[go: nahoru, domu]

Skip to content

Commit

Permalink
fix non-null type support in generated mutations (#7147)
Browse files Browse the repository at this point in the history
* fix non-null type support in generated mutations

* remove console log
  • Loading branch information
hlshen committed May 9, 2024
1 parent de9cbde commit d30d96c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions firebase-vscode/src/data-connect/ad-hoc-mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,14 @@ query {
mutation.push(`${functionSpacing}${name}_insert(data: {`); // insert function
for (const field of ast.fields) {
// necessary to avoid type error
const fieldType: any = field.type;
let fieldTypeName: string = fieldType.type.name.value;
let fieldType: any = field.type;
// We unwrap NonNullType to obtain the actual type
if (fieldType.kind === Kind.NON_NULL_TYPE) {
fieldType = fieldType.type;
}
let fieldTypeName: string = fieldType.name.value;
let fieldName: string = field.name.value;
let defaultValue = defaultScalarValues[fieldTypeName] as string;

if (!isDataConnectScalarType(fieldTypeName)) {
fieldTypeName += "Id";
fieldName += "Id";
Expand Down

0 comments on commit d30d96c

Please sign in to comment.