foolish-indigoF
Refine16mo ago
6 replies
foolish-indigo

Antd useForm how to set custom variable for graphql

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.

const { formProps: editFormProps, saveButtonProps: editSaveButtonProps } =
useForm<
GetFields<UpdateSettingValueMutation>,
HttpError,
GetVariables<UpdateSettingValueMutationVariables>
>({
action: "edit",
resource: "settings",
id: editingId?.toString(),
meta: {
gqlQuery: SETTINGS_WITH_VALUES_DATA_QUERY,
gqlMutation: UPDATE_SETTING_VALUES_MUTATION,
gqlVariables: {
extraValue: 1,
},
},
queryMeta: {
meta: {
extraValue: 1,
},
gqlVariables: {
extraValue: 1,
},
},
queryOptions: {
meta: {
extraValue: 1,
},
},
mutationMode: "pessimistic",
onMutationSuccess: () => {
setEditingId(null);
},
});
My graphql is this:

export const SETTINGS_WITH_VALUES_DATA_QUERY = gql query SettingsWithValuesDataOne($id: ID!, $extraValue: Int!) { setting(id: $id, extraValue: $extraValue) { ...SettingsWithValuesDataFields } } ${SETTINGS_WITH_VALUES_DATA_FIELDS}, ;
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.
Was this page helpful?