UNPKG

@aws-amplify/api

Version:

Api category of aws-amplify

33 lines (32 loc) • 1.69 kB
import { V6Client } from '@aws-amplify/api-graphql'; import { CommonPublicClientOptions, DefaultCommonClientOptions } from '@aws-amplify/api-graphql/internals'; import { AmplifyContext } from '@aws-amplify/core'; /** * Generates an API client bound to a specific {@link AmplifyContext} instead of * the global `Amplify` singleton. Use this overload when you need to scope a * client to an explicit context (e.g. multi-tenant or server-side rendering * scenarios) rather than the shared singleton configuration. * * @param ctx - The {@link AmplifyContext} the client should resolve its * configuration and auth from. * @param options - Optional client options. * @returns {@link V6Client} * @throws {@link Error} - Throws error when client cannot be generated due to configuration issues. * * @example * ```ts * import { generateClient } from 'aws-amplify/api'; * // `listTodos` is a generated GraphQL query document (from your API's codegen output). * * const client = generateClient(ctx); * const result = await client.graphql({ query: listTodos }); * ``` */ export declare function generateClient<T extends Record<any, any> = never, Options extends CommonPublicClientOptions = DefaultCommonClientOptions>(ctx: AmplifyContext, options?: Options): V6Client<T, Options>; /** * Generates an API client that can work with models or raw GraphQL * * @returns {@link V6Client} * @throws {@link Error} - Throws error when client cannot be generated due to configuration issues. */ export declare function generateClient<T extends Record<any, any> = never, Options extends CommonPublicClientOptions = DefaultCommonClientOptions>(options?: Options): V6Client<T, Options>;