Netflix / falcor-router

A Falcor JavaScript DataSource which creates a Virtual JSON Graph document on your app server.
http://netflix.github.io/falcor
Apache License 2.0
104 stars 46 forks source link

How to handle creating multiple resources, but one of them has a validation error. #211

Open eddieajau opened 7 years ago

eddieajau commented 7 years ago

Let's say I've set up a route to add articles.

model.call(
  ['articles', 'add'],                  // callPath
  [{ title: 'good' }, { title: 'bad' }] // arguments
).then(...)

The arguments are an array of articles to add. Normally I'd return a value like this to the router.

[
  {
    "path": [
      "articlesById",
      1,
      "id"
    ],
    "value": 1
  },
 {
    "path": [
      "articlesById",
      2,
      "id"
    ],
    "value": 2
  }
]

However, let's say an article with title of bad fails a validation check. What kind of path should I return to the router to show that the second article (which obviously can't have an id) has a validation error?

Or, do I need to restrict Falcor to only add one article at a time, then I can quite happily throw an Error?

Thanks in advance.