Commit 805589b4 authored by Enrique Alcantara's avatar Enrique Alcantara

Code review feedback

Enclose mutation parameters in an input
data type
parent a47e21ab
mutation submitContentChanges($project: ID!, $username: String!, $sourcePath: String!, $content: String!) {
submitContentChanges(project: $project, username: $username, sourcePath: $sourcePath, content: $content) @client {
mutation submitContentChanges($input: SubmitContentChangesInput) {
submitContentChanges(input: $input) @client {
branch
commit
mergeRequest
......
......@@ -2,8 +2,8 @@ import submitContentChanges from '../../services/submit_content_changes';
import savedContentMetaQuery from '../queries/saved_content_meta.query.graphql';
const submitContentChangesResolver = (
_root,
{ project: projectId, username, sourcePath, content },
_,
{ input: { project: projectId, username, sourcePath, content } },
{ cache },
) => {
return submitContentChanges({ projectId, username, sourcePath, content }).then(
......
......@@ -14,10 +14,6 @@ type SavedContentMeta {
branch: SavedContentField!
}
extend type Project {
file(path: ID!): File
}
type AppData {
isSupportedContent: Boolean!
project: String!
......@@ -26,11 +22,22 @@ type AppData {
username: String!
}
type SubmitContentChangesInput {
project: String!
sourcePath: String!
content: String!
username: String!
}
extend type Project {
file(path: ID!): File
}
extend type Query {
appData: AppData!
savedContentMeta: SavedContentMeta
}
extend type Mutation {
submitContentChanges(project: String!, sourcePath: String!, content: String!, username: String!): SavedContentMeta
submitContentChanges(input: SubmitContentChangesInput!): SavedContentMeta
}
......@@ -74,10 +74,12 @@ export default {
.mutate({
mutation: submitContentChangesMutation,
variables: {
project: this.appData.project,
username: this.appData.username,
sourcePath: this.appData.sourcePath,
content: this.content,
input: {
project: this.appData.project,
username: this.appData.username,
sourcePath: this.appData.sourcePath,
content: this.content,
},
},
})
.then(() => {
......
......@@ -20,7 +20,7 @@ describe('static_site_editor/graphql/resolvers/submit_content_changes', () => {
return submitContentChangesResolver(
{},
{ path: sourcePath, project, sourcePath, content, username },
{ input: { path: sourcePath, project, sourcePath, content, username } },
{ cache },
).then(() => {
expect(cache.writeQuery).toHaveBeenCalledWith({
......
......@@ -194,10 +194,12 @@ describe('static_site_editor/pages/home', () => {
expect(mutateMock).toHaveBeenCalledWith({
mutation: submitContentChangesMutation,
variables: {
content: newContent,
project,
sourcePath,
username,
input: {
content: newContent,
project,
sourcePath,
username,
},
},
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment