ReferenceInput with @ra-data-prisma/dataprovider 6.3.2 not working
Closed this issue ยท 3 comments
winner106 commented
my dependencies
"dependencies": {
"@apollo/client": "^3.4.7",
"@ra-data-prisma/dataprovider": "^6.3.2",
"graphql": "^15.5.1",
"react": "^17.0.2",
"react-admin": "^3.17.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3"}
when i make a file called orderCreate.js, part of code is :
<Create {...props}>
<SimpleForm>
<ReferenceInput label="Product" source="productId" reference="Product">
<SelectInput optionText="name" />
</ReferenceInput>
<ReferenceInput source="customerId" reference="Customer" filterToQuery={(searchText) => ({ email: searchText })}>
<AutocompleteInput optionText="email" />
</ReferenceInput>
<NumberInput source="permitUsers" label="permitUsers" initialValue={3} />
<DateInput source="orderDate" label="orderDate" initialValue={new Date()}/>
</SimpleForm>
</Create>
i checked the browser , the request body content is:
{"operationName":"createOneOrder",
"variables":{"data":{"orderDate":"2021-08-20T00:00:00.000Z","permitUsers":3}},
"query":"mutation createOneOrder($data: OrderCreateInput!) {\n
data: createOneOrder(data: $data) {\n id\n customerId\n productId\n orderDate\n permitUsers\n product {\n id\n __typename\n }\n customer {\n id\n __typename\n }\n __typename\n }\n}\n"}
all the other input components are fine, but ReferenceInput variables lost !
and the request failed!
only seperated backend api service is fine
"dependencies": {
"@prisma/client": "^2.29.0",
"@ra-data-prisma/backend": "^7.0.0",
"apollo-server": "^3.1.2",
"apollo-server-core": "^3.1.2",
"bcryptjs": "^2.4.3",
"graphql": "^15.5.1",
"graphql-middleware": "^6.0.10",
"graphql-scalars": "^1.10.0",
"graphql-shield": "^7.5.0",
"jsonwebtoken": "^8.5.1",
"nexus": "^1.1.0",
"nexus-plugin-prisma": "^0.35.0"
}
in the playground test graphql mutation ( success ):
macrozone commented
it should be product
instead of productId
and customer
instead of customerId
<ReferenceInput label="Product" source="product" reference="Product">
<SelectInput optionText="name" />
</ReferenceInput>
<ReferenceInput source="customer" reference="Customer">
<AutocompleteInput optionText="email" />
</ReferenceInput>
```
winner106 commented
Thanks !
It works ! wtf !
macrozone commented
@winner106 nice!
by the way there is an example of this in the docs: https://github.com/panter/ra-data-prisma/blob/master/packages/dataprovider/README.md#relations