@toptal/davinci-graphql-codegen 0.1.1-alpha-feature-comm-620-graphql-codegen.1451 → 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ # @toptal/davinci-graphql-codegen
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1153](https://github.com/toptal/davinci/pull/1153) [`b51f6179`](https://github.com/toptal/davinci/commit/b51f61791640b552b3d861cfe14fcb3e6ebedb56) Thanks [@alexvcasillas](https://github.com/alexvcasillas)! - Release for GraphQL Codegen
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@toptal/davinci-graphql-codegen",
3
+ "version": "0.1.1",
4
+ "description": "Codegen",
5
+ "author": "Toptal",
6
+ "license": "ISC",
7
+ "homepage": "https://github.com/toptal/davinci/tree/master/packages/graphql-codegen#readme",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "bin": {
12
+ "davinci-graphql-codegen": "./bin/davinci-graphql-codegen.js"
13
+ },
14
+ "main": "./src/index.js",
15
+ "scripts": {
16
+ "build:package": "../../bin/build-package.js",
17
+ "prepublishOnly": "../../bin/prepublish.js",
18
+ "test": "echo \"Error: no test specified\" && exit 1"
19
+ },
20
+ "sideEffects": false,
21
+ "dependencies": {
22
+ "@google-cloud/storage": "^5.16.1",
23
+ "@toptal/davinci-cli-shared": "^1.5.0",
24
+ "chalk": "^4.1.2",
25
+ "graphql": "^15.7.1",
26
+ "@graphql-codegen/add": "^3.1.0",
27
+ "@graphql-codegen/cli": "^2.2.0",
28
+ "@graphql-codegen/introspection": "^2.1.0",
29
+ "@graphql-codegen/typed-document-node": "^2.1.4",
30
+ "@graphql-codegen/typescript": "^2.2.2",
31
+ "@graphql-codegen/typescript-operations": "^2.1.4",
32
+ "@graphql-codegen/typescript-resolvers": "^2.2.1",
33
+ "@graphql-typed-document-node/core": "^3.1.0"
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-graphql-codegen",
3
- "version": "0.1.1-alpha-feature-comm-620-graphql-codegen.1451+7ee636be",
3
+ "version": "0.1.1",
4
4
  "description": "Codegen",
5
5
  "author": "Toptal",
6
6
  "license": "ISC",
@@ -20,6 +20,9 @@
20
20
  "sideEffects": false,
21
21
  "dependencies": {
22
22
  "@google-cloud/storage": "^5.16.1",
23
+ "@toptal/davinci-cli-shared": "^1.5.0",
24
+ "chalk": "^4.1.2",
25
+ "graphql": "^15.7.1",
23
26
  "@graphql-codegen/add": "^3.1.0",
24
27
  "@graphql-codegen/cli": "^2.2.0",
25
28
  "@graphql-codegen/introspection": "^2.1.0",
@@ -27,10 +30,6 @@
27
30
  "@graphql-codegen/typescript": "^2.2.2",
28
31
  "@graphql-codegen/typescript-operations": "^2.1.4",
29
32
  "@graphql-codegen/typescript-resolvers": "^2.2.1",
30
- "@graphql-typed-document-node/core": "^3.1.0",
31
- "@toptal/davinci-cli-shared": "1.5.1-alpha-feature-comm-620-graphql-codegen.91+7ee636be",
32
- "chalk": "^4.1.2",
33
- "graphql": "^15.7.1"
34
- },
35
- "gitHead": "7ee636beaeb668c3752550f0b808e026db7a4341"
33
+ "@graphql-typed-document-node/core": "^3.1.0"
34
+ }
36
35
  }
@@ -6,6 +6,7 @@ const {
6
6
  autoGenerationComments
7
7
  } = require('../config/config')
8
8
  const schemaLoader = require('../services/schema-loader')
9
+ const { isSchemaFromHttp } = require('../utils/detect-schema-source')
9
10
 
