You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@ This changelog documents the changes between release versions.
7
7
## [Unreleased]
8
8
Changes to be included in the next upcoming release
9
9
10
+
- Improved error messages when unsupported enum types or unions of literal types are found, and allow these types to be used in relaxed types mode ([#17](https://github.com/hasura/ndc-nodejs-lambda/pull/17))
11
+
10
12
## [1.1.0] - 2024-02-26
11
13
- Updated to [NDC TypeScript SDK v4.2.0](https://github.com/hasura/ndc-sdk-typescript/releases/tag/v4.2.0) to include OpenTelemetry improvements. Traced spans should now appear in the Hasura Console
12
14
- Custom OpenTelemetry trace spans can now be emitted by creating an OpenTelemetry tracer and using it with `sdk.withActiveSpan` ([#16](https://github.com/hasura/ndc-nodejs-lambda/pull/16))
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -149,6 +149,7 @@ These types are unsupported as function parameter types or return types for func
149
149
*[Function types](https://www.typescriptlang.org/docs/handbook/2/functions.html#function-type-expressions) - function types can't be accepted as arguments or returned as values
150
150
*[`void`](https://www.typescriptlang.org/docs/handbook/2/functions.html#void), [`object`](https://www.typescriptlang.org/docs/handbook/2/functions.html#object), [`unknown`](https://www.typescriptlang.org/docs/handbook/2/functions.html#unknown), [`never`](https://www.typescriptlang.org/docs/handbook/2/functions.html#never), [`any`](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any) types - to accept and return arbitrary JSON, use `sdk.JSONValue` instead
151
151
*`null` and `undefined` - unless used in a union with a single other type
"Relaxed types" are types that are otherwise unsupported, but instead of being rejected are instead converted into opaque custom scalar types. These scalar types are entirely unvalidated when used as input (ie. the caller of the function can send arbitrary JSON values), making it incumbent on the function itself to ensure the incoming value for that relaxed type actually matches its type. Because relaxed types are represented as custom scalar types, in GraphQL you will be unable to select into the type, if it is an object, and will only be able to select the whole thing.
@@ -161,6 +162,7 @@ The following unsupported types are allowed when using relaxed types, and will b
161
162
* Tuple types
162
163
* Types with index signatures
163
164
* The `any` and `unknown` types
165
+
* Enum types
164
166
165
167
Here's an example of a function that uses some relaxed types:
??rejectIfClassType(tsType,typePath,context)// This needs to be done after scalars, because JSONValue is a class
286
287
??deriveSchemaTypeIfTsIndexSignatureType(tsType,typePath,allowRelaxedTypes,context,recursionDepth)// This needs to be done after scalars and classes, etc because some of those types do have index signatures (eg. strings)
@@ -444,6 +445,31 @@ function deriveSchemaTypeIfScalarType(tsType: ts.Type, context: TypeDerivationCo
returnderiveRelaxedTypeOrError(typeName,typePath,()=>`Enum types are not supported, but one was encountered in ${schema.typePathToString(typePath)} (type: ${typeName})`,allowRelaxedTypes,context);
returnderiveRelaxedTypeOrError(typeName,typePath,()=>`Literal union types are not supported, but one was encountered in ${schema.typePathToString(typePath)} (type: ${typeName})`,allowRelaxedTypes,context);
460
+
}
461
+
}
462
+
// Handles computed single member enum types: 'enum { OneThing = "test".length }'
returnderiveRelaxedTypeOrError(typeName,typePath,()=>`Enum types are not supported, but one was encountered in ${schema.typePathToString(typePath)} (type: ${typeName})`,allowRelaxedTypes,context);
466
+
}
467
+
468
+
// Note that single member enum types: 'enum { OneThing }' are simplified by the type system
469
+
// down to literal types (since they can only be a single thing) and are therefore supported via support
470
+
// for literal types in scalars
471
+
}
472
+
447
473
functionisDateType(tsType: ts.Type): boolean{
448
474
constsymbol=tsType.getSymbol()
449
475
if(symbol===undefined)returnfalse;
@@ -464,12 +490,9 @@ function isMapType(tsType: ts.Type): tsType is ts.TypeReference {
0 commit comments