diff --git a/client/coral-framework/graphql/fragments.js b/client/coral-framework/graphql/fragments.js index 9c396cbaa..3c64090bd 100644 --- a/client/coral-framework/graphql/fragments.js +++ b/client/coral-framework/graphql/fragments.js @@ -1,23 +1,19 @@ -import {gql} from 'react-apollo'; -import * as mutations from './mutations'; - -function createDefaultResponseFragments() { - const names = Object.keys(mutations).map((key) => key.replace('with', '')); - const result = {}; - names.forEach((name) => { - const response = `${name}Response`; - result[response] = gql` - fragment Coral_${response} on ${response} { - errors { - translation_key - } - } - `; - }); - return result; -} +import {createDefaultResponseFragments} from '../utils'; // fragments defined here are automatically registered. export default { - ...createDefaultResponseFragments() + ...createDefaultResponseFragments( + 'SetCommentStatusResponse', + 'SuspendUserResponse', + 'RejectUsernameResponse', + 'SetUserStatusResponse', + 'PostCommentResponse', + 'EditCommentResponse', + 'PostFlagResponse', + 'CreateDontAgreeResponse', + 'DeleteActionResponse', + 'ModifyTagResponse', + 'IgnoreUserResponse', + 'StopIgnoringUserResponse', + ) }; diff --git a/client/coral-framework/utils/index.js b/client/coral-framework/utils/index.js index ca2dd5ab2..1d430f1fc 100644 --- a/client/coral-framework/utils/index.js +++ b/client/coral-framework/utils/index.js @@ -112,3 +112,18 @@ export function getResponseErrors(mutationResult) { }); return result.length ? result : false; } + +export function createDefaultResponseFragments(...names) { + const result = {}; + names.forEach((name) => { + const response = `${name}Response`; + result[response] = gql` + fragment Coral_${response} on ${response} { + errors { + translation_key + } + } + `; + }); + return result; +} diff --git a/plugins/coral-plugin-like/server/typeDefs.graphql b/plugins/coral-plugin-like/server/typeDefs.graphql index 1a1100754..40c600f2f 100644 --- a/plugins/coral-plugin-like/server/typeDefs.graphql +++ b/plugins/coral-plugin-like/server/typeDefs.graphql @@ -60,7 +60,7 @@ type CreateLikeResponse implements Response { like: LikeAction # An array of errors relating to the mutation that occurred. - errors: [UserError] + errors: [UserError!] } type RootMutation { diff --git a/plugins/coral-plugin-love/server/typeDefs.graphql b/plugins/coral-plugin-love/server/typeDefs.graphql index e22b91a2d..edc45e20b 100644 --- a/plugins/coral-plugin-love/server/typeDefs.graphql +++ b/plugins/coral-plugin-love/server/typeDefs.graphql @@ -60,7 +60,7 @@ type CreateLoveResponse implements Response { love: LoveAction # An array of errors relating to the mutation that occurred. - errors: [UserError] + errors: [UserError!] } type RootMutation {