Skip to content

Commit b594dc8

Browse files
committed
Remove _openAPIToGraphQL from arbitrary JSON in []
Signed-off-by: Christopher <[email protected]>
1 parent 926ce20 commit b594dc8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/openapi-to-graphql/src/schema_builder.ts

+17
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,23 @@ const CleanGraphQLJSON = new GraphQLScalarType({
115115
cleanValue = { ...value }
116116

117117
delete cleanValue[OPENAPI_TO_GRAPHQL]
118+
} else if (
119+
/**
120+
* As an exception to the above case an object may be an array defined as an object
121+
* where the array members contain an arbitrary JSON and *do* have the
122+
* _openAPIToGraphQL field which must be removed
123+
*/
124+
value &&
125+
typeof value === 'object' &&
126+
value.length > 0 &&
127+
typeof value[0] == 'object' &&
128+
typeof value[0][OPENAPI_TO_GRAPHQL] === 'object'
129+
) {
130+
cleanValue = value.map((member) => {
131+
const cleanmember = { ...member }
132+
delete cleanmember[OPENAPI_TO_GRAPHQL]
133+
return cleanmember
134+
})
118135

119136
/**
120137
* As a GraphQLJSON type, the value can also be a scalar or array or

0 commit comments

Comments
 (0)