10
11
  const generateSchema = async ({ schema, target, projectId }) => {
11
12
  const {
@@ -23,7 +24,7 @@ const generateSchema = async ({ schema, target, projectId }) => {
23
24
  // plugins: ['introspection']
24
25
  // },
25
26
  [destinationPathTs]: {
26
- schema: schema.startsWith('https://')
27
+ schema: isSchemaFromHttp(schema)
27
28
  ? schema
28
29
  : require.resolve(schemaPath),
29
30
  plugins: [
@@ -0,0 +1,29 @@
1
+ const {
2
+ isSchemaFromBucket,
3
+ isSchemaFromHttp,
4
+ isLocalSchema
5
+ } = require('./detect-schema-source')
6
+
7
+ const gsBucketSchema = 'gs://toptal.net/gateway/graphql/talent'
8
+ const httpSchema = 'https://toptal.net/gateway/graphql/talent'
9
+ const localSchema = '../../graphql/talent'
10
+
11
+ describe('Detect Schema Sources', () => {
12
+ it('detects that schema is from GS Bucket', () => {
13
+ expect(isSchemaFromBucket(gsBucketSchema)).toBe(true)
14
+ expect(isSchemaFromHttp(gsBucketSchema)).toBe(false)
15
+ expect(isLocalSchema(gsBucketSchema)).toBe(false)
16
+ })
17
+
18
+ it('detects that schema is from http', () => {
19
+ expect(isSchemaFromBucket(httpSchema)).toBe(false)
20
+ expect(isSchemaFromHttp(httpSchema)).toBe(true)
21
+ expect(isLocalSchema(httpSchema)).toBe(false)
22
+ })
23
+
24
+ it('detects that schema is from local folder', () => {
25
+ expect(isSchemaFromBucket(localSchema)).toBe(false)
26
+ expect(isSchemaFromHttp(localSchema)).toBe(false)
27
+ expect(isLocalSchema(localSchema)).toBe(true)
28
+ })
29
+ })
@@ -0,0 +1,12 @@
1
+ const parseGSURI = require('./parse-gs-uri')
2
+
3
+ const bucketURI = 'gs://gqlgw-introspection/staging_talent_schema.graphql'
4
+
5
+ describe('Parse Google Storage Bucket URI', () => {
6
+ it('parses a Google Storage Bucket URI correctly', () => {
7
+ const { bucketName, fileName } = parseGSURI(bucketURI)
8
+
9
+ expect(bucketName).toBe('gqlgw-introspection')
10
+ expect(fileName).toBe('staging_talent_schema.graphql')
11
+ })
12
+ })
@@ -9,13 +9,10 @@ const processArgs = args => {
9
9
  }
10
10
 
11
11
  // Eg: Parts -> ['projectId', 'toptal-hub']
12
- const parts = arg
12
+ const [key, value] = arg
13
13
  .split(/(?:--)([a-zA-Z]*)(?:=)([a-zA-Z-]*)/i)
14
14
  .filter(Boolean)
15
15
 
16
- const key = parts[0]
17
- const value = parts[1]
18
-
19
16
  obj[key] = value
20
17
  })
21
18
 
@@ -0,0 +1,10 @@
1
+ const processArgs = require('./process-args')
2
+
3
+ describe('Argument processor', () => {
4
+ it('process arguments correctly', () => {
5
+ const args = processArgs(['generate-operations', '--projectId=toptal'])
6
+
7
+ expect(args.operation).toBe('generate-operations')
8
+ expect(args.projectId).toBe('toptal')
9
+ })
10
+ })
@@ -0,0 +1,15 @@
1
+ const toArray = require('./to-array')
2
+
3
+ describe('toArray', () => {
4
+ it("converts a value into an array if it's not one", () => {
5
+ const asArray = toArray('hello')
6
+
7
+ expect(Array.isArray(asArray)).toBe(true)
8
+ })
9
+
10
+ it("returns the array as is if it's an array", () => {
11
+ const asArray = toArray(['hello', 'there'])
12
+
13
+ expect(Array.isArray(asArray)).toBe(true)
14
+ })
15
+ })