|
| 1 | +Feature: GraphQL DTO input and output |
| 2 | + In order to use a hypermedia API |
| 3 | + As a client software developer |
| 4 | + I need to be able to use DTOs on my resources as Input or Output objects. |
| 5 | + |
| 6 | + @createSchema |
| 7 | + Scenario: Retrieve an Output with GraphQl |
| 8 | + When I add "Content-Type" header equal to "application/ld+json" |
| 9 | + And I send a "POST" request to "/dummy_dto_input_outputs" with body: |
| 10 | + """ |
| 11 | + { |
| 12 | + "foo": "test", |
| 13 | + "bar": 1 |
| 14 | + } |
| 15 | + """ |
| 16 | + Then the response status code should be 201 |
| 17 | + And the JSON should be equal to: |
| 18 | + """ |
| 19 | + { |
| 20 | + "@context": { |
| 21 | + "@vocab": "http://example.com/docs.jsonld#", |
| 22 | + "hydra": "http://www.w3.org/ns/hydra/core#", |
| 23 | + "id": "OutputDto/id", |
| 24 | + "baz": "OutputDto/baz", |
| 25 | + "bat": "OutputDto/bat" |
| 26 | + }, |
| 27 | + "@type": "DummyDtoInputOutput", |
| 28 | + "@id": "/dummy_dto_input_outputs/1", |
| 29 | + "id": 1, |
| 30 | + "baz": 1, |
| 31 | + "bat": "test" |
| 32 | + } |
| 33 | + """ |
| 34 | + When I send the following GraphQL request: |
| 35 | + """ |
| 36 | + { |
| 37 | + dummyDtoInputOutput(id: "/dummy_dto_input_outputs/1") { |
| 38 | + _id, id, baz |
| 39 | + } |
| 40 | + } |
| 41 | + """ |
| 42 | + Then the response status code should be 200 |
| 43 | + And the response should be in JSON |
| 44 | + And the header "Content-Type" should be equal to "application/json" |
| 45 | + And the JSON should be equal to: |
| 46 | + """ |
| 47 | + { |
| 48 | + "data": { |
| 49 | + "dummyDtoInputOutput": { |
| 50 | + "_id": 1, |
| 51 | + "id": "/dummy_dto_input_outputs/1", |
| 52 | + "baz": 1 |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + """ |
| 57 | + |
| 58 | + Scenario: Create an item using custom inputClass & disabled outputClass |
| 59 | + Given there are 2 dummyDtoNoOutput objects |
| 60 | + When I send the following GraphQL request: |
| 61 | + """ |
| 62 | + mutation { |
| 63 | + createDummyDtoNoOutput(input: {foo: "A new one", bar: 3, clientMutationId: "myId"}) { |
| 64 | + dummyDtoNoOutput { |
| 65 | + id |
| 66 | + } |
| 67 | + clientMutationId |
| 68 | + } |
| 69 | + } |
| 70 | + """ |
| 71 | + Then the response status code should be 200 |
| 72 | + And the response should be in JSON |
| 73 | + And the header "Content-Type" should be equal to "application/json" |
| 74 | + And the JSON should be equal to: |
| 75 | + """ |
| 76 | + { |
| 77 | + "errors": [ |
| 78 | + { |
| 79 | + "message": "Cannot query field \"id\" on type \"DummyDtoNoOutput\".", |
| 80 | + "extensions": { |
| 81 | + "category": "graphql" |
| 82 | + }, |
| 83 | + "locations": [ |
| 84 | + { |
| 85 | + "line": 4, |
| 86 | + "column": 7 |
| 87 | + } |
| 88 | + ] |
| 89 | + } |
| 90 | + ] |
| 91 | + } |
| 92 | + """ |
| 93 | + |
| 94 | + Scenario: Cannot create an item with input fields using disabled inputClass |
| 95 | + When I send the following GraphQL request: |
| 96 | + """ |
| 97 | + mutation { |
| 98 | + createDummyDtoNoInput(input: {lorem: "A new one", ipsum: 3, clientMutationId: "myId"}) { |
| 99 | + clientMutationId |
| 100 | + } |
| 101 | + } |
| 102 | + """ |
| 103 | + Then the response status code should be 200 |
| 104 | + And the response should be in JSON |
| 105 | + And the header "Content-Type" should be equal to "application/json" |
| 106 | + And the JSON should be equal to: |
| 107 | + """ |
| 108 | + { |
| 109 | + "errors": [ |
| 110 | + { |
| 111 | + "message": "Field \"lorem\" is not defined by type createDummyDtoNoInputInput.", |
| 112 | + "extensions": { |
| 113 | + "category": "graphql" |
| 114 | + }, |
| 115 | + "locations": [ |
| 116 | + { |
| 117 | + "line": 2, |
| 118 | + "column": 33 |
| 119 | + } |
| 120 | + ] |
| 121 | + }, |
| 122 | + { |
| 123 | + "message": "Field \"ipsum\" is not defined by type createDummyDtoNoInputInput.", |
| 124 | + "extensions": { |
| 125 | + "category": "graphql" |
| 126 | + }, |
| 127 | + "locations": [ |
| 128 | + { |
| 129 | + "line": 2, |
| 130 | + "column": 53 |
| 131 | + } |
| 132 | + ] |
| 133 | + } |
| 134 | + ] |
| 135 | + } |
| 136 | + """ |
| 137 | + |
| 138 | + Scenario: Create an item with empty input fields using disabled inputClass (no persist done) |
| 139 | + When I send the following GraphQL request: |
| 140 | + """ |
| 141 | + mutation { |
| 142 | + createDummyDtoNoInput(input: {clientMutationId: "myId"}) { |
| 143 | + dummyDtoNoInput { |
| 144 | + id |
| 145 | + } |
| 146 | + clientMutationId |
| 147 | + } |
| 148 | + } |
| 149 | + """ |
| 150 | + Then the response status code should be 200 |
| 151 | + And the response should be in JSON |
| 152 | + And the header "Content-Type" should be equal to "application/json" |
| 153 | + And the JSON should be equal to: |
| 154 | + """ |
| 155 | + { |
| 156 | + "data": { |
| 157 | + "createDummyDtoNoInput": { |
| 158 | + "dummyDtoNoInput": null, |
| 159 | + "clientMutationId": "myId" |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | + """ |
| 164 | + |
| 165 | + @!mongodb |
| 166 | + Scenario: Use messenger with graphql and an input where the handler gives a synchronous result |
| 167 | + When I send the following GraphQL request: |
| 168 | + """ |
| 169 | + mutation { |
| 170 | + createMessengerWithInput(input: {var: "test"}) { |
| 171 | + messengerWithInput { id, name } |
| 172 | + } |
| 173 | + } |
| 174 | + """ |
| 175 | + Then the response status code should be 200 |
| 176 | + And the response should be in JSON |
| 177 | + And the header "Content-Type" should be equal to "application/json" |
| 178 | + And the JSON should be equal to: |
| 179 | + """ |
| 180 | + { |
| 181 | + "data": { |
| 182 | + "createMessengerWithInput": { |
| 183 | + "messengerWithInput": { |
| 184 | + "id": "/messenger_with_inputs/1", |
| 185 | + "name": "test" |
| 186 | + } |
| 187 | + } |
| 188 | + } |
| 189 | + } |
| 190 | + """ |
0 commit comments