The set of data and hooks that a unary method supports.

interface UnaryFunctions {
    createData: ((data) => O);
    createUseInfiniteQueryOptions: (<ParamKey>(input, options) => {
        enabled: boolean;
        getNextPageParam: GetNextPageParamFunction<O>;
        onError?: ((error) => void);
        queryFn: ((context) => Promise<O>);
        queryKey: ConnectQueryKey<I>;
    });
    createUseMutationOptions: ((options?) => {
        mutationFn: ((input, context?) => Promise<O>);
        onError?: ((error) => void);
    });
    createUseQueryOptions: ((input?, options?) => {
        enabled: boolean;
        onError?: ((error) => void);
        placeholderData?: (() => undefined | O);
        queryFn: ((context?) => Promise<O>);
        queryKey: ConnectQueryKey<I>;
    });
    getPartialQueryKey: (() => ConnectPartialQueryKey);
    getQueryKey: ((input?) => ConnectQueryKey<I>);
    methodInfo: MethodInfoUnary<I, O>;
    setQueriesData: ((updater) => [queryKey: ConnectPartialQueryKey, updater: ((prev?) => undefined | O)]);
    setQueryData: ((updater, input?) => [queryKey: ConnectQueryKey<I>, updater: ((prev?) => undefined | O)]);
}

Type Parameters

Properties

createData: ((data) => O)

Type declaration

    • (data): O
    • Use this to create a data object that can be used as placeholderData or initialData.

      Parameters

      Returns O

createUseInfiniteQueryOptions: (<ParamKey>(input, options) => {
    enabled: boolean;
    getNextPageParam: GetNextPageParamFunction<O>;
    onError?: ((error) => void);
    queryFn: ((context) => Promise<O>);
    queryKey: ConnectQueryKey<I>;
})

Type declaration

    • <ParamKey>(input, options): {
          enabled: boolean;
          getNextPageParam: GetNextPageParamFunction<O>;
          onError?: ((error) => void);
          queryFn: ((context) => Promise<O>);
          queryKey: ConnectQueryKey<I>;
      }
    • This helper is intended to be used with QueryClients useInfiniteQuery function.

      Type Parameters

      • ParamKey extends string | number | symbol

      Parameters

      • input: typeof disableQuery | PartialMessage<I>
      • options: {
            applyPageParam?: ((options) => PartialMessage<I>);
            callOptions?: CallOptions;
            getNextPageParam: ((lastPage, allPages) => PartialMessage<I>[ParamKey]);
            onError?: ((error) => void);
            pageParamKey?: ParamKey;
            sanitizeInputKey?: ((input) => unknown);
            transport?: Transport;
        }
        • Optional applyPageParam?: ((options) => PartialMessage<I>)
        • Optional callOptions?: CallOptions
        • getNextPageParam: ((lastPage, allPages) => PartialMessage<I>[ParamKey])
        • Optional onError?: ((error) => void)
        • Optional pageParamKey?: ParamKey
        • Optional sanitizeInputKey?: ((input) => unknown)
            • (input): unknown
            • The option allows you to remove fields or otherwise customize the input used to generate the query key. By default, we will remove the pageParamKey from the input. If this is provided, we will use this result instead.

              Parameters

              Returns unknown

        • Optional transport?: Transport

      Returns {
          enabled: boolean;
          getNextPageParam: GetNextPageParamFunction<O>;
          onError?: ((error) => void);
          queryFn: ((context) => Promise<O>);
          queryKey: ConnectQueryKey<I>;
      }

createUseMutationOptions: ((options?) => {
    mutationFn: ((input, context?) => Promise<O>);
    onError?: ((error) => void);
})

Type declaration

    • (options?): {
          mutationFn: ((input, context?) => Promise<O>);
          onError?: ((error) => void);
      }
    • This function is intended to be used with TanStack Query's useMutation API.

      Parameters

      • Optional options: {
            callOptions?: CallOptions;
            onError?: ((error) => void);
            transport?: Transport;
        }

      Returns {
          mutationFn: ((input, context?) => Promise<O>);
          onError?: ((error) => void);
      }

createUseQueryOptions: ((input?, options?) => {
    enabled: boolean;
    onError?: ((error) => void);
    placeholderData?: (() => undefined | O);
    queryFn: ((context?) => Promise<O>);
    queryKey: ConnectQueryKey<I>;
})

Type declaration

    • (input?, options?): {
          enabled: boolean;
          onError?: ((error) => void);
          placeholderData?: (() => undefined | O);
          queryFn: ((context?) => Promise<O>);
          queryKey: ConnectQueryKey<I>;
      }
    • createUseQueryOptions is intended to be used with useQuery, but is not a hook. Since hooks cannot be called conditionally (or in loops), it can sometimes be helpful to use createUseQueryOptions to prepare an input to TanStack's useQuery API.

      The caveat being that if you go the route of using createUseQueryOptions you must provide transport. You can get transport from the useTransport export, or make sure these functions were generated with createQueryService() with a transport provided.

      Parameters

      Returns {
          enabled: boolean;
          onError?: ((error) => void);
          placeholderData?: (() => undefined | O);
          queryFn: ((context?) => Promise<O>);
          queryKey: ConnectQueryKey<I>;
      }

      • enabled: boolean
      • Optional onError?: ((error) => void)
      • Optional placeholderData?: (() => undefined | O)
          • (): undefined | O
          • Returns undefined | O

      • queryFn: ((context?) => Promise<O>)
      • queryKey: ConnectQueryKey<I>
getPartialQueryKey: (() => ConnectPartialQueryKey)

Type declaration

getQueryKey: ((input?) => ConnectQueryKey<I>)

Type declaration

methodInfo: MethodInfoUnary<I, O>

This is the metadata associated with this method.

setQueriesData: ((updater) => [queryKey: ConnectPartialQueryKey, updater: ((prev?) => undefined | O)])

Type declaration

setQueryData: ((updater, input?) => [queryKey: ConnectQueryKey<I>, updater: ((prev?) => undefined | O)])

Type declaration

Generated using TypeDoc