fix: format graphql localization input type (#932)
* fix: format locales for graphql * fix: locale missing from graphql mutation args
This commit is contained in:
@@ -177,6 +177,9 @@ function initCollectionsGraphQL(payload: Payload): void {
|
||||
args: {
|
||||
data: { type: collection.graphQL.mutationInputType },
|
||||
draft: { type: GraphQLBoolean },
|
||||
...(payload.config.localization ? {
|
||||
locale: { type: payload.types.localeInputType },
|
||||
} : {}),
|
||||
},
|
||||
resolve: createResolver(collection),
|
||||
};
|
||||
@@ -188,6 +191,9 @@ function initCollectionsGraphQL(payload: Payload): void {
|
||||
data: { type: collection.graphQL.updateMutationInputType },
|
||||
draft: { type: GraphQLBoolean },
|
||||
autosave: { type: GraphQLBoolean },
|
||||
...(payload.config.localization ? {
|
||||
locale: { type: payload.types.localeInputType },
|
||||
} : {}),
|
||||
},
|
||||
resolve: updateResolver(collection),
|
||||
};
|
||||
|
||||
@@ -62,6 +62,9 @@ function initGlobalsGraphQL(payload: Payload): void {
|
||||
args: {
|
||||
data: { type: global.graphQL.mutationInputType },
|
||||
draft: { type: GraphQLBoolean },
|
||||
...(payload.config.localization ? {
|
||||
locale: { type: payload.types.localeInputType },
|
||||
} : {}),
|
||||
},
|
||||
resolve: updateResolver(global),
|
||||
};
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { GraphQLEnumType } from 'graphql';
|
||||
import { LocalizationConfig } from '../../config/types';
|
||||
import formatName from '../utilities/formatName';
|
||||
|
||||
const buildFallbackLocaleInputType = (localization: LocalizationConfig): GraphQLEnumType => new GraphQLEnumType({
|
||||
name: 'FallbackLocaleInputType',
|
||||
values: [...localization.locales, 'none'].reduce((values, locale) => ({
|
||||
...values,
|
||||
[locale]: {
|
||||
[formatName(locale)]: {
|
||||
value: locale,
|
||||
},
|
||||
}), {}),
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import { GraphQLEnumType } from 'graphql';
|
||||
import { GraphQLEnumType, GraphQLScalarType } from 'graphql';
|
||||
import { LocalizationConfig } from '../../config/types';
|
||||
import formatName from '../utilities/formatName';
|
||||
|
||||
const buildLocaleInputType = (localization: LocalizationConfig): GraphQLEnumType => new GraphQLEnumType({
|
||||
name: 'LocaleInputType',
|
||||
values: localization.locales.reduce((values, locale) => ({
|
||||
...values,
|
||||
[locale]: {
|
||||
value: locale,
|
||||
},
|
||||
}), {}),
|
||||
});
|
||||
const buildLocaleInputType = (localization: LocalizationConfig): GraphQLEnumType | GraphQLScalarType => {
|
||||
return new GraphQLEnumType({
|
||||
name: 'LocaleInputType',
|
||||
values: localization.locales.reduce((values, locale) => ({
|
||||
...values,
|
||||
[formatName(locale)]: {
|
||||
value: locale,
|
||||
},
|
||||
}), {}),
|
||||
});
|
||||
};
|
||||
|
||||
export default buildLocaleInputType;
|
||||
|
||||
Reference in New Issue
Block a user