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

Add type definitions to schema extensions #2081

Merged
merged 9 commits into from
Aug 23, 2022

Conversation

smyrick
Copy link
Member

@smyrick smyrick commented Aug 18, 2022

TS Compiler error

image

Because the type schema.extensions is unknown the TS compiler is failing because it doesn't know for sure if schema.extensions.apollo is an object. If it is not, we can not perform a spread on it.

@netlify
Copy link

netlify bot commented Aug 18, 2022

👷 Deploy request for apollo-federation-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 183bed8

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 18, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@cpeacock
Copy link
Contributor

@clenfest mind taking a quick look at this at some point? seems fine to me but you are more knowledgeable

@clenfest clenfest merged commit baa77b5 into apollographql:main Aug 23, 2022
@smyrick smyrick deleted the ts-schema-extensions branch August 23, 2022 18:24
@trevor-scheer
Copy link
Member

@smyrick @clenfest This is just a fly-by comment and it's possible I'm misunderstanding something here, but I would've expected something similar to what subgraph-js does by extending the extensions type as the outcome:

declare module 'graphql/type/definition' {
interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
apollo?: {
subgraph?: ApolloSubgraphExtensions<_TContext>;
};
}

@smyrick
Copy link
Member Author

smyrick commented Aug 24, 2022

@trevor-scheer There is that type declared already:

declare module 'graphql/type/schema' {
interface GraphQLSchemaExtensions {
apollo?: {
gateway?: ApolloGatewayExtensions;
}
}
}

And I am using it here:

import { GraphQLSchemaExtensions } from 'graphql/type/schema';

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

Successfully merging this pull request may close these issues.

5 participants