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!) { mutation submitContentChanges($input: SubmitContentChangesInput) {
submitContentChanges(project: $project, username: $username, sourcePath: $sourcePath, content: $content) @client { submitContentChanges(input: $input) @client {
branch branch
commit commit
mergeRequest mergeRequest
......
...@@ -2,8 +2,8 @@ import submitContentChanges from '../../services/submit_content_changes'; ...@@ -2,8 +2,8 @@ import submitContentChanges from '../../services/submit_content_changes';
import savedContentMetaQuery from '../queries/saved_content_meta.query.graphql'; import savedContentMetaQuery from '../queries/saved_content_meta.query.graphql';
const submitContentChangesResolver = ( const submitContentChangesResolver = (
_root, _,
{ project: projectId, username, sourcePath, content }, { input: { project: projectId, username, sourcePath, content } },
{ cache }, { cache },
) => { ) => {
return submitContentChanges({ projectId, username, sourcePath, content }).then( return submitContentChanges({ projectId, username, sourcePath, content }).then(
......
...@@ -14,10 +14,6 @@ type SavedContentMeta { ...@@ -14,10 +14,6 @@ type SavedContentMeta {
branch: SavedContentField! branch: SavedContentField!
} }
extend type Project {
file(path: ID!): File
}
type AppData { type AppData {
isSupportedContent: Boolean! isSupportedContent: Boolean!
project: String! project: String!
...@@ -26,11 +22,22 @@ type AppData { ...@@ -26,11 +22,22 @@ type AppData {
username: String! username: String!
} }
type SubmitContentChangesInput {
project: String!
sourcePath: String!
content: String!
username: String!
}
extend type Project {
file(path: ID!): File
}
extend type Query { extend type Query {
appData: AppData! appData: AppData!
savedContentMeta: SavedContentMeta savedContentMeta: SavedContentMeta
} }
extend type Mutation { extend type Mutation {
submitContentChanges(project: String!, sourcePath: String!, content: String!, username: String!): SavedContentMeta submitContentChanges(input: SubmitContentChangesInput!): SavedContentMeta
} }
...@@ -74,10 +74,12 @@ export default { ...@@ -74,10 +74,12 @@ export default {
.mutate({ .mutate({
mutation: submitContentChangesMutation, mutation: submitContentChangesMutation,
variables: { variables: {
project: this.appData.project, input: {
username: this.appData.username, project: this.appData.project,
sourcePath: this.appData.sourcePath, username: this.appData.username,
content: this.content, sourcePath: this.appData.sourcePath,
content: this.content,
},
}, },
}) })
.then(() => { .then(() => {
......
...@@ -20,7 +20,7 @@ describe('static_site_editor/graphql/resolvers/submit_content_changes', () => { ...@@ -20,7 +20,7 @@ describe('static_site_editor/graphql/resolvers/submit_content_changes', () => {
return submitContentChangesResolver( return submitContentChangesResolver(
{}, {},
{ path: sourcePath, project, sourcePath, content, username }, { input: { path: sourcePath, project, sourcePath, content, username } },
{ cache }, { cache },
).then(() => { ).then(() => {
expect(cache.writeQuery).toHaveBeenCalledWith({ expect(cache.writeQuery).toHaveBeenCalledWith({
......
...@@ -194,10 +194,12 @@ describe('static_site_editor/pages/home', () => { ...@@ -194,10 +194,12 @@ describe('static_site_editor/pages/home', () => {
expect(mutateMock).toHaveBeenCalledWith({ expect(mutateMock).toHaveBeenCalledWith({
mutation: submitContentChangesMutation, mutation: submitContentChangesMutation,
variables: { variables: {
content: newContent, input: {
project, content: newContent,
sourcePath, project,
username, 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