@khanacademy/graphql-flow 3.2.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,7 @@ jobs:
34
34
 
35
35
  - name: Run TypeScript
36
36
  if: steps.ts-files.outputs.filtered != '[]'
37
- run: yarn tsc
37
+ run: yarn typecheck
38
38
 
39
39
  - id: eslint-reset
40
40
  uses: Khan/actions@filter-files-v1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @khanacademy/graphql-flow
2
2
 
3
+ ## 3.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c699e6a: Export the introspection options we use
8
+
9
+ ## 3.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - b9fc899: Adds support for marking input fields as @deprecated
14
+
3
15
  ## 3.2.0
4
16
 
5
17
  ### Minor Changes
@@ -12,6 +12,7 @@ var _jsonschema = require("jsonschema");
12
12
  var _minimist = _interopRequireDefault(require("minimist"));
13
13
  var _child_process = require("child_process");
14
14
  var _path = _interopRequireDefault(require("path"));
15
+ var _getIntrospectionQuery = require("./get-introspection-query");
15
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
17
  const validateOrThrow = (value, jsonSchema) => {
17
18
  const result = (0, _jsonschema.validate)(value, jsonSchema);
@@ -67,9 +68,7 @@ const getSchemas = schemaFilePath => {
67
68
  const schemaForValidation = (0, _graphql.buildSchema)(raw);
68
69
  const queryResponse = (0, _graphql.graphqlSync)({
69
70
  schema: schemaForValidation,
70
- source: (0, _graphql.getIntrospectionQuery)({
71
- descriptions: true
72
- })
71
+ source: (0, _getIntrospectionQuery.getIntrospectionQuery)()
73
72
  });
74
73
  const schemaForTypeGeneration = (0, _schemaFromIntrospectionData.schemaFromIntrospectionData)(queryResponse.data);
75
74
  return [schemaForValidation, schemaForTypeGeneration];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getIntrospectionQuery = void 0;
7
+ var _graphql = require("graphql");
8
+ const INTROSPECTION_OPTIONS = {
9
+ descriptions: true,
10
+ inputValueDeprecation: true
11
+ };
12
+ const getIntrospectionQuery = () => {
13
+ return (0, _graphql.getIntrospectionQuery)(INTROSPECTION_OPTIONS);
14
+ };
15
+ exports.getIntrospectionQuery = getIntrospectionQuery;
package/dist/index.js CHANGED
@@ -4,10 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.documentToFlowTypes = exports.FlowGenerationError = void 0;
7
+ Object.defineProperty(exports, "getIntrospectionQuery", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _getIntrospectionQuery.getIntrospectionQuery;
11
+ }
12
+ });
7
13
  var _wonderStuffCore = require("@khanacademy/wonder-stuff-core");
8
14
  var _generator = _interopRequireDefault(require("@babel/generator"));
9
15
  var _generateResponseType = require("./generateResponseType");
10
16
  var _generateVariablesType = require("./generateVariablesType");
17
+ var _getIntrospectionQuery = require("./cli/get-introspection-query");
11
18
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
19
  /* eslint-disable no-console */
13
20
  /* flow-uncovered-file */
@@ -18,6 +25,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
18
25
  * which is produced by running `./tools/graphql-flow/sendIntrospection.js`.
19
26
  */
20
27
 
28
+ // NOTE(kevinb): This is exported so that tooling in other repos can use
29
+ // the same options for their introspection query. In particular, we use
30
+ // this in Khan/frontend when downloading the introspection JSON from prod.
31
+
21
32
  const optionsToConfig = (schema, definitions, options, errors = []) => {
22
33
  var _options$strictNullab, _options$readOnlyArra, _options$scalars, _options$typeScript, _options$omitFileExte;
23
34
  const internalOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/graphql-flow",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "bin": {
5
5
  "graphql-flow": "./dist/cli/run.js"
6
6
  },
@@ -11,6 +11,7 @@
11
11
  },
