Skip to content

Commit

Permalink
fix(gatsby-transformer-sharp): explicitly register enum types (#19343)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst authored and m-allanson committed Nov 12, 2019
1 parent 8938c95 commit fdc7ccd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
11 changes: 10 additions & 1 deletion packages/gatsby-transformer-sharp/src/customize-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const {
ImageFormatType,
ImageCropFocusType,
DuotoneGradientType,
PotraceTurnPolicyType,
PotraceType,
ImageFitType,
} = require(`./types`)
Expand Down Expand Up @@ -567,6 +568,14 @@ module.exports = ({
})

if (createTypes) {
createTypes([imageSharpType])
createTypes([
ImageFormatType,
ImageFitType,
ImageCropFocusType,
DuotoneGradientType,
PotraceTurnPolicyType,
PotraceType,
imageSharpType,
])
}
}
25 changes: 14 additions & 11 deletions packages/gatsby-transformer-sharp/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,24 @@ const DuotoneGradientType = new GraphQLInputObjectType({
},
})

const PotraceTurnPolicyType = new GraphQLEnumType({
name: `PotraceTurnPolicy`,
values: {
TURNPOLICY_BLACK: { value: Potrace.TURNPOLICY_BLACK },
TURNPOLICY_WHITE: { value: Potrace.TURNPOLICY_WHITE },
TURNPOLICY_LEFT: { value: Potrace.TURNPOLICY_LEFT },
TURNPOLICY_RIGHT: { value: Potrace.TURNPOLICY_RIGHT },
TURNPOLICY_MINORITY: { value: Potrace.TURNPOLICY_MINORITY },
TURNPOLICY_MAJORITY: { value: Potrace.TURNPOLICY_MAJORITY },
},
})

const PotraceType = new GraphQLInputObjectType({
name: `Potrace`,
fields: () => {
return {
turnPolicy: {
type: new GraphQLEnumType({
name: `PotraceTurnPolicy`,
values: {
TURNPOLICY_BLACK: { value: Potrace.TURNPOLICY_BLACK },
TURNPOLICY_WHITE: { value: Potrace.TURNPOLICY_WHITE },
TURNPOLICY_LEFT: { value: Potrace.TURNPOLICY_LEFT },
TURNPOLICY_RIGHT: { value: Potrace.TURNPOLICY_RIGHT },
TURNPOLICY_MINORITY: { value: Potrace.TURNPOLICY_MINORITY },
TURNPOLICY_MAJORITY: { value: Potrace.TURNPOLICY_MAJORITY },
},
}),
type: PotraceTurnPolicyType,
},
turdSize: { type: GraphQLFloat },
alphaMax: { type: GraphQLFloat },
Expand All @@ -91,5 +93,6 @@ module.exports = {
ImageFitType,
ImageCropFocusType,
DuotoneGradientType,
PotraceTurnPolicyType,
PotraceType,
}

0 comments on commit fdc7ccd

Please sign in to comment.