@khanacademy/graphql-flow 3.3.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/changeset-release.yml +17 -2
- package/.github/workflows/pr-checks.yml +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/cli/config.js +2 -4
- package/dist/cli/get-introspection-query.js +15 -0
- package/dist/index.js +11 -0
- package/package.json +14 -2
- package/src/cli/config.ts +4 -6
- package/src/cli/get-introspection-query.ts +13 -0
- package/src/index.ts +5 -0
|
@@ -5,6 +5,10 @@ on:
|
|
|
5
5
|
branches:
|
|
6
6
|
- main
|
|
7
7
|
|
|
8
|
+
permissions:
|
|
9
|
+
id-token: write # required for publishing to npm
|
|
10
|
+
contents: write # required to `git push`
|
|
11
|
+
|
|
8
12
|
# This workflow will run changesets depending on two different scenarios:
|
|
9
13
|
#
|
|
10
14
|
# 1. If we are landing a specific commit into main (Author PR), then
|
|
@@ -36,18 +40,29 @@ jobs:
|
|
|
36
40
|
with:
|
|
37
41
|
node-version: 20.x
|
|
38
42
|
|
|
43
|
+
- name: ⬆️ Upgrade npm for OIDC support
|
|
44
|
+
shell: bash
|
|
45
|
+
run: |
|
|
46
|
+
# npm trusted publishing requires npm CLI v11.5.1+
|
|
47
|
+
# Node.js 22 ships with npm 10.x, so we need to upgrade
|
|
48
|
+
npm install -g npm@latest
|
|
49
|
+
echo "✅ npm upgraded to $(npm --version)"
|
|
50
|
+
|
|
39
51
|
- name: Create Release Pull Request or Publish to npm
|
|
40
52
|
id: changesets
|
|
41
53
|
uses: changesets/action@v1
|
|
42
54
|
with:
|
|
43
|
-
publish:
|
|
55
|
+
publish: npm run publish:ci
|
|
44
56
|
env:
|
|
45
57
|
# We use a Personal Access Token here rather than the GITHUB_TOKEN
|
|
46
58
|
# so that it will trigger our other actions. The token has to be on
|
|
47
59
|
# the account of someone with appropriate access levels and given the
|
|
48
60
|
# repo scope.
|
|
49
61
|
GITHUB_TOKEN: ${{ secrets.KHAN_ACTIONS_BOT_TOKEN }}
|
|
50
|
-
|
|
62
|
+
# Note: we no longer use the NPM_TOKEN secret because we've enabled
|
|
63
|
+
# Trusted Publishing (https://docs.npmjs.com/trusted-publishers) on
|
|
64
|
+
# the npmjs.com side:
|
|
65
|
+
# https://www.npmjs.com/package/@khanacademy/graphql-flow/access
|
|
51
66
|
|
|
52
67
|
- name: Send a Slack notification for web if a publish happens
|
|
53
68
|
if: steps.changesets.outputs.published == 'true'
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @khanacademy/graphql-flow
|
|
2
2
|
|
|
3
|
+
## 3.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 958d35e: Enable Trusted Publishing for npm
|
|
8
|
+
|
|
9
|
+
## 3.4.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 92b8412: Update project to use Trusted Publishing
|
|
14
|
+
|
|
15
|
+
## 3.4.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- c699e6a: Export the introspection options we use
|
|
20
|
+
|
|
3
21
|
## 3.3.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/cli/config.js
CHANGED
|
@@ -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,10 +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,
|
|
71
|
-
descriptions: true,
|
|
72
|
-
inputValueDeprecation: true
|
|
73
|
-
})
|
|
71
|
+
source: (0, _getIntrospectionQuery.getIntrospectionQuery)()
|
|
74
72
|
});
|
|
75
73
|
const schemaForTypeGeneration = (0, _schemaFromIntrospectionData.schemaFromIntrospectionData)(queryResponse.data);
|
|
76
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,8 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/graphql-flow",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.2",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/Khan/graphql-flow.git"
|
|
7
|
+
},
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/Khan/graphql-flow/issues"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"provenance": true
|
|
14
|
+
},
|
|
4
15
|
"bin": {
|
|
5
|
-
"graphql-flow": "
|
|
16
|
+
"graphql-flow": "dist/cli/run.js"
|
|
6
17
|
},
|
|
7
18
|
"jest": {
|
|
8
19
|
"testPathIgnorePatterns": [
|
|
@@ -11,6 +22,7 @@
|
|
|
11
22
|
},
|
|
12
23
|
"scripts": {
|
|
13
24
|
"test": "jest",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
14
26
|
"publish:ci": "yarn run build && changeset publish",
|
|
15
27
|
"build": "babel src --extensions '.ts, .tsx' --out-dir dist --ignore 'src/**/*.spec.ts','src/**/*.test.ts' && chmod 755 dist/cli/run.js"
|
|
16
28
|
},
|
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,10 +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(
|
|
95
|
-
descriptions: true,
|
|
96
|
-
inputValueDeprecation: true,
|
|
97
|
-
}),
|
|
95
|
+
source: getIntrospectionQuery(),
|
|
98
96
|
});
|
|
99
97
|
const schemaForTypeGeneration = schemaFromIntrospectionData(
|
|
100
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>,
|