Skip to content

Commit

Permalink
[graphiql] fix types to allow overriding endpoint option
Browse files Browse the repository at this point in the history
  • Loading branch information
EmrysMyrddin committed Jan 31, 2025
1 parent 11d4fb9 commit b931c4a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/graphql-yoga/src/plugins/use-graphiql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,19 @@ export type GraphiQLOptions = {
* Retry attempts
*/
retry?: number;
};

export type GraphiQLRendererOptions = {
/**
* The endpoint requests should be sent. Defaults to `"/graphql"`.
* The endpoint requests should be sent.
* Defaults to the graphql endpoint ("/graphql" by default).
*/
endpoint?: string;
} & GraphiQLOptions;
};

/**
* @deprecated replaced by GraphiQLOptions
*/
export type GraphiQLRendererOptions = GraphiQLOptions;

export const renderGraphiQL = (opts: GraphiQLRendererOptions) =>
export const renderGraphiQL = (opts: GraphiQLOptions) =>
graphiqlHTML
.replace('__TITLE__', opts?.title || 'Yoga GraphiQL')
.replace('__OPTS__', JSON.stringify(opts ?? {}));
Expand All @@ -148,7 +151,7 @@ export type GraphiQLOptionsOrFactory<TServerContext> =
export interface GraphiQLPluginConfig<TServerContext> {
graphqlEndpoint: string;
options?: GraphiQLOptionsOrFactory<TServerContext>;
render?(options: GraphiQLRendererOptions): PromiseOrValue<BodyInit>;
render?(options: GraphiQLOptions): PromiseOrValue<BodyInit>;
logger?: YogaLogger;
}

Expand Down

0 comments on commit b931c4a

Please sign in to comment.