Skip to content

Commit fccc74c

Browse files
committed
fix: types are plain objects
1 parent 58ba99e commit fccc74c

File tree

1 file changed

+13
-33
lines changed
  • packages/gatsby-source-wordpress/src/steps/create-schema-customization/transform-fields

1 file changed

+13
-33
lines changed

packages/gatsby-source-wordpress/src/steps/create-schema-customization/transform-fields/index.js

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ import {
1111
} from "../helpers"
1212

1313
import { buildDefaultResolver } from "./default-resolver"
14-
import {
15-
GraphQLScalarType,
16-
GraphQLList,
17-
GraphQLNonNull,
18-
isListType,
19-
isNonNullType,
20-
} from "graphql"
2114

2215
/**
2316
* @param {import("graphql").GraphQLField} field
@@ -32,41 +25,28 @@ const handleCustomScalars = field => {
3225
// type it as JSON
3326
return {
3427
...field,
35-
type: new GraphQLScalarType({
28+
type: {
29+
...field.type,
3630
name: `JSON`,
37-
}),
31+
},
3832
}
3933
}
4034

4135
const fieldTypeOfTypeIsACustomScalar =
42-
field.type.ofType &&
43-
field.type.ofType.kind === `SCALAR` &&
44-
!typeIsASupportedScalar(field.type)
36+
field.type.ofType?.kind === `SCALAR` && !typeIsASupportedScalar(field.type)
4537

4638
if (fieldTypeOfTypeIsACustomScalar) {
4739
// if this field is an unsupported custom scalar,
4840
// type it as JSON
49-
50-
if (isListType(field.type)) {
51-
return {
52-
...field,
53-
type: new GraphQLList(
54-
new GraphQLScalarType({
55-
name: `JSON`,
56-
})
57-
),
58-
}
59-
}
60-
61-
if (isNonNullType(field.type)) {
62-
return {
63-
...field,
64-
type: new GraphQLNonNull(
65-
new GraphQLScalarType({
66-
name: `JSON`,
67-
})
68-
),
69-
}
41+
return {
42+
...field,
43+
type: {
44+
...field.type,
45+
ofType: {
46+
...field.type.ofType,
47+
name: `JSON`,
48+
},
49+
},
7050
}
7151
}
7252

0 commit comments

Comments
 (0)