graphql-jerky 1.0.2 → 1.0.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/build/lib.cjs CHANGED
@@ -39,23 +39,26 @@ async function findExports(source, resolveModuleFn = resolveModule) {
39
39
  if (ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)) {
40
40
  if (node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) {
41
41
  if (node.modifiers.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword)) {
42
- exports.default = { declaration: node, source, name: "default" };
42
+ (exports.default || (exports.default = [])).push({ declaration: node, source, name: "default" });
43
43
  }
44
44
  else if (node.name) {
45
- exports[node.name.getText(source)] = { declaration: node, source, name: node.name.getText(source) };
45
+ const name = node.name.getText(source);
46
+ (exports[name] || (exports[name] = [])).push({ declaration: node, source, name: name });
46
47
  }
47
48
  }
48
49
  }
49
50
  else if (ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node) || ts.isModuleDeclaration(node)) {
50
51
  if (node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) {
51
- exports[node.name.getText(source)] = { declaration: node, source, name: node.name.getText(source) };
52
+ const name = node.name.getText(source);
53
+ (exports[name] || (exports[name] = [])).push({ declaration: node, source, name: name });
52
54
  }
53
55
  }
54
56
  else if (ts.isVariableStatement(node)) {
55
57
  if (node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) {
56
58
  for (const decl of node.declarationList.declarations) {
57
59
  if (decl.name) {
58
- exports[decl.name.getText(source)] = { declaration: decl, source, name: decl.name.getText(source) };
60
+ const name = decl.name.getText(source);
61
+ (exports[name] || (exports[name] = [])).push({ declaration: decl, source, name: name });
59
62
  }
60
63
  }
61
64
  }
@@ -73,7 +76,7 @@ async function findExports(source, resolveModuleFn = resolveModule) {
73
76
  if (!(name in moduleExports)) {
74
77
  throw new Error(`Exported name ${name} not found in ${JSON.stringify(specifier)}`);
75
78
  }
76
- exports[name] = moduleExports[name];
79
+ (exports[name] || (exports[name] = [])).push(...moduleExports[name]);
77
80
  }
78
81
  }
79
82
  else {
@@ -82,7 +85,6 @@ async function findExports(source, resolveModuleFn = resolveModule) {
82
85
  name: element.name.text,
83
86
  property: element.propertyName?.text,
84
87
  });
85
- // exports[element.name.getText(source)] = { declaration: element, source };
86
88
  }
87
89
  }
88
90
  }
