Weakky / ra-data-opencrud

A react-admin data provider for Prisma and GraphCMS
MIT License
159 stars 45 forks source link

The auto generated id_in leads to invalid query #21

Open xcv58 opened 6 years ago

xcv58 commented 6 years ago

https://github.com/Weakky/ra-data-opencrud/blob/929e19342f0878fa7ab68852162f48c58a318f1a/src/buildVariables.js#L31-L36

The filter like { id_in: ['id_1', 'id_2'] } will lead to query variables like:

{
   "where": {
    "id_in": { "id_in": ["id_1", "id_2"] }
  }
}

Which is not a valid query anymore.

Weakky commented 6 years ago

Hey there,

Could you please provide the components you're using to end up into this bug?

Thanks 🙏

xcv58 commented 6 years ago

Sure, the component is react-admin List: https://marmelab.com/react-admin/List.html#permanent-filter

The query like this:

{
  posts (where: { title_in: ["Hello World", "My Second Post"] }) {
    id
    title
  }
}

will turn to:

{ title_in: { id_in: ["Hello World", "My Second Post"] } }

The link for the query: https://graphqlbin.com/v2/YvW2uN

xcv58 commented 6 years ago

@Weakky I reproduce the bug here: https://github.com/xcv58/ra-data-opencrud-issue-21