|
| 1 | +import { QueryHookOptions, useQuery, LazyQueryHookOptions, useLazyQuery, MutationHookOptions, useMutation } from "@apollo/client"; |
| 2 | +import { FetchResult } from "@apollo/client"; |
| 3 | +import { ApolloClient } from "@apollo/client"; |
| 4 | +import { FetchVehicleGraphFieldsByIdQuery } from "../"; |
| 5 | +import { FetchVehicleGraphFieldsByIdQueryVariables } from "../"; |
| 6 | +import { FetchVehicleGraphFieldsByIdDocument } from "../"; |
| 7 | +import { FetchVehicleGraphFieldsQuery } from "../"; |
| 8 | +import { FetchVehicleGraphFieldsDocument } from "../"; |
| 9 | +import { FetchVehicleGraphFieldsQueryVariables } from "../"; |
| 10 | +import { Vehicle_Insert_Input } from "../"; |
| 11 | +import { Vehicle_On_Conflict } from "../"; |
| 12 | +import { InsertVehicleGraphFieldsMutation } from "../"; |
| 13 | +import { InsertVehicleGraphFieldsMutationVariables } from "../"; |
| 14 | +import { InsertVehicleGraphFieldsDocument } from "../"; |
| 15 | +import { Vehicle_Set_Input } from "../"; |
| 16 | +import { UpdateVehicleGraphFieldsByIdMutation } from "../"; |
| 17 | +import { UpdateVehicleGraphFieldsByIdMutationVariables } from "../"; |
| 18 | +import { UpdateVehicleGraphFieldsByIdDocument } from "../"; |
| 19 | +import { UpdateVehicleGraphFieldsMutation } from "../"; |
| 20 | +import { UpdateVehicleGraphFieldsMutationVariables } from "../"; |
| 21 | +import { UpdateVehicleGraphFieldsDocument } from "../"; |
| 22 | +import { RemoveVehicleModelMutation } from "../"; |
| 23 | +import { RemoveVehicleModelMutationVariables } from "../"; |
| 24 | +import { RemoveVehicleModelDocument } from "../"; |
| 25 | +import { RemoveVehicleModelByIdMutation } from "../"; |
| 26 | +import { RemoveVehicleModelByIdMutationVariables } from "../"; |
| 27 | +import { RemoveVehicleModelByIdDocument } from "../"; |
| 28 | + |
| 29 | +// vehicle React |
| 30 | +//------------------------------------------------ |
| 31 | + |
| 32 | +// Fetch Hooks |
| 33 | +// |
| 34 | + |
| 35 | +/** |
| 36 | + * __useFetchVehicleGraphFieldsObjectByIdQuery__ |
| 37 | + * |
| 38 | + * To run a query within a React component, call `useVehicleGraphFieldsObjectByIdQuery` |
| 39 | + * When your component renders, `useVehicleGraphFieldsObjectByIdQuery` returns an object from Apollo Client that contains loading, error, data properties, and a shortcut result property |
| 40 | + * |
| 41 | + * @param queryHookOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; |
| 42 | + * |
| 43 | + * @example |
| 44 | + * const { result, loading, error } = useFetchVehicleGraphFieldsObjectByIdQuery({ vehicleId:<value> }); |
| 45 | + */ |
| 46 | + |
| 47 | +// Fetch Hook |
| 48 | +// |
| 49 | +export function useFetchVehicleGraphFieldsObjectByIdQuery({ |
| 50 | + vehicleId, |
| 51 | + queryHookOptions |
| 52 | +}: { |
| 53 | + vehicleId: string; |
| 54 | + queryHookOptions?: Omit<QueryHookOptions<FetchVehicleGraphFieldsByIdQuery, FetchVehicleGraphFieldsByIdQueryVariables>, "query" | "variables">; |
| 55 | +}) { |
| 56 | + const query = useQuery<FetchVehicleGraphFieldsByIdQuery, FetchVehicleGraphFieldsByIdQueryVariables>(FetchVehicleGraphFieldsByIdDocument, { |
| 57 | + variables: { vehicleId }, |
| 58 | + ...queryHookOptions |
| 59 | + }); |
| 60 | + return { ...query, returning: query && query.data && query.data.vehicle_by_pk }; |
| 61 | +} |
| 62 | + |
| 63 | +// Lazy Fetch Hook |
| 64 | +// |
| 65 | +export function useFetchVehicleObjectByIdLazyQuery({ |
| 66 | + vehicleId, |
| 67 | + queryHookOptions |
| 68 | +}: { |
| 69 | + vehicleId: string; |
| 70 | + queryHookOptions?: Omit<LazyQueryHookOptions<FetchVehicleGraphFieldsByIdQuery, FetchVehicleGraphFieldsByIdQueryVariables>, "query" | "variables">; |
| 71 | +}) { |
| 72 | + const lazyQuery = useLazyQuery<FetchVehicleGraphFieldsByIdQuery, FetchVehicleGraphFieldsByIdQueryVariables>(FetchVehicleGraphFieldsByIdDocument, { |
| 73 | + variables: { vehicleId }, |
| 74 | + ...queryHookOptions |
| 75 | + }); |
| 76 | + |
| 77 | + return [lazyQuery[0], { ...lazyQuery[1], returning: lazyQuery[1] && lazyQuery[1].data && lazyQuery[1].data.vehicle_by_pk }]; |
| 78 | +} |
| 79 | + |
| 80 | +// Fetch Collection Hook |
| 81 | +// |
| 82 | +export function useFetchVehicleObjectsQuery({ |
| 83 | + queryHookOptions |
| 84 | +}: { |
| 85 | + queryHookOptions: Omit<QueryHookOptions<FetchVehicleGraphFieldsQuery, FetchVehicleGraphFieldsQueryVariables>, "query">; |
| 86 | +}) { |
| 87 | + const query = useQuery<FetchVehicleGraphFieldsQuery, FetchVehicleGraphFieldsQueryVariables>(FetchVehicleGraphFieldsDocument, queryHookOptions); |
| 88 | + return { ...query, returning: query && query.data && query.data.vehicle }; |
| 89 | +} |
| 90 | + |
| 91 | +// Lazy Fetch Collection Hook |
| 92 | +// |
| 93 | +export function useFetchVehicleObjectsLazyQuery({ |
| 94 | + queryHookOptions |
| 95 | +}: { |
| 96 | + queryHookOptions?: Omit<LazyQueryHookOptions<FetchVehicleGraphFieldsQuery, FetchVehicleGraphFieldsQueryVariables>, "query">; |
| 97 | +}) { |
| 98 | + const lazyQuery = useLazyQuery<FetchVehicleGraphFieldsQuery, FetchVehicleGraphFieldsQueryVariables>(FetchVehicleGraphFieldsDocument, queryHookOptions); |
| 99 | + |
| 100 | + return [lazyQuery[0], { ...lazyQuery[1], returning: lazyQuery[1] && lazyQuery[1].data && lazyQuery[1].data.vehicle }]; |
| 101 | +} |
| 102 | + |
| 103 | +// Insert Hooks |
| 104 | +// |
| 105 | + |
| 106 | +export async function useInsertVehicleGraphFieldsObject({ |
| 107 | + vehicle, |
| 108 | + onConflict, |
| 109 | + mutationHookOptions |
| 110 | +}: { |
| 111 | + vehicle: Vehicle_Insert_Input; |
| 112 | + onConflict?: Vehicle_On_Conflict; |
| 113 | + mutationHookOptions?: Omit<MutationHookOptions<InsertVehicleGraphFieldsMutation, InsertVehicleGraphFieldsMutationVariables>, "mutation" | "variables">; |
| 114 | +}) { |
| 115 | + const lazyMutation = useMutation<InsertVehicleGraphFieldsMutation, InsertVehicleGraphFieldsMutationVariables>(InsertVehicleGraphFieldsDocument, { |
| 116 | + variables: { objects: [vehicle], onConflict }, |
| 117 | + ...mutationHookOptions |
| 118 | + }); |
| 119 | + |
| 120 | + return [ |
| 121 | + lazyMutation[0], |
| 122 | + { |
| 123 | + ...lazyMutation[1], |
| 124 | + returning: |
| 125 | + lazyMutation[1] && |
| 126 | + lazyMutation[1].data && |
| 127 | + lazyMutation[1].data.insert_vehicle && |
| 128 | + lazyMutation[1].data.insert_vehicle!.returning && |
| 129 | + lazyMutation[1].data.insert_vehicle!.returning[0] |
| 130 | + } |
| 131 | + ]; |
| 132 | +} |
| 133 | + |
| 134 | +export async function insertVehicleGraphFieldsObjects({ |
| 135 | + mutationHookOptions |
| 136 | +}: { |
| 137 | + mutationHookOptions: Omit<MutationHookOptions<InsertVehicleGraphFieldsMutation, InsertVehicleGraphFieldsMutationVariables>, "mutation">; |
| 138 | +}) { |
| 139 | + const lazyMutation = useMutation<InsertVehicleGraphFieldsMutation, InsertVehicleGraphFieldsMutationVariables>(InsertVehicleGraphFieldsDocument, { ...mutationHookOptions }); |
| 140 | + |
| 141 | + return [ |
| 142 | + lazyMutation[0], |
| 143 | + { ...lazyMutation[1], returning: lazyMutation[1] && lazyMutation[1].data && lazyMutation[1].data.insert_vehicle && lazyMutation[1].data.insert_vehicle!.returning } |
| 144 | + ]; |
| 145 | +} |
| 146 | + |
| 147 | +// Update Hooks |
| 148 | +// |
| 149 | + |
| 150 | +export async function updateVehicleGraphFieldsObjectById({ |
| 151 | + vehicleId, |
| 152 | + set, |
| 153 | + mutationHookOptions |
| 154 | +}: { |
| 155 | + vehicleId: string; |
| 156 | + set: Vehicle_Set_Input; |
| 157 | + mutationHookOptions?: Omit<MutationHookOptions<UpdateVehicleGraphFieldsByIdMutation, UpdateVehicleGraphFieldsByIdMutationVariables>, "mutation">; |
| 158 | +}) { |
| 159 | + const lazyMutation = useMutation<UpdateVehicleGraphFieldsByIdMutation, UpdateVehicleGraphFieldsByIdMutationVariables>(UpdateVehicleGraphFieldsByIdDocument, { |
| 160 | + variables: { id: vehicleId, set }, |
| 161 | + ...mutationHookOptions |
| 162 | + }); |
| 163 | + |
| 164 | + return [ |
| 165 | + lazyMutation[0], |
| 166 | + { |
| 167 | + ...lazyMutation[1], |
| 168 | + returning: |
| 169 | + lazyMutation[1] && |
| 170 | + lazyMutation[1].data && |
| 171 | + lazyMutation[1].data.update_vehicle && |
| 172 | + lazyMutation[1].data.update_vehicle!.returning && |
| 173 | + lazyMutation[1].data.update_vehicle!.returning[0] |
| 174 | + } |
| 175 | + ]; |
| 176 | +} |
| 177 | + |
| 178 | +export async function updateVehicleGraphFieldsObjects({ |
| 179 | + apolloClient, |
| 180 | + mutationHookOptions |
| 181 | +}: { |
| 182 | + apolloClient: ApolloClient<object>; |
| 183 | + mutationHookOptions: Omit<MutationHookOptions<UpdateVehicleGraphFieldsMutation, UpdateVehicleGraphFieldsMutationVariables>, "mutation">; |
| 184 | +}) { |
| 185 | + const lazyMutation = useMutation<UpdateVehicleGraphFieldsMutation, UpdateVehicleGraphFieldsMutationVariables>(UpdateVehicleGraphFieldsDocument, { ...mutationHookOptions }); |
| 186 | + |
| 187 | + return [ |
| 188 | + lazyMutation[0], |
| 189 | + { ...lazyMutation[1], returning: lazyMutation[1] && lazyMutation[1].data && lazyMutation[1].data.update_vehicle && lazyMutation[1].data.update_vehicle!.returning } |
| 190 | + ]; |
| 191 | +} |
| 192 | + |
| 193 | +// Delete Hooks |
| 194 | +// |
| 195 | + |
| 196 | +export async function removeVehicleModelObjectById({ |
| 197 | + vehicleId, |
| 198 | + mutationHookOptions |
| 199 | +}: { |
| 200 | + vehicleId: string; |
| 201 | + mutationHookOptions?: Omit<MutationHookOptions<RemoveVehicleModelByIdMutation, RemoveVehicleModelByIdMutationVariables>, "mutation">; |
| 202 | +}) { |
| 203 | + const lazyMutation = useMutation<RemoveVehicleModelByIdMutation, RemoveVehicleModelByIdMutationVariables>(RemoveVehicleModelByIdDocument, { |
| 204 | + variables: { id: vehicleId }, |
| 205 | + ...mutationHookOptions |
| 206 | + }); |
| 207 | + |
| 208 | + return [ |
| 209 | + lazyMutation[0], |
| 210 | + { ...lazyMutation[1], returning: lazyMutation[1] && lazyMutation[1].data && lazyMutation[1].data.delete_vehicle && lazyMutation[1].data.delete_vehicle!.affected_rows } |
| 211 | + ]; |
| 212 | +} |
| 213 | + |
| 214 | +export async function removeVehicleModelObjects({ |
| 215 | + mutationHookOptions |
| 216 | +}: { |
| 217 | + mutationHookOptions: Omit<MutationHookOptions<RemoveVehicleModelMutation, RemoveVehicleModelMutationVariables>, "mutation">; |
| 218 | +}) { |
| 219 | + const lazyMutation = useMutation<RemoveVehicleModelMutation, RemoveVehicleModelMutationVariables>(RemoveVehicleModelDocument, { ...mutationHookOptions }); |
| 220 | + |
| 221 | + return [ |
| 222 | + lazyMutation[0], |
| 223 | + { ...lazyMutation[1], returning: lazyMutation[1] && lazyMutation[1].data && lazyMutation[1].data.delete_vehicle && lazyMutation[1].data.delete_vehicle!.affected_rows } |
| 224 | + ]; |
| 225 | +} |
0 commit comments