@toptal/davinci-graphql-codegen 0.2.1-alpha-feature-comm-833-reusing-graphql-fragments.2 → 0.2.1-alpha-remove-display-name-from-code-templates.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/davinci-graphql-codegen",
|
|
3
|
-
"version": "0.2.1-alpha-
|
|
3
|
+
"version": "0.2.1-alpha-remove-display-name-from-code-templates.4+052cbcbe",
|
|
4
4
|
"description": "Codegen",
|
|
5
5
|
"author": "Toptal",
|
|
6
6
|
"license": "ISC",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@graphql-codegen/typescript-operations": "^2.1.4",
|
|
30
30
|
"@graphql-codegen/typescript-resolvers": "^2.2.1",
|
|
31
31
|
"@graphql-typed-document-node/core": "^3.1.0",
|
|
32
|
-
"@toptal/davinci-cli-shared": "1.5.2-alpha-
|
|
33
|
-
"@toptal/davinci-monorepo": "6.4.3-alpha-
|
|
32
|
+
"@toptal/davinci-cli-shared": "1.5.2-alpha-remove-display-name-from-code-templates.4+052cbcbe",
|
|
33
|
+
"@toptal/davinci-monorepo": "6.4.3-alpha-remove-display-name-from-code-templates.4+052cbcbe",
|
|
34
34
|
"chalk": "^4.1.2",
|
|
35
35
|
"graphql": "^15.7.1"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "052cbcbef56c98d569c48fa8f950939429276c02"
|
|
38
38
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
1
|
const chalk = require('chalk')
|
|
3
2
|
const { generate } = require('@graphql-codegen/cli')
|
|
4
3
|
|
|
@@ -10,11 +9,6 @@ const getSchemaPath = require('../services/get-schema-path')
|
|
|
10
9
|
const getRelativeFilePath = require('../utils/get-relative-file-path')
|
|
11
10
|
|
|
12
11
|
const generateOperations = async ({ schema, documents, extension }) => {
|
|
13
|
-
const fragmentImportResolverPlugin = path.join(
|
|
14
|
-
__dirname,
|
|
15
|
-
'../plugins/fragment-import-resolver.js'
|
|
16
|
-
)
|
|
17
|
-
|
|
18
12
|
const docsPath = getRelativeFilePath(documents)
|
|
19
13
|
|
|
20
14
|
const { target, schemaPath, schemaPathResolution } = getSchemaPath(schema)
|
|
@@ -37,7 +31,6 @@ const generateOperations = async ({ schema, documents, extension }) => {
|
|
|
37
31
|
baseTypesPath: `~${schema}/schema`
|
|
38
32
|
},
|
|
39
33
|
plugins: [
|
|
40
|
-
fragmentImportResolverPlugin,
|
|
41
34
|
'typescript-operations',
|
|
42
35
|
'typed-document-node',
|
|
43
36
|
{
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3
|
-
plugin(schema, documents, config) {
|
|
4
|
-
const docsLength = documents.length
|
|
5
|
-
// Here we will store the imports that need to be generated :)
|
|
6
|
-
const importsToGenerate = []
|
|
7
|
-
|
|
8
|
-
for (let i = 0; i < docsLength; i++) {
|
|
9
|
-
// Store document for readability and ease of use
|
|
10
|
-
const document = documents[i].rawSDL
|
|
11
|
-
// This RegExp will match custom "# import" syntax
|
|
12
|
-
const importRegExp = new RegExp(/^(?:\s?)+#import.*$/gm)
|
|
13
|
-
// Retrieve matching imports
|
|
14
|
-
const extractedImports = document.match(importRegExp)
|
|
15
|
-
const extractedImportsLength = extractedImports.length
|
|
16
|
-
|
|
17
|
-
// Iterate over and push them to the imports to generate array
|
|
18
|
-
for (let x = 0; x < extractedImportsLength; x++) {
|
|
19
|
-
importsToGenerate.push(`${extractedImports[x].replace('#', '')}`)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Join them all into a single string since a plugin must return a single string
|
|
24
|
-
return importsToGenerate.join('\n')
|
|
25
|
-
}
|
|
26
|
-
}
|