Skip to content

Commit

Permalink
fix: Arrays returned as objects (#12676)
Browse files Browse the repository at this point in the history
  • Loading branch information
stocaaro authored Dec 6, 2023
1 parent 1e96034 commit 8d9b94c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/api-graphql/__tests__/fixtures/modeled/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const schema = a.schema({
description: a.string(),
notes: a.hasMany('Note'),
meta: a.hasOne('TodoMetadata'),
tags: a.string().array(),
})
.authorization([a.allow.public('apiKey'), a.allow.owner()]),
Note: a
Expand Down
2 changes: 2 additions & 0 deletions packages/api-graphql/__tests__/generateClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ describe('generateClient', () => {
...serverManagedFields,
name: 'some name',
description: 'something something',
tags: ['one', 'two', 'three']
},
},
});
Expand All @@ -288,6 +289,7 @@ describe('generateClient', () => {
owner: 'wirejobviously',
name: 'some name',
description: 'something something',
tags: ['one', 'two', 'three']
})
);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/api-graphql/src/internals/APIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const flattenItems = (obj: Record<string, any>): Record<string, any> => {
const res: Record<string, any> = {};

Object.entries(obj).forEach(([prop, value]) => {
if (typeof value === 'object' && value !== null) {
if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
if (value.items !== undefined) {
res[prop] = value.items.map((item: Record<string, any>) =>
flattenItems(item)
Expand Down

0 comments on commit 8d9b94c

Please sign in to comment.