graphql-constraint-directive icon indicating copy to clipboard operation
graphql-constraint-directive copied to clipboard

`apollo4.d.ts` has wrong type for `createApollo4QueryValidationPlugin`

Open l3dotdev opened this issue 1 year ago • 2 comments

Package version: 5.3.0

The latest package version has this type for the apollo4 plugin create function:

export function createApollo4QueryValidationPlugin ( options: { schema?: GraphQLSchema } ) : ApolloServerPlugin;

The expected type for this function is as follows:

// from index.d.ts
interface PluginOptions {
    formats: Record<string, (value: unknown) => boolean>;
}

export function createApollo4QueryValidationPlugin ( options: PluginOptions ) : ApolloServerPlugin;

I am willing to create a PR

l3dotdev avatar Jan 22 '24 20:01 l3dotdev

Temporary fix for anyone who finds this:

// graphql-constraint-directive-fix.d.ts
import type { ApolloServerPlugin } from "@apollo/server";
import type { PluginOptions } from "graphql-constraint-directive";

export {};

declare module "graphql-constraint-directive/apollo4" {
	/**
	 * Create Apollo 4 validation plugin.
	 *
	 * @param options to setup plugin. `schema` is deprecated now, not used, as plugins gets schema from the Apollo Server.
	 */
	export function createApollo4QueryValidationPlugin(options: PluginOptions): ApolloServerPlugin;
}

l3dotdev avatar Jan 22 '24 22:01 l3dotdev

Thank you @Synthetic-Dev, PRs welcome

confuser avatar Jan 23 '24 09:01 confuser