export const createBill = /* GraphQL */ `mutation CreateBill(
$input: CreateBillInput!
$condition: ModelBillConditionInput
) {
createBill(input: $input, condition: $condition) {
periodStart
periodEnd
energy
senderId
receiverId
metering_point_number
file_key
customer_number
bill_number
paid
interval
id
createdAt
updatedAt
__typename
}
}
` as GeneratedMutation<
APITypes.CreateBillMutationVariables,
APITypes.CreateBillMutation
>;
I have this graphql query wich is automatically generated.
Now i try to create an function that takes in the string createBill
and variables. The variables are the CreateBillMutationVariables
and the return type should be CreateBillMutation
How do i do this?
import * as mutations from ‘@/src/graphql/mutations’
import * as mutations from ‘@/src/graphql/mutations’
export const apiQuery = <
T extends keyof typeof mutations,
F extends (typeof mutations)[T]
>(
query: T,
variables: F
) => {
return API.graphql(graphqlOperation(query, variables))
}
I have tried this, it works for query, but not for variables.