@@ -98,57 +100,63 @@ async function findExports(source, resolveModuleFn = resolveModule) {
98
100
  if (ts.isVariableStatement(statement)) {
99
101
  for (const decl of statement.declarationList.declarations) {
100
102
  if (ts.isIdentifier(decl.name) && decl.name.getText(source) in names) {
101
- exports[names[decl.name.getText(source)]] = {
103
+ const name = names[decl.name.getText(source)];
104
+ (exports[name] || (exports[name] = [])).push({
102
105
  declaration: decl,
103
106
  source,
104
107
  name: names[decl.name.getText(source)],
105
- };
108
+ });
106
109
  }
107
110
  }
108
111
  }
109
112
  if (ts.isFunctionDeclaration(statement)) {
110
113
  if (statement.name && ts.isIdentifier(statement.name) && statement.name.getText(source) in names) {
111
- exports[names[statement.name.getText(source)]] = {
114
+ const name = names[statement.name.getText(source)];
115
+ (exports[name] || (exports[name] = [])).push({
112
116
  declaration: statement,
113
117
  source,
114
118
  name: names[statement.name.getText(source)],
115
- };
119
+ });
116
120
  }
117
121
  }
118
122
  if (ts.isClassDeclaration(statement)) {
119
123
  if (statement.name && ts.isIdentifier(statement.name) && statement.name.getText(source) in names) {
120
- exports[names[statement.name.getText(source)]] = {
124
+ const name = names[statement.name.getText(source)];
125
+ (exports[name] || (exports[name] = [])).push({
121
126
  declaration: statement,
122
127
  source,
123
128
  name: names[statement.name.getText(source)],
124
- };
129
+ });
125
130
  }
126
131
  }
127
132
  if (ts.isTypeAliasDeclaration(statement)) {
128
133
  if (statement.name && ts.isIdentifier(statement.name) && statement.name.getText(source) in names) {
129
- exports[names[statement.name.getText(source)]] = {
134
+ const name = names[statement.name.getText(source)];
135
+ (exports[name] || (exports[name] = [])).push({
130
136
  declaration: statement,
131
137
  source,
132
138
  name: names[statement.name.getText(source)],
133
- };
139
+ });
134
140
  }
135
141
  }
136
142
  if (ts.isInterfaceDeclaration(statement)) {
137
143
  if (statement.name && ts.isIdentifier(statement.name) && statement.name.getText(source) in names) {
138
- exports[names[statement.name.getText(source)]] = {
144
+ const name = names[statement.name.getText(source)];
145
+ (exports[name] || (exports[name] = [])).push({
139
146
  declaration: statement,
140
147
  source,
141
148
  name: names[statement.name.getText(source)],
142
- };
149
+ });
143
150
  }
144
151
  }
145
152
  if (ts.isEnumDeclaration(statement)) {
146
153
  if (statement.name && ts.isIdentifier(statement.name) && statement.name.getText(source) in names) {
147
- exports[names[statement.name.getText(source)]] = {
154
+ const name = names[statement.name.getText(source)];
155
+ (exports[name] || (exports[name] = [])).push({
148
156
  declaration: statement,
149
157
  source,
150
158
  name: names[statement.name.getText(source)],
151
- };
159
+ });
152
160
  }
153
161
  }
154
162
  if (ts.isImportDeclaration(statement)) {
@@ -168,11 +176,12 @@ async function findExports(source, resolveModuleFn = resolveModule) {
168
176
  if (!importExports[element.name.getText(source)]) {
169
177
  throw new Error(`Exported name ${element.name.getText(source)} not found in ${JSON.stringify(statement.moduleSpecifier.getText(source))}`);
170
178
  }
171
- exports[names[element.propertyName.getText(source)]] = {
179
+ const name = names[element.propertyName.getText(source)];
180
+ (exports[name] || (exports[name] = [])).push({
172
181
  declaration: element,
173
182
  source,
174
183
  name: names[element.propertyName.getText(source)],
175
- };
184
+ });
176
185
  }
177
186
  }
178
187
  }
