protoc-gen-pothos 0.3.2 → 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Masayuki Izumi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,4 +2,53 @@
2
2
 
3
3
  Build GraphQL schema from Protobuf and [Pothos GraphQL](https://pothos-graphql.dev/).
4
4
 
5
- - repository: https://github.com/proto-graphql/proto-graphql-js
5
+ ## Supported Protocol Buffers Implementations
6
+
7
+ - [ts-proto](https://github.com/stephenh/ts-proto)
8
+
9
+ ## Configuration with [Buf](https://docs.buf.build/installation)
10
+
11
+ ```yaml
12
+ # proto/buf.yaml
13
+ version: v1
14
+ deps:
15
+ - buf.build/proto-graphql/proto-graphql
16
+ ```
17
+
18
+ ### with [ts-proto](https://github.com/stephenh/ts-proto)
19
+
20
+ ```yaml
21
+ # proto/buf.gen.yaml
22
+ version: v1
23
+ plugins:
24
+ - name: ts
25
+ out: ../src/__generated__/proto
26
+ strategy: all
27
+ path: ../node_modules/.bin/protoc-gen-ts_proto
28
+ opt:
29
+ - esModuleInterop=true # required
30
+ - unrecognizedEnum=false # required
31
+ - outputTypeRegistry=true # required
32
+ strategy: all
33
+ - name: pothos
34
+ path: ../node_modules/.bin/protoc-gen-pothos
35
+ out: ../src/__generated__/pothos
36
+ opt:
37
+ - pothos_builder_path=../../builder
38
+ - import_prefix=../proto
39
+ ```
40
+
41
+ ### Supported options
42
+
43
+ - `import_prefix` (`string`, required)
44
+ - path to out dir of ts-proto
45
+ - `pothos_builder_path` (`string`, required)
46
+ - path to file that exports pothos builder
47
+ - `emit_imported_files` (`bool`, optional)
48
+ - if `true`, protoc-gen-pothos also emits types defined in imported `.proto` file.
49
+ - `custom_type` (`string`, optional)
50
+ - `long_number` (`string`, optional, default `String`)
51
+
52
+ ## Author
53
+
54
+ - Masayuki Izumi ([twitter: @izumin5210](https://github.com/izumin5210), [github: @izumin5210](https://github.com/izumin5210))
@@ -1 +1 @@
1
- {"version":3,"file":"inputObjectType.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/inputObjectType.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAGhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAkC,MAAM,SAAS,CAAC;AAG/D,OAAO,EAGL,oBAAoB,EAGrB,MAAM,QAAQ,CAAC;AAEhB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAkDN"}
1
+ {"version":3,"file":"inputObjectType.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/inputObjectType.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAIhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAkC,MAAM,SAAS,CAAC;AAG/D,OAAO,EAGL,oBAAoB,EAGrB,MAAM,QAAQ,CAAC;AAEhB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAsDN"}
@@ -35,7 +35,9 @@ function createInputObjectTypeCode(type, opts) {
35
35
  }
36
36
  return f.isNullable()
37
37
  ? (0, ts_poet_1.code) `${f.name}?: ${typeNode} | null,`
38
- : (0, ts_poet_1.code) `${f.name}: ${typeNode},`;
38
+ : (0, ts_poet_1.code) `${f.name}: ${f.type instanceof codegen_core_1.ScalarType && f.type.isCustomScalar()
39
+ ? (0, ts_poet_1.code) `NonNullable<${typeNode}>`
40
+ : typeNode},`;
39
41
  }))}
40
42
  };
41
43
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"inputObjectType.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/inputObjectType.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAGhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAkC,MAAM,SAAS,CAAC;AAG/D,OAAO,EAGL,oBAAoB,EAGrB,MAAM,QAAQ,CAAC;AAEhB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAkDN"}
1
+ {"version":3,"file":"inputObjectType.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/inputObjectType.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAIhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAkC,MAAM,SAAS,CAAC;AAG/D,OAAO,EAGL,oBAAoB,EAGrB,MAAM,QAAQ,CAAC;AAEhB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAsDN"}
@@ -1,4 +1,4 @@
1
- import { compact, InputObjectType, protobufGraphQLExtensions, protoType, } from "@proto-graphql/codegen-core";
1
+ import { compact, InputObjectType, protobufGraphQLExtensions, protoType, ScalarType, } from "@proto-graphql/codegen-core";
2
2
  import { code, imp, joinCode, literalOf } from "ts-poet";
3
3
  import { createFieldRefCode, createNoopFieldRefCode } from "./field";
4
4
  import { fieldTypeShape, pothosBuilder, pothosRef, shapeType, } from "./util";
@@ -32,7 +32,9 @@ export function createInputObjectTypeCode(type, opts) {
32
32
  }
33
33
  return f.isNullable()
34
34
  ? code `${f.name}?: ${typeNode} | null,`
35
- : code `${f.name}: ${typeNode},`;
35
+ : code `${f.name}: ${f.type instanceof ScalarType && f.type.isCustomScalar()
36
+ ? code `NonNullable<${typeNode}>`
37
+ : typeNode},`;
36
38
  }))}
37
39
  };
38
40
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "protoc-gen-pothos",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Generate DSL for Pothos GraphQL from Protocol Buffers IDL",
5
5
  "keywords": [
6
6
  "graphql",
@@ -23,24 +23,30 @@
23
23
  "node": ">= 14.0.0"
24
24
  },
25
25
  "dependencies": {
26
- "@proto-graphql/codegen-core": "^0.3.2",
27
- "@proto-graphql/proto-descriptors": "^0.3.1",
28
- "@proto-graphql/protoc-plugin-helpers": "^0.2.3",
29
26
  "google-protobuf": "^3.21.2",
30
- "ts-poet": "^6.3.0"
27
+ "ts-poet": "^6.3.0",
28
+ "@proto-graphql/codegen-core": "0.3.4",
29
+ "@proto-graphql/proto-descriptors": "0.3.3",
30
+ "@proto-graphql/protoc-plugin-helpers": "0.2.6"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/google-protobuf": "^3.15.6"
33
+ "@proto-graphql/eslint-config": "0.1.0",
34
+ "@proto-graphql/testapis-proto": "0.1.0",
35
+ "@proto-graphql/tsconfig": "0.1.0"
34
36
  },
35
37
  "files": [
36
38
  "bin/",
37
- "include/",
38
39
  "lib/",
39
40
  "module/"
40
41
  ],
41
42
  "scripts": {
42
- "build": "tsc --build tsconfig.cjs.json && tsc --build tsconfig.module.json",
43
- "clean": "rimraf lib/ module/ && tsc --build tsconfig.cjs.json --clean && tsc --build tsconfig.module.json --clean",
43
+ "build": "pnpm run build:cjs && pnpm run build:module",
44
+ "build:cjs": "tsc --build tsconfig.cjs.json",
45
+ "build:module": "tsc --build tsconfig.module.json",
46
+ "clean": "pnpm run clean:cjs && pnpm run clean:module",
47
+ "clean:cjs": "pnpm run build:cjs --clean",
48
+ "clean:module": "pnpm run build:module --clean",
49
+ "lint": "eslint --fix .",
44
50
  "test": "jest --coverage"
45
51
  }
46
- }
52
+ }