score:0

i think i've encountered this issue, and i think i solved it as you suggest, by including the fields that needs to aliased up in the query:

graphql`
   fragment forminstancefields on forminstance {
      id
      form {
        id
        name
      }
      status
      createdat
      submittedat
   }
`
export default withdata<pages_dashboard_query>(indexpage, {
  query: graphql`
    query pages_dashboard_query {
      drafts: forminstances(status: draft) {
        ...forminstancefields
      }
      submitted: forminstances(status: submitted) {
        ...forminstancefields
      }
    }
  `,
})

(above fragment needs to be named correctly per compiler requirements)

then the thing to do is to not wrap forminstancelist in a fragment container, because as you point out, this leads to errors. the impulse to wrap it is strong, because using the hoc-based api, the instinct is to wrap all the way down through the render tree. but that won't work in this case.

instead, wrap each forminstance in a fragment container (which i'm guessing you're doing already already). then it will work. the drafts and submitted fields will contain arrays of relay store refs, and you can interate over them and pass each one to forminstancecontainer.

this may feel wrong, but if you think of it from the perspective of the upcoming hooks api, or relay-hooks, there's nothing really wrong it.


edit

haven't used relay in a while, but i think you could even keep the containers at all levels by doing something like this:

graphql`
  fragment forminstancelistcontainer_data on rootquery {
      drafts: forminstances(status: draft) {
        ...forminstancefields
      }
      submitted: forminstances(status: submitted) {
        ...forminstancefields
      }
  }
`

shouldn't that work, too?


Related Query

More Query from same tag