@@ -239,16 +248,9 @@ function compareEntryKey([a], [b]) {
239
248
  function compareName({ name: a }, { name: b }) {
240
249
  return a.localeCompare(b);
241
250
  }
251
+ const PRIMITIVE_TYPES = new Set(["ID", "Int", "Float", "String", "Boolean"]);
242
252
  function isPrimitiveType(type) {
243
- switch (type.name) {
244
- case "ID":
245
- case "Int":
246
- case "Float":
247
- case "String":
248
- case "Boolean":
249
- return true;
250
- }
251
- return false;
253
+ return PRIMITIVE_TYPES.has(type.name);
252
254
  }
253
255
  function importAlias(line) {
254
256
  const pos = line.indexOf(" as ");
@@ -742,6 +744,20 @@ class GeneratorContext {
742
744
  .map((directive) => [directive.name, this._renderGraphQLDirectiveDefinition(directive)])
743
745
  .sort(compareEntryKey),
744
746
  ].map(([, expr]) => expr),
747
+ ...Array.from(PRIMITIVE_TYPES)
748
+ .flatMap((type) => {
749
+ const info = this._scalarsInfo[type];
750
+ if (!info) {
751
+ return [];
752
+ }
753
+ return [
754
+ jen.statements(...[
755
+ info.serializeFunc && this._gql("GraphQL" + type).dot("serialize").op("=").parens(renderSymbolReference(this._pkgs, info.serializeFunc).as.any),
756
+ info.parseValueFunc && this._gql("GraphQL" + type).dot("parseValue").op("=").parens(renderSymbolReference(this._pkgs, info.parseValueFunc).as.any),
757
+ info.parseLiteralFunc && this._gql("GraphQL" + type).dot("parseLiteral").op("=").parens(renderSymbolReference(this._pkgs, info.parseLiteralFunc).as.any),
758
+ ].filter(Boolean))
759
+ ];
760
+ }),
745
761
  // render schema
746
762
  jen.const.id("schema").op("=").new.add(this._gql("GraphQLSchema")).call(jen.obj(...(schema.getQueryType()
747
763
  ? [jen.prop("query", this._renderGraphQLTypeIdentifier(schema.getQueryType()))]
@@ -918,7 +934,7 @@ function createMatcher(pattern) {
918
934
 
919
935
  async function parseResolverFile(path) {
920
936
  return Object.fromEntries(Object.entries((await parseModule(path)).exports)
921
- .flatMap(([name, { declaration }]) => {
937
+ .flatMap(([name, decls]) => decls.flatMap(({ declaration }) => {
922
938
  if (ts.isVariableDeclaration(declaration) && declaration.initializer) {
923
939
  if (ts.isFunctionExpression(declaration.initializer)) {
924
940
  return [[name, { module: path, symbol: name }]];
@@ -931,7 +947,7 @@ async function parseResolverFile(path) {
931
947
  return [[name, { module: path, symbol: name }]];
932
948
  }
933
949
  return [];
934
- }));
950
+ })));
935
951
  }
936
952
  async function parseTypeResolvers(typeName, glob$1, ignore) {
937
953
  const shouldIgnore = createMatcher(ignore);
@@ -1006,6 +1022,12 @@ function refFromTypeReferenceNode(typeNode, source) {
1006
1022
  return;
1007
1023
  }
1008
1024
  const typeName = typeNode.typeName.text;
1025
+ if (typeNode.typeArguments?.length) {
1026
+ if (typeName !== 'Promise') {
1027
+ throw new Error('TODO: handle type arguments');
1028
+ }
1029
+ return refFromTypeNode(typeNode.typeArguments[0], source);
1030
+ }
1009
1031
  for (const statement of source.statements) {
1010
1032
  if (ts.isImportDeclaration(statement)) {
1011
1033
  // search imports
@@ -1145,21 +1167,23 @@ async function parse$1(path) {
1145
1167
  const scalarFnsInfos = {};
1146
1168
  const scalarTypeNodes = {};
1147
1169
  const sources = {};
1148
- for (const [name, { declaration, source }] of Object.entries((await parseModule(path)).exports)) {
1149
- sources[name] = source;
1150
- if (ts.isVariableDeclaration(declaration)) {
1151
- if (declaration.initializer && ts.isObjectLiteralExpression(declaration.initializer)) {
1152
- scalarFnsInfos[name] = scalarInfoFromObjectLiteralExpression(name, new URL(source.fileName).toString(), declaration.initializer.properties);
1153
- }
1154
- }
1155
- else if (ts.isTypeAliasDeclaration(declaration)) {
1156
- if (declaration.typeParameters?.length) {
1157
- console.log(`WARNING: skipping scalar type ${name}: type parameters are not supported`);
1158
- continue;
1170
+ for (const [name, decls] of Object.entries((await parseModule(path)).exports)) {
1171
+ for (const { declaration, source } of decls) {
1172
+ sources[name] = source;
1173
+ if (ts.isVariableDeclaration(declaration)) {
1174
+ if (declaration.initializer && ts.isObjectLiteralExpression(declaration.initializer)) {
1175
+ scalarFnsInfos[name] = scalarInfoFromObjectLiteralExpression(name, new URL(source.fileName).toString(), declaration.initializer.properties);
1176
+ }
1159
1177
  }
1160
- const ref = refFromTypeNode(declaration.type, source);
1161
- if (ref) {
1162
- scalarTypeNodes[name] = declaration.type;
1178
+ else if (ts.isTypeAliasDeclaration(declaration)) {
1179
+ if (declaration.typeParameters?.length) {
1180
+ console.log(`WARNING: skipping scalar type ${name}: type parameters are not supported`);
1181
+ continue;
1182
+ }
1183
+ const ref = refFromTypeNode(declaration.type, source);
1184
+ if (ref) {
1185
+ scalarTypeNodes[name] = declaration.type;
1186
+ }
1163
1187
  }
1164
1188
  }
1165
1189
  }
@@ -1172,7 +1196,7 @@ async function parse$1(path) {
1172
1196
  module: source.fileName,
1173
1197
  symbol: name,
1174
1198
  } : reconcileScalarType(name, [
1175
- fnsInfo?.serializeFunc?.declaration?.parameters?.[0]?.type,
1199
+ // NOTE: omit serialize input type because it is supposed to be `unknown`
1176
1200
  fnsInfo?.parseValueFunc?.declaration?.type,
1177
1201
  fnsInfo?.parseLiteralFunc?.declaration?.type,
1178
1202
  ], source);
package/build/lib.mjs CHANGED
@@ -37,23 +37,26 @@ async function findExports(source, resolveModuleFn = resolveModule) {
37
37
  if (ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)) {
38
38
  if (node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) {
39
39
  if (node.modifiers.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword)) {
40
- exports.default = { declaration: node, source, name: "default" };
40
+ (exports.default || (exports.default = [])).push({ declaration: node, source, name: "default" });
41
41
  }
42
42
  else if (node.name) {
43
- exports[node.name.getText(source)] = { declaration: node, source, name: node.name.getText(source) };
43
+ const name = node.name.getText(source);
44
+ (exports[name] || (exports[name] = [])).push({ declaration: node, source, name: name });
44
45
  }
45
46
  }
46
47
  }
47
48
  else if (ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node) || ts.isModuleDeclaration(node)) {
48
49
  if (node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) {
49
- exports[node.name.getText(source)] = { declaration: node, source, name: node.name.getText(source) };
50
+ const name = node.name.getText(source);
51
+ (exports[name] || (exports[name] = [])).push({ declaration: node, source, name: name });
50
52
  }
51
53
  }
52
54
  else if (ts.isVariableStatement(node)) {
53
55
  if (node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) {
54
56
  for (const decl of node.declarationList.declarations) {
55
57
  if (decl.name) {
56
- exports[decl.name.getText(source)] = { declaration: decl, source, name: decl.name.getText(source) };
58
+ const name = decl.name.getText(source);
59
+ (exports[name] || (exports[name] = [])).push({ declaration: decl, source, name: name });
57
60
  }
58
61
  }
59
62
  }
@@ -71,7 +74,7 @@ async function findExports(source, resolveModuleFn = resolveModule) {
71
74
  if (!(name in moduleExports)) {
72
75
  throw new Error(`Exported name ${name} not found in ${JSON.stringify(specifier)}`);
73
76
  }
74
- exports[name] = moduleExports[name];
77
+ (exports[name] || (exports[name] = [])).push(...moduleExports[name]);
75
78
  }
76
79
  }
77
80
  else {
@@ -80,7 +83,6 @@ async function findExports(source, resolveModuleFn = resolveModule) {
80
83
  name: element.name.text,
81
84
  property: element.propertyName?.text,
82
85
  });
83
- // exports[element.name.getText(source)] = { declaration: element, source };
84
86
  }
85
87
  }
86
88
  }
@@ -96,57 +98,63 @@ async function findExports(source, resolveModuleFn = resolveModule) {
96
98
  if (ts.isVariableStatement(statement)) {
97
99
  for (const decl of statement.declarationList.declarations) {
98
100
  if (ts.isIdentifier(decl.name) && decl.name.getText(source) in names) {
99
- exports[names[decl.name.getText(source)]] = {
101
+ const name = names[decl.name.getText(source)];
102
+ (exports[name] || (exports[name] = [])).push({
100
103
  declaration: decl,
101
104
  source,
102
105
  name: names[decl.name.getText(source)],
103
- };
106
+ });
104
107
  }
105
108
  }
106
109
  }
107
110
  if (ts.isFunctionDeclaration(statement)) {
108
111
  if (statement.name && ts.isIdentifier(statement.name) && statement.name.getText(source) in names) {
109
- exports[names[statement.name.getText(source)]] = {
112
+ const name = names[statement.name.getText(source)];
113
+ (exports[name] || (exports[name] = [])).push({
110
114
  declaration: statement,
111
115
  source,
112
116
  name: names[statement.name.getText(source)],
113
- };
117
+ });
114
118
  }
115
119
  }
116
120
  if (ts.isClassDeclaration(statement)) {
117
121
  if (statement.name && ts.isIdentifier(statement.name) && statement.name.getText(source) in names) {
118
- exports[names[statement.name.getText(source)]] = {
122
+ const name = names[statement.name.getText(source)];
123
+ (exports[name] || (exports[name] = [])).push({
119
124
  declaration: statement,
120
125
  source,
121
126
  name: names[statement.name.getText(source)],
122
- };
127
+ });
123
128
  }
124
129
  }
125
130
  if (ts.isTypeAliasDeclaration(statement)) {
126
131
  if (statement.name && ts.isIdentifier(statement.name) && statement.name.getText(source) in names) {
127
- exports[names[statement.name.getText(source)]] = {
132
+ const name = names[statement.name.getText(source)];
133
+ (exports[name] || (exports[name] = [])).push({
128
134
  declaration: statement,
129
135
  source,
130
136
  name: names[statement.name.getText(source)],
131
- };
137
+ });
132
138
  }
133
139
  }
134
140
  if (ts.isInterfaceDeclaration(statement)) {
135
141
  if (statement.name && ts.isIdentifier(statement.name) && statement.name.getText(source) in names) {
136
- exports[names[statement.name.getText(source)]] = {
142
+ const name = names[statement.name.getText(source)];
143
+ (exports[name] || (exports[name] = [])).push({
137
144
  declaration: statement,
138
145
  source,
139
146
  name: names[statement.name.getText(source)],
140
- };
147
+ });
141
148
  }
142
149
  }
143
150
  if (ts.isEnumDeclaration(statement)) {
144
151
  if (statement.name && ts.isIdentifier(statement.name) && statement.name.getText(source) in names) {
145
- exports[names[statement.name.getText(source)]] = {
152
+ const name = names[statement.name.getText(source)];
153
+ (exports[name] || (exports[name] = [])).push({
146
154
  declaration: statement,
147
155
  source,
148
156
  name: names[statement.name.getText(source)],
149
- };
157
+ });
150
158
  }
151
159
  }
152
160
  if (ts.isImportDeclaration(statement)) {
@@ -166,11 +174,12 @@ async function findExports(source, resolveModuleFn = resolveModule) {
166
174
  if (!importExports[element.name.getText(source)]) {
167
175
  throw new Error(`Exported name ${element.name.getText(source)} not found in ${JSON.stringify(statement.moduleSpecifier.getText(source))}`);
168
176
  }
169
- exports[names[element.propertyName.getText(source)]] = {
177
+ const name = names[element.propertyName.getText(source)];
178
+ (exports[name] || (exports[name] = [])).push({
170
179
  declaration: element,
171
180
  source,
172
181
  name: names[element.propertyName.getText(source)],
173
- };
182
+ });
174
183
  }
175
184
  }
176
185
  }
@@ -237,16 +246,9 @@ function compareEntryKey([a], [b]) {
237
246
  function compareName({ name: a }, { name: b }) {
238
247
  return a.localeCompare(b);
239
248
  }
249
+ const PRIMITIVE_TYPES = new Set(["ID", "Int", "Float", "String", "Boolean"]);
240
250
  function isPrimitiveType(type) {
241
- switch (type.name) {
242
- case "ID":
243
- case "Int":
244
- case "Float":
245
- case "String":
246
- case "Boolean":
247
- return true;
248
- }
249
- return false;
251
+ return PRIMITIVE_TYPES.has(type.name);
250
252
  }
251
253
  function importAlias(line) {
252
254
  const pos = line.indexOf(" as ");
@@ -740,6 +742,20 @@ class GeneratorContext {
740
742
  .map((directive) => [directive.name, this._renderGraphQLDirectiveDefinition(directive)])
741
743
  .sort(compareEntryKey),
742
744
  ].map(([, expr]) => expr),
745
+ ...Array.from(PRIMITIVE_TYPES)
746
+ .flatMap((type) => {
747
+ const info = this._scalarsInfo[type];
748
+ if (!info) {
749
+ return [];
750
+ }
751
+ return [
752
+ jen$1.statements(...[
753
+ info.serializeFunc && this._gql("GraphQL" + type).dot("serialize").op("=").parens(renderSymbolReference(this._pkgs, info.serializeFunc).as.any),
754
+ info.parseValueFunc && this._gql("GraphQL" + type).dot("parseValue").op("=").parens(renderSymbolReference(this._pkgs, info.parseValueFunc).as.any),
755
+ info.parseLiteralFunc && this._gql("GraphQL" + type).dot("parseLiteral").op("=").parens(renderSymbolReference(this._pkgs, info.parseLiteralFunc).as.any),
756
+ ].filter(Boolean))
757
+ ];
758
+ }),
743
759
  // render schema
744
760
  jen$1.const.id("schema").op("=").new.add(this._gql("GraphQLSchema")).call(jen$1.obj(...(schema.getQueryType()
745
761
  ? [jen$1.prop("query", this._renderGraphQLTypeIdentifier(schema.getQueryType()))]
@@ -916,7 +932,7 @@ function createMatcher(pattern) {
916
932
 
917
933
  async function parseResolverFile(path) {
918
934
  return Object.fromEntries(Object.entries((await parseModule(path)).exports)
919
- .flatMap(([name, { declaration }]) => {
935
+ .flatMap(([name, decls]) => decls.flatMap(({ declaration }) => {
920
936
  if (ts.isVariableDeclaration(declaration) && declaration.initializer) {
921
937
  if (ts.isFunctionExpression(declaration.initializer)) {
922
938
  return [[name, { module: path, symbol: name }]];
@@ -929,7 +945,7 @@ async function parseResolverFile(path) {
929
945
  return [[name, { module: path, symbol: name }]];
930
946
  }
931
947
  return [];
932
- }));
948
+ })));
933
949
  }
934
950
  async function parseTypeResolvers(typeName, glob, ignore) {
935
951
  const shouldIgnore = createMatcher(ignore);
@@ -1004,6 +1020,12 @@ function refFromTypeReferenceNode(typeNode, source) {
1004
1020
  return;
1005
1021
  }
1006
1022
  const typeName = typeNode.typeName.text;
1023
+ if (typeNode.typeArguments?.length) {
1024
+ if (typeName !== 'Promise') {
1025
+ throw new Error('TODO: handle type arguments');
1026
+ }
1027
+ return refFromTypeNode(typeNode.typeArguments[0], source);
1028
+ }
1007
1029
  for (const statement of source.statements) {
1008
1030
  if (ts.isImportDeclaration(statement)) {
1009
1031
  // search imports
@@ -1143,21 +1165,23 @@ async function parse$1(path) {
1143
1165
  const scalarFnsInfos = {};
1144
1166
  const scalarTypeNodes = {};
1145
1167
  const sources = {};
1146
- for (const [name, { declaration, source }] of Object.entries((await parseModule(path)).exports)) {
1147
- sources[name] = source;
1148
- if (ts.isVariableDeclaration(declaration)) {
1149
- if (declaration.initializer && ts.isObjectLiteralExpression(declaration.initializer)) {
1150
- scalarFnsInfos[name] = scalarInfoFromObjectLiteralExpression(name, new URL(source.fileName).toString(), declaration.initializer.properties);
1151
- }
1152
- }
1153
- else if (ts.isTypeAliasDeclaration(declaration)) {
1154
- if (declaration.typeParameters?.length) {
1155
- console.log(`WARNING: skipping scalar type ${name}: type parameters are not supported`);
1156
- continue;
1168
+ for (const [name, decls] of Object.entries((await parseModule(path)).exports)) {
1169
+ for (const { declaration, source } of decls) {
1170
+ sources[name] = source;
1171
+ if (ts.isVariableDeclaration(declaration)) {
1172
+ if (declaration.initializer && ts.isObjectLiteralExpression(declaration.initializer)) {
1173
+ scalarFnsInfos[name] = scalarInfoFromObjectLiteralExpression(name, new URL(source.fileName).toString(), declaration.initializer.properties);
1174
+ }
1157
1175
  }
1158
- const ref = refFromTypeNode(declaration.type, source);
1159
- if (ref) {
1160
- scalarTypeNodes[name] = declaration.type;
1176
+ else if (ts.isTypeAliasDeclaration(declaration)) {
1177
+ if (declaration.typeParameters?.length) {
1178
+ console.log(`WARNING: skipping scalar type ${name}: type parameters are not supported`);
1179
+ continue;
1180
+ }
1181
+ const ref = refFromTypeNode(declaration.type, source);
1182
+ if (ref) {
1183
+ scalarTypeNodes[name] = declaration.type;
1184
+ }
1161
1185
  }
1162
1186
  }
1163
1187
  }
@@ -1170,7 +1194,7 @@ async function parse$1(path) {
1170
1194
  module: source.fileName,
1171
1195
  symbol: name,
1172
1196
  } : reconcileScalarType(name, [
1173
- fnsInfo?.serializeFunc?.declaration?.parameters?.[0]?.type,
1197
+ // NOTE: omit serialize input type because it is supposed to be `unknown`
1174
1198
  fnsInfo?.parseValueFunc?.declaration?.type,
1175
1199
  fnsInfo?.parseLiteralFunc?.declaration?.type,
1176
1200
  ], source);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-jerky",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Jerky is a schema-first static graphql schema lightweight code generator.",
5
5
  "type": "module",
6
6
  "bin": "./build/bin/jerky.cjs",