@aws-amplify/data-schema 1.3.6 → 1.3.7
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/dist/cjs/SchemaProcessor.js +2 -2
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/custom.js +15 -2
- package/dist/cjs/runtime/internals/operations/custom.js.map +1 -1
- package/dist/esm/ClientSchema/Core/ClientCustomOperations.d.ts +2 -1
- package/dist/esm/SchemaProcessor.mjs +2 -2
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/custom.mjs +15 -2
- package/dist/esm/runtime/internals/operations/custom.mjs.map +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/ClientSchema/Core/ClientCustomOperations.ts +4 -1
- package/src/SchemaProcessor.ts +2 -2
- package/src/runtime/internals/operations/custom.ts +17 -2
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import type { AppSyncResolverHandler } from 'aws-lambda';
|
|
|
6
6
|
import type { CustomType } from '../../CustomType';
|
|
7
7
|
import type { FieldTypesOfCustomType } from '../../MappedTypes/ResolveSchema';
|
|
8
8
|
import type { ResolveRef } from '../utilities/ResolveRef';
|
|
9
|
+
import type { EnumType } from '../../EnumType';
|
|
9
10
|
import { ClientSchemaProperty } from './ClientSchemaProperty';
|
|
10
11
|
|
|
11
12
|
type CustomOperationSubType<Op extends CustomOperationParamShape> =
|
|
@@ -83,7 +84,9 @@ type CustomOpArguments<Shape extends CustomOperationParamShape> =
|
|
|
83
84
|
infer R
|
|
84
85
|
>
|
|
85
86
|
? R
|
|
86
|
-
:
|
|
87
|
+
: Shape['arguments'][FieldName] extends EnumType<infer Values>
|
|
88
|
+
? Values[number] | null
|
|
89
|
+
: never;
|
|
87
90
|
}>;
|
|
88
91
|
|
|
89
92
|
/**
|
package/src/SchemaProcessor.ts
CHANGED
|
@@ -398,14 +398,14 @@ function customOperationToGql(
|
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
if (Object.keys(fieldArgs).length > 0) {
|
|
401
|
-
const { gqlFields, implicitTypes } = processFields(
|
|
401
|
+
const { gqlFields, implicitTypes: implied } = processFields(
|
|
402
402
|
typeName,
|
|
403
403
|
fieldArgs,
|
|
404
404
|
{},
|
|
405
405
|
{},
|
|
406
406
|
);
|
|
407
407
|
callSignature += `(${gqlFields.join(', ')})`;
|
|
408
|
-
implicitTypes.push(...
|
|
408
|
+
implicitTypes.push(...implied);
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
const handler = handlers && handlers[0];
|
|
@@ -191,6 +191,21 @@ function hasStringField<Field extends string>(
|
|
|
191
191
|
return typeof o[field] === 'string';
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
/**
|
|
195
|
+
* @param argDef A single argument definition from a custom operation
|
|
196
|
+
* @returns A string naming the base type including the `!` if the arg is required.
|
|
197
|
+
*/
|
|
198
|
+
function argumentBaseTypeString(
|
|
199
|
+
argDef: Exclude<CustomOperation['arguments'], undefined>[number],
|
|
200
|
+
) {
|
|
201
|
+
const requiredFlag = argDef.isRequired ? '!' : '';
|
|
202
|
+
if (argDef.type instanceof Object && 'enum' in argDef.type) {
|
|
203
|
+
return argDef.type.enum + requiredFlag;
|
|
204
|
+
} else {
|
|
205
|
+
return argDef.type + requiredFlag;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
194
209
|
/**
|
|
195
210
|
* Generates "outer" arguments string for a custom operation. For example,
|
|
196
211
|
* in this operation:
|
|
@@ -216,7 +231,7 @@ function outerArguments(operation: CustomOperation): string {
|
|
|
216
231
|
}
|
|
217
232
|
const args = Object.entries(operation.arguments)
|
|
218
233
|
.map(([k, v]) => {
|
|
219
|
-
const baseType =
|
|
234
|
+
const baseType = argumentBaseTypeString(v);
|
|
220
235
|
const finalType = v.isArray
|
|
221
236
|
? `[${baseType}]${v.isArrayNullable ? '' : '!'}`
|
|
222
237
|
: baseType;
|
|
@@ -261,7 +276,7 @@ function innerArguments(operation: CustomOperation): string {
|
|
|
261
276
|
/**
|
|
262
277
|
* Generates the selection set string for a custom operation. This is slightly
|
|
263
278
|
* different than the selection set generation for models. If the custom op returns
|
|
264
|
-
* a primitive or enum types, it
|
|
279
|
+
* a primitive or enum types, it doesn't require a selection set at all.
|
|
265
280
|
*
|
|
266
281
|
* E.g., the graphql might look like this:
|
|
267
282
|
*
|