Skip to content

Commit

Permalink
More consistent naming
Browse files Browse the repository at this point in the history
  • Loading branch information
freiksenet committed Apr 24, 2019
1 parent 9ca160e commit 17d7857
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/gatsby/src/schema/__tests__/kitchen-sink.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ describe(`Kitchen sink schema test`, () => {
payload: `
type PostsJson implements Node @infer {
id: String!
time: Date @addResolver(type: "date", options: { defaultLocale: "fi", defaultFormat: "DD MMMM"})
time: Date @addResolver(type: "dateformat", options: { locale: "fi", formatString: "DD MMMM"})
code: String
image: File @addResolver(type: "relativeFile")
image: File @addResolver(type: "fileByRelativePath")
}
`,
})
Expand Down
14 changes: 7 additions & 7 deletions packages/gatsby/src/schema/add-field-resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const addFieldResolvers = ({
) {
const options = extensions.addResolver.options || {}
switch (extensions.addResolver.type) {
case `date`: {
case `dateformat`: {
addDateResolver({
typeComposer,
fieldName,
Expand All @@ -33,7 +33,7 @@ export const addFieldResolvers = ({
})
break
}
case `relativeFile`: {
case `fileByRelativePath`: {
typeComposer.extendField(fieldName, {
resolve: fileByPath({ from: options.from }),
})
Expand Down Expand Up @@ -61,7 +61,7 @@ export const addFieldResolvers = ({
const addDateResolver = ({
typeComposer,
fieldName,
options: { defaultFormat, defaultLocale },
options: { formatString, locale },
}) => {
const field = typeComposer.getField(fieldName)

Expand All @@ -72,11 +72,11 @@ const addDateResolver = ({
fieldConfig.args = {
...dateResolver.args,
}
if (defaultFormat) {
fieldConfig.args.formatString.defaultValue = defaultFormat
if (formatString) {
fieldConfig.args.formatString.defaultValue = formatString
}
if (defaultLocale) {
fieldConfig.args.locale.defaultValue = defaultLocale
if (locale) {
fieldConfig.args.locale.defaultValue = locale
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/schema/infer/__tests__/merge-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ describe(`merges explicit and inferred type definitions`, () => {
it(`adds explicit resolvers through directives`, async () => {
const typeDefs = `
type Test implements Node @infer {
explicitDate: Date @addResolver(type: "date")
explicitDate: Date @addResolver(type: "dateformat")
}
type LinkTest implements Node @infer {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/schema/infer/add-inferred-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ const getFieldConfigFromFieldNameConvention = ({
}
}

const DATE_EXTENSION = { addResolver: { type: `date` } }
const FILE_EXTENSION = { addResolver: { type: `relativeFile` } }
const DATE_EXTENSION = { addResolver: { type: `dateformat` } }
const FILE_EXTENSION = { addResolver: { type: `fileByRelativePath` } }

const getSimpleFieldConfig = ({
schemaComposer,
Expand Down

0 comments on commit 17d7857

Please sign in to comment.