@khanacademy/graphql-flow 2.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cli/config.js +6 -3
- package/dist/cli/run.js +4 -1
- package/dist/parser/parse.js +4 -1
- package/dist/parser/utils.js +6 -2
- package/package.json +2 -2
- package/src/cli/config.ts +5 -5
- package/src/cli/run.ts +4 -1
- package/src/parser/parse.ts +3 -1
- package/src/parser/utils.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @khanacademy/graphql-flow
|
|
2
2
|
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c6be76f: Search through untracked files for graphql-tag. Don't error out on files that can't be found.
|
|
8
|
+
|
|
9
|
+
## 3.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- ad68019: Update 'graphql' to 16.3.x (requires consumers to change their version of 'graphql')
|
|
14
|
+
|
|
3
15
|
## 2.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/dist/cli/config.js
CHANGED
|
@@ -52,9 +52,12 @@ const getSchemas = schemaFilePath => {
|
|
|
52
52
|
|
|
53
53
|
if (schemaFilePath.endsWith('.graphql')) {
|
|
54
54
|
const schemaForValidation = (0, _graphql.buildSchema)(raw);
|
|
55
|
-
const queryResponse = (0, _graphql.graphqlSync)(
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const queryResponse = (0, _graphql.graphqlSync)({
|
|
56
|
+
schema: schemaForValidation,
|
|
57
|
+
source: (0, _graphql.getIntrospectionQuery)({
|
|
58
|
+
descriptions: true
|
|
59
|
+
})
|
|
60
|
+
});
|
|
58
61
|
const schemaForTypeGeneration = (0, _schemaFromIntrospectionData.schemaFromIntrospectionData)( // eslint-disable-next-line flowtype-errors/uncovered
|
|
59
62
|
queryResponse.data);
|
|
60
63
|
return [schemaForValidation, schemaForTypeGeneration];
|
package/dist/cli/run.js
CHANGED
|
@@ -42,7 +42,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
42
42
|
|
|
43
43
|
/** Step (1) */
|
|
44
44
|
const findGraphqlTagReferences = root => {
|
|
45
|
-
|
|
45
|
+
// NOTE(john): We want to include untracked files here so that we can
|
|
46
|
+
// generate types for them. This is useful for when we have a new file
|
|
47
|
+
// that we want to generate types for, but we haven't committed it yet.
|
|
48
|
+
const response = (0, _child_process.execSync)("git grep -I --word-regexp --name-only --fixed-strings --untracked 'graphql-tag' -- '*.js' '*.jsx' '*.ts' '*.tsx'", {
|
|
46
49
|
encoding: 'utf8',
|
|
47
50
|
cwd: root
|
|
48
51
|
});
|
package/dist/parser/parse.js
CHANGED
|
@@ -35,7 +35,10 @@ const listExternalReferences = file => {
|
|
|
35
35
|
if (v.type === 'import') {
|
|
36
36
|
if (followImports) {
|
|
37
37
|
const absPath = (0, _utils.getPathWithExtension)(v.path);
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
if (absPath) {
|
|
40
|
+
paths[absPath] = true;
|
|
41
|
+
}
|
|
39
42
|
}
|
|
40
43
|
} else {
|
|
41
44
|
v.source.expressions.forEach(expr => add(expr, true));
|
package/dist/parser/utils.js
CHANGED
|
@@ -28,9 +28,13 @@ const getPathWithExtension = pathWithoutExtension => {
|
|
|
28
28
|
|
|
29
29
|
if (_fs.default.existsSync(pathWithoutExtension + '.ts')) {
|
|
30
30
|
return pathWithoutExtension + '.ts';
|
|
31
|
-
}
|
|
31
|
+
} // NOTE(john): This is a bit of a hack, but it's necessary for when we
|
|
32
|
+
// have a file that doesn't exist. This will happen when we delete all of
|
|
33
|
+
// the type files before re-running graphql-flow again. We want to ensure
|
|
34
|
+
// that we don't error out in this case.
|
|
35
|
+
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
return "";
|
|
34
38
|
};
|
|
35
39
|
|
|
36
40
|
exports.getPathWithExtension = getPathWithExtension;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/graphql-flow",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"bin": {
|
|
5
5
|
"graphql-flow": "./dist/cli/run.js"
|
|
6
6
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@babel/types": "^7.17.0",
|
|
41
41
|
"@khanacademy/wonder-stuff-core": "^1.5.1",
|
|
42
42
|
"apollo-utilities": "^1.3.4",
|
|
43
|
-
"graphql": "
|
|
43
|
+
"graphql": "^16.3.0",
|
|
44
44
|
"jsonschema": "^1.4.1",
|
|
45
45
|
"prettier": "^2.5.1",
|
|
46
46
|
"prettier-eslint": "^13.0.0"
|
package/src/cli/config.ts
CHANGED
|
@@ -39,13 +39,13 @@ export const getSchemas = (schemaFilePath: string): [GraphQLSchema, Schema] => {
|
|
|
39
39
|
const raw = fs.readFileSync(schemaFilePath, 'utf8');
|
|
40
40
|
if (schemaFilePath.endsWith('.graphql')) {
|
|
41
41
|
const schemaForValidation = buildSchema(raw);
|
|
42
|
-
const queryResponse = graphqlSync(
|
|
43
|
-
schemaForValidation,
|
|
44
|
-
getIntrospectionQuery({descriptions: true}),
|
|
45
|
-
);
|
|
42
|
+
const queryResponse = graphqlSync({
|
|
43
|
+
schema: schemaForValidation,
|
|
44
|
+
source: getIntrospectionQuery({descriptions: true}),
|
|
45
|
+
});
|
|
46
46
|
const schemaForTypeGeneration = schemaFromIntrospectionData(
|
|
47
47
|
// eslint-disable-next-line flowtype-errors/uncovered
|
|
48
|
-
(queryResponse.data as IntrospectionQuery),
|
|
48
|
+
((queryResponse.data as any) as IntrospectionQuery),
|
|
49
49
|
);
|
|
50
50
|
return [schemaForValidation, schemaForTypeGeneration];
|
|
51
51
|
} else {
|
package/src/cli/run.ts
CHANGED
|
@@ -32,8 +32,11 @@ import {dirname} from 'path';
|
|
|
32
32
|
/** Step (1) */
|
|
33
33
|
|
|
34
34
|
const findGraphqlTagReferences = (root: string): Array<string> => {
|
|
35
|
+
// NOTE(john): We want to include untracked files here so that we can
|
|
36
|
+
// generate types for them. This is useful for when we have a new file
|
|
37
|
+
// that we want to generate types for, but we haven't committed it yet.
|
|
35
38
|
const response = execSync(
|
|
36
|
-
"git grep -I --word-regexp --name-only --fixed-strings 'graphql-tag' -- '*.js' '*.jsx' '*.ts' '*.tsx'",
|
|
39
|
+
"git grep -I --word-regexp --name-only --fixed-strings --untracked 'graphql-tag' -- '*.js' '*.jsx' '*.ts' '*.tsx'",
|
|
37
40
|
{
|
|
38
41
|
encoding: 'utf8',
|
|
39
42
|
cwd: root,
|
package/src/parser/parse.ts
CHANGED
|
@@ -105,7 +105,9 @@ const listExternalReferences = (file: FileResult): Array<string> => {
|
|
|
105
105
|
if (v.type === 'import') {
|
|
106
106
|
if (followImports) {
|
|
107
107
|
const absPath = getPathWithExtension(v.path);
|
|
108
|
-
|
|
108
|
+
if (absPath) {
|
|
109
|
+
paths[absPath] = true;
|
|
110
|
+
}
|
|
109
111
|
}
|
|
110
112
|
} else {
|
|
111
113
|
v.source.expressions.forEach((expr) => add(expr, true));
|
package/src/parser/utils.ts
CHANGED
|
@@ -20,5 +20,9 @@ export const getPathWithExtension = (pathWithoutExtension: string): string => {
|
|
|
20
20
|
if (fs.existsSync(pathWithoutExtension + '.ts')) {
|
|
21
21
|
return pathWithoutExtension + '.ts';
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
// NOTE(john): This is a bit of a hack, but it's necessary for when we
|
|
24
|
+
// have a file that doesn't exist. This will happen when we delete all of
|
|
25
|
+
// the type files before re-running graphql-flow again. We want to ensure
|
|
26
|
+
// that we don't error out in this case.
|
|
27
|
+
return "";
|
|
24
28
|
};
|