File tree Expand file tree Collapse file tree 1 file changed +13
-33
lines changed
packages/gatsby-source-wordpress/src/steps/create-schema-customization/transform-fields Expand file tree Collapse file tree 1 file changed +13
-33
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,6 @@ import {
11
11
} from "../helpers"
12
12
13
13
import { buildDefaultResolver } from "./default-resolver"
14
- import {
15
- GraphQLScalarType ,
16
- GraphQLList ,
17
- GraphQLNonNull ,
18
- isListType ,
19
- isNonNullType ,
20
- } from "graphql"
21
14
22
15
/**
23
16
* @param {import("graphql").GraphQLField } field
@@ -32,41 +25,28 @@ const handleCustomScalars = field => {
32
25
// type it as JSON
33
26
return {
34
27
...field ,
35
- type : new GraphQLScalarType ( {
28
+ type : {
29
+ ...field . type ,
36
30
name : `JSON` ,
37
- } ) ,
31
+ } ,
38
32
}
39
33
}
40
34
41
35
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 )
45
37
46
38
if ( fieldTypeOfTypeIsACustomScalar ) {
47
39
// if this field is an unsupported custom scalar,
48
40
// 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
+ } ,
70
50
}
71
51
}
72
52
You can’t perform that action at this time.
0 commit comments