Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apollo4.d.ts has wrong type for createApollo4QueryValidationPlugin #219

Open
Synthetic-Dev opened this issue Jan 22, 2024 · 2 comments
Open

Comments

@Synthetic-Dev
Copy link

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

@Synthetic-Dev
Copy link
Author

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;
}

@confuser
Copy link
Owner

Thank you @Synthetic-Dev, PRs welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants