graphql-constraint-directive
graphql-constraint-directive copied to clipboard
`apollo4.d.ts` has wrong type for `createApollo4QueryValidationPlugin`
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
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;
}
Thank you @Synthetic-Dev, PRs welcome