protoc-gen-pothos 0.2.2 → 0.2.3
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,14 @@
|
|
|
1
1
|
# protoc-gen-pothos
|
|
2
2
|
|
|
3
|
+
## 0.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#237](https://github.com/proto-graphql/proto-graphql-js/pull/237) [`b9945c8`](https://github.com/proto-graphql/proto-graphql-js/commit/b9945c827e737bda8b85621966a90a2e7e5cdf41) Thanks [@izumin5210](https://github.com/izumin5210)! - tweak input type definition for avoiding type error
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`b9945c8`](https://github.com/proto-graphql/proto-graphql-js/commit/b9945c827e737bda8b85621966a90a2e7e5cdf41)]:
|
|
10
|
+
- @proto-graphql/codegen-core@0.2.3
|
|
11
|
+
|
|
3
12
|
## 0.2.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -11,8 +11,7 @@ const util_1 = require("./util");
|
|
|
11
11
|
/**
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
14
|
-
* export const HelloInput = builder.inputRef
|
|
15
|
-
* HelloInput.implement({
|
|
14
|
+
* export const HelloInput$Ref: pothos.InputObjectRef<Hello$SHape> = builder.inputRef("HelloInput").implement({
|
|
16
15
|
* description: "...",
|
|
17
16
|
* fields: (t) => ({
|
|
18
17
|
* // ...
|
|
@@ -23,14 +22,17 @@ const util_1 = require("./util");
|
|
|
23
22
|
function createInputObjectTypeDslStmts(type) {
|
|
24
23
|
return [
|
|
25
24
|
createInputObjectTypeShapeDecl(type),
|
|
26
|
-
(0, util_1.createDslExportConstStmt)(type.pothosRefObjectName,
|
|
27
|
-
|
|
25
|
+
(0, util_1.createDslExportConstStmt)(type.pothosRefObjectName,
|
|
26
|
+
// builder.inputRef<Hello$Shale>("HelloInput").implement({ ... })
|
|
27
|
+
typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createPropertyAccessExpression(typescript_1.default.factory.createCallExpression((0, util_1.createBuilderPropExpr)("inputRef"), [typescript_1.default.factory.createTypeReferenceNode(createInputObjectTypeShapeIdent(type))], [typescript_1.default.factory.createStringLiteral(type.typeName)]), "implement"), undefined, [
|
|
28
28
|
typescript_1.default.factory.createObjectLiteralExpression([
|
|
29
29
|
(0, util_1.createDescriptionPropertyAssignment)(type),
|
|
30
30
|
typescript_1.default.factory.createPropertyAssignment("fields", createInputObjectTypeFieldsMethodExpr(type)),
|
|
31
31
|
typescript_1.default.factory.createPropertyAssignment("extensions", createExtensionsObjectLiteralExpr(type)),
|
|
32
32
|
].filter((0, util_1.onlyNonNull)()), true),
|
|
33
|
-
])
|
|
33
|
+
]),
|
|
34
|
+
// $$pothos$core.InputObjectRef<Hello$Shape>
|
|
35
|
+
typescript_1.default.factory.createTypeReferenceNode(typescript_1.default.factory.createQualifiedName(typescript_1.default.factory.createIdentifier((0, codegen_core_1.uniqueImportAlias)("@pothos/core")), "InputObjectRef"), [typescript_1.default.factory.createTypeReferenceNode(createInputObjectTypeShapeIdent(type))])),
|
|
34
36
|
];
|
|
35
37
|
}
|
|
36
38
|
exports.createInputObjectTypeDslStmts = createInputObjectTypeDslStmts;
|
|
@@ -50,7 +52,7 @@ function createInputObjectTypeFieldsMethodExpr(type) {
|
|
|
50
52
|
/**
|
|
51
53
|
* @example
|
|
52
54
|
* ```ts
|
|
53
|
-
* {
|
|
55
|
+
* export type Hello$Shape = {
|
|
54
56
|
* message?: _$hello$hello_pb$Hello["message"] | null,
|
|
55
57
|
* // ...
|
|
56
58
|
* }
|
|
@@ -75,8 +75,8 @@ function createImportDecl({ alias, module, type, }) {
|
|
|
75
75
|
: undefined), typescript_1.default.factory.createStringLiteral(module));
|
|
76
76
|
}
|
|
77
77
|
exports.createImportDecl = createImportDecl;
|
|
78
|
-
function createDslExportConstStmt(name, exp) {
|
|
79
|
-
return typescript_1.default.factory.createVariableStatement([typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.ExportKeyword)], typescript_1.default.factory.createVariableDeclarationList([typescript_1.default.factory.createVariableDeclaration(name, undefined,
|
|
78
|
+
function createDslExportConstStmt(name, exp, typeNode) {
|
|
79
|
+
return typescript_1.default.factory.createVariableStatement([typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.ExportKeyword)], typescript_1.default.factory.createVariableDeclarationList([typescript_1.default.factory.createVariableDeclaration(name, undefined, typeNode, exp)], typescript_1.default.NodeFlags.Const));
|
|
80
80
|
}
|
|
81
81
|
exports.createDslExportConstStmt = createDslExportConstStmt;
|
|
82
82
|
function onlyNonNull() {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { InputObjectType } from "@proto-graphql/codegen-core";
|
|
1
|
+
import { InputObjectType, uniqueImportAlias } from "@proto-graphql/codegen-core";
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import { createFieldDefinitionExpr, createNoopFieldDefinitionExpr } from "./field";
|
|
4
4
|
import { createBuilderPropExpr, createDescriptionPropertyAssignment, createDslExportConstStmt, createQualifiedName, onlyNonNull, } from "./util";
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
|
-
* export const HelloInput = builder.inputRef
|
|
9
|
-
* HelloInput.implement({
|
|
8
|
+
* export const HelloInput$Ref: pothos.InputObjectRef<Hello$SHape> = builder.inputRef("HelloInput").implement({
|
|
10
9
|
* description: "...",
|
|
11
10
|
* fields: (t) => ({
|
|
12
11
|
* // ...
|
|
@@ -17,14 +16,17 @@ import { createBuilderPropExpr, createDescriptionPropertyAssignment, createDslEx
|
|
|
17
16
|
export function createInputObjectTypeDslStmts(type) {
|
|
18
17
|
return [
|
|
19
18
|
createInputObjectTypeShapeDecl(type),
|
|
20
|
-
createDslExportConstStmt(type.pothosRefObjectName,
|
|
21
|
-
|
|
19
|
+
createDslExportConstStmt(type.pothosRefObjectName,
|
|
20
|
+
// builder.inputRef<Hello$Shale>("HelloInput").implement({ ... })
|
|
21
|
+
ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createCallExpression(createBuilderPropExpr("inputRef"), [ts.factory.createTypeReferenceNode(createInputObjectTypeShapeIdent(type))], [ts.factory.createStringLiteral(type.typeName)]), "implement"), undefined, [
|
|
22
22
|
ts.factory.createObjectLiteralExpression([
|
|
23
23
|
createDescriptionPropertyAssignment(type),
|
|
24
24
|
ts.factory.createPropertyAssignment("fields", createInputObjectTypeFieldsMethodExpr(type)),
|
|
25
25
|
ts.factory.createPropertyAssignment("extensions", createExtensionsObjectLiteralExpr(type)),
|
|
26
26
|
].filter(onlyNonNull()), true),
|
|
27
|
-
])
|
|
27
|
+
]),
|
|
28
|
+
// $$pothos$core.InputObjectRef<Hello$Shape>
|
|
29
|
+
ts.factory.createTypeReferenceNode(ts.factory.createQualifiedName(ts.factory.createIdentifier(uniqueImportAlias("@pothos/core")), "InputObjectRef"), [ts.factory.createTypeReferenceNode(createInputObjectTypeShapeIdent(type))])),
|
|
28
30
|
];
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
@@ -43,7 +45,7 @@ function createInputObjectTypeFieldsMethodExpr(type) {
|
|
|
43
45
|
/**
|
|
44
46
|
* @example
|
|
45
47
|
* ```ts
|
|
46
|
-
* {
|
|
48
|
+
* export type Hello$Shape = {
|
|
47
49
|
* message?: _$hello$hello_pb$Hello["message"] | null,
|
|
48
50
|
* // ...
|
|
49
51
|
* }
|
|
@@ -61,8 +61,8 @@ export function createImportDecl({ alias, module, type, }) {
|
|
|
61
61
|
])
|
|
62
62
|
: undefined), ts.factory.createStringLiteral(module));
|
|
63
63
|
}
|
|
64
|
-
export function createDslExportConstStmt(name, exp) {
|
|
65
|
-
return ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, undefined,
|
|
64
|
+
export function createDslExportConstStmt(name, exp, typeNode) {
|
|
65
|
+
return ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, undefined, typeNode, exp)], ts.NodeFlags.Const));
|
|
66
66
|
}
|
|
67
67
|
export function onlyNonNull() {
|
|
68
68
|
return (t) => t != null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "protoc-gen-pothos",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
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.2.
|
|
26
|
+
"@proto-graphql/codegen-core": "^0.2.3",
|
|
27
27
|
"@proto-graphql/proto-descriptors": "^0.2.0",
|
|
28
28
|
"@proto-graphql/protoc-plugin-helpers": "^0.2.1",
|
|
29
29
|
"google-protobuf": "^3.20.1"
|