12
12
  "scripts": {
13
13
  "test": "jest",
14
+ "typecheck": "tsc --noEmit",
14
15
  "publish:ci": "yarn run build && changeset publish",
15
16
  "build": "babel src --extensions '.ts, .tsx' --out-dir dist --ignore 'src/**/*.spec.ts','src/**/*.test.ts' && chmod 755 dist/cli/run.js"
16
17
  },
@@ -61,6 +61,7 @@ input CharacterInput {
61
61
  appearsIn: [Episode!]
62
62
  candies: PositiveNumber!
63
63
  friendly: Boolean! = true
64
+ toBeRemoved: String @deprecated(reason: "Unused")
64
65
  }
65
66
 
66
67
  type Mutation {
@@ -579,6 +579,7 @@ describe("graphql-flow generation", () => {
579
579
  "NEW_HOPE" | "EMPIRE" | "JEDI"> | null | undefined;
580
580
  candies: number;
581
581
  friendly?: boolean | null | undefined;
582
+ toBeRemoved?: string | null | undefined;
582
583
  };
583
584
  },
584
585
  response: {
@@ -610,6 +611,7 @@ describe("graphql-flow generation", () => {
610
611
  appearsIn?: ReadonlyArray<"NEW_HOPE" | "EMPIRE" | "JEDI"> | null | undefined;
611
612
  candies: number;
612
613
  friendly?: boolean | null | undefined;
614
+ toBeRemoved?: string | null | undefined;
613
615
  };
614
616
  },
615
617
  response: {
package/src/cli/config.ts CHANGED
@@ -8,9 +8,8 @@ import fs from "fs";
8
8
  import {
9
9
  buildClientSchema,
10
10
  buildSchema,
11
- getIntrospectionQuery,
12
11
  graphqlSync,
13
- IntrospectionQuery,
12
+ type IntrospectionQuery,
14
13
  } from "graphql";
15
14
  import {validate} from "jsonschema";
16
15
  import processArgs from "minimist";
@@ -18,6 +17,8 @@ import type {Config, GenerateConfig} from "../types";
18
17
  import {execSync} from "child_process";
19
18
  import path from "path";
20
19
 
20
+ import {getIntrospectionQuery} from "./get-introspection-query";
21
+
21
22
  export const validateOrThrow = (value: unknown, jsonSchema: unknown) => {
22
23
  const result = validate(value, jsonSchema);
23
24
  if (!result.valid) {
@@ -91,7 +92,7 @@ export const getSchemas = (schemaFilePath: string): [GraphQLSchema, Schema] => {
91
92
  const schemaForValidation = buildSchema(raw);
92
93
  const queryResponse = graphqlSync({
93
94
  schema: schemaForValidation,
94
- source: getIntrospectionQuery({descriptions: true}),
95
+ source: getIntrospectionQuery(),
95
96
  });
96
97
  const schemaForTypeGeneration = schemaFromIntrospectionData(
97
98
  queryResponse.data as any as IntrospectionQuery,
@@ -0,0 +1,13 @@
1
+ import {
2
+ getIntrospectionQuery as getIntrospectionQueryWithOptions,
3
+ type IntrospectionOptions,
4
+ } from "graphql";
5
+
6
+ const INTROSPECTION_OPTIONS: IntrospectionOptions = {
7
+ descriptions: true,
8
+ inputValueDeprecation: true,
9
+ };
10
+
11
+ export const getIntrospectionQuery = () => {
12
+ return getIntrospectionQueryWithOptions(INTROSPECTION_OPTIONS);
13
+ };
package/src/index.ts CHANGED
@@ -19,6 +19,11 @@ import type {Node} from "@babel/types";
19
19
 
20
20
  import type {Context, Schema, GenerateConfig} from "./types";
21
21
 
22
+ // NOTE(kevinb): This is exported so that tooling in other repos can use
23
+ // the same options for their introspection query. In particular, we use
24
+ // this in Khan/frontend when downloading the introspection JSON from prod.
25
+ export {getIntrospectionQuery} from "./cli/get-introspection-query";
26
+
22
27
  const optionsToConfig = (
23
28
  schema: Schema,
24
29
  definitions: ReadonlyArray<DefinitionNode>,