useform-metadata

But the error is coming from the UserWithRoles
23 Replies
Omer
Omer2y ago
If useForm's queryResult is returning results then the problem cannot be here
absent-sapphire
absent-sapphire2y ago
Correct
Omer
Omer2y ago
Can you check your network requests? There we can find the wrong request
absent-sapphire
absent-sapphire2y ago
This is the query that is being sent out: query ($id: ID!) { user (id: $id) } And this is the message in the response: Field "user" of type "UserWithRoles" must have a selection of subfields. Did you mean "user { ... }"?
Omer
Omer2y ago
Does the error go away when you remove the useForm?
absent-sapphire
absent-sapphire2y ago
Haven't tried that Give me minute Yes, its still there
Omer
Omer2y ago
Let's try to remove useList as well
absent-sapphire
absent-sapphire2y ago
Just caught it It's coming from const { register, handleSubmit } = useReactHookForm({ } Import statement of the same: import { useForm as useReactHookForm } from '@pankod/refine-react-hook-form'
Omer
Omer2y ago
hmm why did you import two forms?
absent-sapphire
absent-sapphire2y ago
Both are two different things right?
Omer
Omer2y ago
@pankod/refine-react-hook-form package extends useForm already in core. So just use @pankod/refine-react-hook-form
absent-sapphire
absent-sapphire2y ago
Ohh
Omer
Omer2y ago
const userRolesList = useList<IUserRoles>({
resource: "userRoles",
metaData: { fields: [ "id", "type" ] }
})

const { register, handleSubmit } = useReactHookForm({
refineCoreProps: {
action: "edit",
metaData: { fields: [ "id", "name", { user_roles: ["id", "type"], } ] }
}
})

const formSubmitHandler = e => onFinish(e)
const userRolesList = useList<IUserRoles>({
resource: "userRoles",
metaData: { fields: [ "id", "type" ] }
})

const { register, handleSubmit } = useReactHookForm({
refineCoreProps: {
action: "edit",
metaData: { fields: [ "id", "name", { user_roles: ["id", "type"], } ] }
}
})

const formSubmitHandler = e => onFinish(e)
absent-sapphire
absent-sapphire2y ago
Omer
Omer2y ago
Yes definitely, you can have a look here to use the properties in core https://refine.dev/docs/packages/documentation/react-hook-form/useForm/#properties