Generation

generate functionSat, 03 Dec 2022

graphql request {blog : {image}} with fetch

export interface Image { url: string; width: number; height: number; } export interface Blog { image: Image; } export interface BlogQuery { blog: Blog; } export interface Client { request(query: DocumentNode): Promise<any>; } export function getImage(client: Client): Promise<Image> { return client .request(gql` { blog { image { url width height } } } `) .then(res => res.blog.image); }

TypeScript
Generate More

Questions about programming?Chat with your personal AI assistant