Merge branch '142993479-tags' of github.com:coralproject/talk into 142993479-tags

This commit is contained in:
Wyatt Johnson
2017-06-08 11:21:55 -06:00
4 changed files with 32 additions and 21 deletions
+15 -19
View File
@@ -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',
)
};
+15
View File
@@ -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;
}
@@ -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 {
@@ -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 {