protoc-gen-pothos 0.1.1 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # protoc-gen-pothos
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#217](https://github.com/proto-graphql/proto-graphql-js/pull/217) [`5e2e85b`](https://github.com/proto-graphql/proto-graphql-js/commit/5e2e85baf6e0e21960104d3db30a4e21e04e1627) Thanks [@izumin5210](https://github.com/izumin5210)! - add `eslint-disable` directive to generated files
8
+
9
+ - [#218](https://github.com/proto-graphql/proto-graphql-js/pull/218) [`c1246c3`](https://github.com/proto-graphql/proto-graphql-js/commit/c1246c3a349f11e3b2bbfd6198c1a06b37270ece) Thanks [@izumin5210](https://github.com/izumin5210)! - fix non-null custom scalar field resolver
10
+
11
+ - Updated dependencies [[`c1246c3`](https://github.com/proto-graphql/proto-graphql-js/commit/c1246c3a349f11e3b2bbfd6198c1a06b37270ece)]:
12
+ - @proto-graphql/codegen-core@0.1.2
13
+
3
14
  ## 0.1.1
4
15
 
5
16
  ### Patch Changes
@@ -51,7 +51,9 @@ function createFieldDefinitionExpr(field) {
51
51
  }
52
52
  let createResolveStmts;
53
53
  if (!isInput) {
54
- if (field.type instanceof codegen_core_1.ObjectType && !field.isNullable()) {
54
+ const nullableInProto = field.type instanceof codegen_core_1.ObjectType ||
55
+ (field.type instanceof codegen_core_1.ScalarType && !field.type.isPrimitive() && !field.type.isWrapperType());
56
+ if (nullableInProto && !field.isNullable()) {
55
57
  createResolveStmts = (sourceExpr) => (0, nonNullResolver_1.createNonNullResolverStmts)(typescript_1.default.factory.createPropertyAccessExpression(sourceExpr, field.protoJsName));
56
58
  }
57
59
  if (field.type instanceof codegen_core_1.EnumType && field instanceof codegen_core_1.ObjectField) {
package/lib/printer.js CHANGED
@@ -56,6 +56,8 @@ function printSource(types, file) {
56
56
  "// Code generated by protoc-gen-pothos. DO NOT EDIT.",
57
57
  `// source: ${file.descriptor.getName()}`,
58
58
  "",
59
+ "/* eslint-disable */",
60
+ "",
59
61
  result,
60
62
  ].join("\n");
61
63
  return content;
@@ -45,7 +45,9 @@ export function createFieldDefinitionExpr(field) {
45
45
  }
46
46
  let createResolveStmts;
47
47
  if (!isInput) {
48
- if (field.type instanceof ObjectType && !field.isNullable()) {
48
+ const nullableInProto = field.type instanceof ObjectType ||
49
+ (field.type instanceof ScalarType && !field.type.isPrimitive() && !field.type.isWrapperType());
50
+ if (nullableInProto && !field.isNullable()) {
49
51
  createResolveStmts = (sourceExpr) => createNonNullResolverStmts(ts.factory.createPropertyAccessExpression(sourceExpr, field.protoJsName));
50
52
  }
51
53
  if (field.type instanceof EnumType && field instanceof ObjectField) {
package/module/printer.js CHANGED
@@ -49,6 +49,8 @@ function printSource(types, file) {
49
49
  "// Code generated by protoc-gen-pothos. DO NOT EDIT.",
50
50
  `// source: ${file.descriptor.getName()}`,
51
51
  "",
52
+ "/* eslint-disable */",
53
+ "",
52
54
  result,
53
55
  ].join("\n");
54
56
  return content;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "protoc-gen-pothos",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Generate DSL for Pothos GraphQL from Protocol Buffers IDL",
5
5
  "keywords": [
6
6
  "graphql",
@@ -23,7 +23,7 @@
23
23
  "node": ">= 14.0.0"
24
24
  },
25
25
  "dependencies": {
26
- "@proto-graphql/codegen-core": "^0.1.1",
26
+ "@proto-graphql/codegen-core": "^0.1.2",
27
27
  "@proto-graphql/proto-descriptors": "^0.1.0",
28
28
  "@proto-graphql/protoc-plugin-helpers": "^0.1.1",
29
29
  "google-protobuf": "^3.20.1"