firebase-functions
Version:
Firebase SDK for Cloud Functions
59 lines (58 loc) • 2.1 kB
TypeScript
import express from "express";
import type { GraphQLResolveInfo } from "graphql";
import { HttpsFunction, HttpsOptions } from "../https";
/** @hidden */
export declare function initGraphqlServer(opts: GraphqlServerOptions): Promise<express.Express>;
/**
* @hidden
* Handles HTTPS GraphQL requests.
* @param {GraphqlServerOptions} opts - Options for configuring the GraphQL server.
* @returns {HttpsFunction} A function you can export and deploy.
*/
export declare function onGraphRequest(opts: GraphqlServerOptions): HttpsFunction;
/**
* @hidden
* Options for configuring the GraphQL server.
*/
export interface GraphqlServerOptions extends Omit<HttpsOptions, "cors"> {
/**
* A valid SDL string that represents the GraphQL server's schema.
* Either `schema` or `schemaFilePath` is required.
*/
schema?: string;
/**
* A relative file path from the Firebase project directory to a valid GraphQL schema.
* Either `schema` or `schemaFilePath` is required.
*/
schemaFilePath?: string;
/**
* The path where the GraphQL server will be served on the Cloud Run function.
* e.g. https://...run.app/{path}
* If no path is provided, "graphql" is used as the default.
*/
path?: string;
/** A map of functions that populate data for individual GraphQL schema fields. */
resolvers: GraphqlResolvers;
}
/**
* @hidden
* Per-request context state shared by all resolvers in a particular query.
*/
export interface FirebaseContext {
auth: {
/** The token attached to the `X-Firebase-Auth-Token` in the request, if present. */
token?: string;
};
}
/**
* @hidden
* Resolver functions that populate data for individual GraphQL schema fields.
*/
export interface GraphqlResolvers {
query?: {
[resolver: string]: (parent: unknown, args: Record<string, unknown>, context: FirebaseContext, info: GraphQLResolveInfo) => unknown;
};
mutation?: {
[key: string]: (parent: unknown, args: Record<string, unknown>, context: FirebaseContext, info: GraphQLResolveInfo) => unknown;
};
}