Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-transformer-sharp): explicitly register enum types #19343

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just my nitpick - should it not be like other Types capitalized?

Suggested change
imageSharpType,
ImageSharpType,

also should changed in this line:

-  const imageSharpType = schema.buildObjectType({
+  const ImageSharpType = schema.buildObjectType({

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not strictly part of this PR, so IMO - let's merge this PR and we can do style commit (if anyone feel very strongly about it) separately?

])
}
}
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,
}