gatsby-source-payload-cms
Version:
Source data from Payload CMS
43 lines (42 loc) • 1.75 kB
TypeScript
import type { ICollectionTypeObject, IGlobalTypeObject } from "./types";
/**
* Fetch utility for requests to the example api.
* You can use a GraphQL client module instead if you prefer a more full-featured experience.
* @see https://graphql.org/code/#javascript-client
*/
export declare function fetchGraphQL<T>(endpoint: string, query: string): Promise<T>;
export declare const fetchDataMessage: (url: string, serializedParams?: string) => string;
export declare const gatsbyNodeTypeName: ({ payloadSlug, prefix }: {
payloadSlug: string;
prefix?: string;
}) => string;
/**
* Get doc relationships
*
* From an API response, return dot notation key value pairs of relationship ids only.
*
* Note that this only works if the relationship is expanded.
* i.e. it includes an `id` field. Consider adding support
* for non-expanded relationships. e.g.
* ``"hereForYou.image": "64877d207ac104cf4d385657"`.
*
* The document id is excluded (desirable) because it doesn't
* end with `.id`. e.g. `"id": "64877d207ac104cf4d385657"`.
*/
export declare const documentRelationships: (doc: {
[key: string]: unknown;
}, prefix?: string) => Partial<any>;
export declare const payloadImage: (apiResponse: {
[key: string]: any;
}, size?: string) => any;
export declare const payloadImageUrl: (apiResponse: {
[key: string]: any;
}, size?: string, baseUrl?: string) => string | undefined;
export declare const normalizeGlobals: (globalTypes: Array<string | IGlobalTypeObject> | undefined, endpoint: string) => {
endpoint: string;
type: string;
}[];
export declare const normalizeCollections: (collectionTypes: Array<string | ICollectionTypeObject> | undefined, endpoint: string) => {
endpoint: string;
type: string;
}[];