From 1377455cda0f178d345696f4f09ae2e26c064908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Thu, 7 Mar 2019 18:31:54 +0100 Subject: [PATCH] Disable/enable should return the Resource --- src/resolvers/moderation.spec.js | 20 ++++++++++---------- src/schema.graphql | 9 +++++++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/resolvers/moderation.spec.js b/src/resolvers/moderation.spec.js index c1d4a75fe..005996ec7 100644 --- a/src/resolvers/moderation.spec.js +++ b/src/resolvers/moderation.spec.js @@ -37,7 +37,7 @@ afterEach(async () => { describe('disable', () => { const mutation = ` mutation($id: ID!, $type: ResourceEnum!) { - disable(resource: { id: $id, type: $type }) + disable(resource: { id: $id, type: $type }) { id type } } ` let variables @@ -103,8 +103,8 @@ describe('disable', () => { } }) - it('returns true', async () => { - const expected = { disable: true } + it('returns disabled Resource', async () => { + const expected = { disable: { id: 'c47', type: 'comment' } } await runSetup() await expect(action()).resolves.toEqual(expected) }) @@ -154,8 +154,8 @@ describe('disable', () => { } }) - it('returns true', async () => { - const expected = { disable: true } + it('returns disabled Resource', async () => { + const expected = { disable: { id: 'p9', type: 'contribution' } } await runSetup() await expect(action()).resolves.toEqual(expected) }) @@ -195,7 +195,7 @@ describe('disable', () => { describe('enable', () => { const mutation = ` mutation($id: ID!, $type: ResourceEnum!) { - enable(resource: { id: $id, type: $type }) + enable(resource: { id: $id, type: $type }) { id type } } ` let variables @@ -270,8 +270,8 @@ describe('enable', () => { } }) - it('returns true', async () => { - const expected = { enable: true } + it('returns disabled Resource', async () => { + const expected = { enable: { id: 'c456', type: 'comment' } } await runSetup() await expect(action()).resolves.toEqual(expected) }) @@ -331,8 +331,8 @@ describe('enable', () => { } }) - it('returns true', async () => { - const expected = { enable: true } + it('returns disabled Resource', async () => { + const expected = { enable: { id: 'p9', type: 'contribution' } } await runSetup() await expect(action()).resolves.toEqual(expected) }) diff --git a/src/schema.graphql b/src/schema.graphql index 5e58d5f1d..e284b6c52 100644 --- a/src/schema.graphql +++ b/src/schema.graphql @@ -7,8 +7,8 @@ type Mutation { login(email: String!, password: String!): String! signup(email: String!, password: String!): Boolean! report(resource: Resource!, description: String): Report - disable(resource: Resource!): Boolean! - enable(resource: Resource!): Boolean! + disable(resource: Resource!): ResourcePayload! + enable(resource: Resource!): ResourcePayload! } type Statistics { @@ -32,6 +32,11 @@ input Resource { type: ResourceEnum! } +type ResourcePayload { + id: ID!, + type: ResourceEnum! +} + enum ResourceEnum { contribution comment