variables name not changing

I want to create mutation to hasura, i use useCreate and add variables to the meta object. I want the variable named "objects" but refine still send variables named "object". Please how can i change it to "objects". In the query i already use objects, but still somehow refine send "object" without s.
4 Replies
kapa.ai
kapa.ai3w ago
Hi @heisenbergt. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, it appears that Refine doesn't have a direct way to change the variable name from "object" to "objects" for mutations in the Hasura data provider. The default behavior seems to use "object" as the variable name. However, there are a couple of approaches you might consider: 1. Use mutationMeta: You can try using the mutationMeta property instead of meta when calling useCreate. This property is specifically used for passing additional information to mutation hooks.
useCreate({
resource: "your_resource",
values: yourValues,
mutationMeta: {
gqlMutation: YOUR_MUTATION,
variables: {
objects: yourObjects
}
}
});

useCreate({
resource: "your_resource",
values: yourValues,
mutationMeta: {
gqlMutation: YOUR_MUTATION,
variables: {
objects: yourObjects
}
}
});

useForm mutationMeta documentation (https://refine.dev/docs/ui-integrations/mantine/hooks/use-form/#mutationmeta) 2. Custom Data Provider: If the above approach doesn't work, you might need to create a custom data provider that extends the Hasura data provider. In this custom provider, you could override the create method to use "objects" instead of "object".
const customDataProvider = {
...dataProvider,
create: async ({ resource, variables, meta }) => {
// Modify the variables here to use "objects" instead of "object"
const modifiedVariables = { objects: variables.object };
return dataProvider.create({ resource, variables: modifiedVariables, meta });
}
};

const customDataProvider = {
...dataProvider,
create: async ({ resource, variables, meta }) => {
// Modify the variables here to use "objects" instead of "object"
const modifiedVariables = { objects: variables.object };
return dataProvider.create({ resource, variables: modifiedVariables, meta });
}
};

Data Provider create method documentation (https://refine.dev/docs/data/data-provider/#create-) It's important to note that these suggestions are based on the available documentation and may require some experimentation. The knowledge sources don't provide a direct solution to your specific issue. If these approaches don't solve your problem, you might want to consider raising an issue on the Refine GitHub repository for more specific guidance or to request this feature. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3w ago
<@876018755170345001> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
metropolitan-bronze
metropolitan-bronzeOP3w ago
please someone help, nothing worked
environmental-rose
environmental-rose3w ago
Hello @heisenbergt, unfortunately it's not possible to change variable key. implementation is here: https://github.com/refinedev/refine/blob/main/packages/hasura/src/dataProvider/index.ts#L277 you can swizzle the data-provider and customize according to your needs. swizzle documentation is here: https://refine.dev/docs/packages/cli/#swizzle

Did you find this page helpful?