-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] getOne method doesn't use meta.gqlVariables
in @refinedev/hasura
#6374
Comments
I am trying to do something more simple like this and it still doesnt work it only passes the ID, nothing changes there is no extraValue. const { data, isLoading, isError } = useOne({
resource: "settings",
id: 1,
meta: {
gqlQuery: SETTINGS_WITH_VALUES_DATA_QUERY,
variables: {
extraValue: 2,
},
gqlVariables: {
extraValue: 2,
},
},
queryOptions: {
enabled: true,
},
}); Inside my DataProvider i have this: getOne: async (...args) => {
try {
return await dataProvider.getOne(...args);
} catch (error) {
throw error;
}
}, I managed to pass variables by changing it to this: getOne: async ({ resource, id, meta }) => {
try {
// Extract custom variables from meta
const customVariables = meta?.variables || {};
const variables = {
id,
...customVariables,
};
const query = meta?.gqlQuery!;
const response = await client.request<BaseRecord>(query, variables);
return {
data: response[meta?.operation!],
};
} catch (error) {
throw error;
}
}, But is this correct? I dont want to write custom logic for something that already exists like passing a custom varaible? |
Hey @vrrashkov sorry for the issue! Looks like the PR #6222 missed updating the We'll be happy to see your contribution, if you can prepare a PR with the fix. Until this is fixed and released, you can stick with your workaround for the I'll update the issue title since this is not related with |
meta.gqlVariables
in @refinedev/hasura
Describe the bug
Trying to pass custom variables other than ID to a query is not working. Here is the code that I have. I am using useForm and what in my getOne query to have extra variable not only the ID.
My graphql is this:
I am not sure if I am missing something from the documentation but i have tried multiple ways as you can see in the above code and nothing seems to be helping it always sends only
variables : {id: "1"}
, the extraValue i am trying to pass its not there.Steps To Reproduce
Test with the code provided
Expected behavior
Custom variables should be included
Packages
Additional Context
No response
The text was updated successfully, but these errors were encountered: