Skip to content

Commit

Permalink
updateCrudOneToMany
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbrui committed Aug 30, 2023
1 parent 1bcb616 commit eabcff1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/integrations/gei-crud/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gei-crud",
"version": "0.8.5",
"version": "0.8.6",
"description": "GraphQL Editor integration for stucco. Allows basic crud operations and relations.",
"main": "lib/index.js",
"private": false,
Expand Down
4 changes: 3 additions & 1 deletion packages/integrations/gei-crud/src/Object/oneToMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export const handler = async (input: FieldResolveInput) => {
const fieldWithArray = prepareField[1] ? prepareField[1] : undefined;

if (fieldWithArray) {
if (typeof s[fieldWithArray][0] !== 'string') return s[fieldWithArray];
// Return an empty array if the fieldWithArray is either not an array or an empty array.
if (!Array.isArray(s[fieldWithArray]) || s[fieldWithArray].length === 0) {
return [];
}
if (typeof s[fieldWithArray][0] !== 'string') {
return s[fieldWithArray].filter((s: any) => s !== null);
}
}

return db
Expand Down

0 comments on commit eabcff1

Please sign in to comment.