americanexpress / parrot

✨ Scenario-based HTTP mocking
Apache License 2.0
139 stars 30 forks source link

Add Partial Success (Data & Error) to graphql response #210

Open PageTMcEneaney opened 1 year ago

PageTMcEneaney commented 1 year ago

Similar to https://github.com/americanexpress/parrot/issues/100 we'd like to add an enhancement to Parrot responses.

At the moment, there is no option to add both data and error objects outside of the body. We'd like to add to support partial success graphql responses. See example. I want to make sure this is compatible with the parrot-friendly formatting of the scenarios so I think we should update the scenarios file to use or add a second example app

{
  "data": {
    "getInt": 12,
    "getString": null
  },
  "errors": [
    {
      "message": "Failed to get string!"
      // ...additional fields...
    }
  ]
}

Here is my WIP forked repo & branch

Note: to test this locally I needed to link parrot-friendly to the local version with “parrot-friendly”: “file:../../packages/parrot-friendly”,, if the parrot-friendly changes need to be approved & merged first I can remove the friendly-pirate-app changes and include those in a separate followup PR

github-actions[bot] commented 1 year ago

Thanks for opening your first issue. Pull requests are always welcome!

PageTMcEneaney commented 1 year ago

The main changes are in packages/parrot-friendly/src/Mock.js & the test file. The other changes are adding a second example app friendly-pirate-app which is optional but seemed cleaner than overwriting the original scenario syntax