Skip to content

Fix return type of simplifyParsedResolveInfoFragmentWithType #872

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

Open
wants to merge 2 commits into
base: v4
Choose a base branch
from

Conversation

dhritzkiv
Copy link

Description

Specify type as ResolveTree for returned fields in simplifyParsedResolveInfoFragmentWithType. Otherwise, the return type is simply {} which is not indexable in TS.

Checklist

  • My code matches the project's code style and yarn lint:fix passes.
  • I've added tests for the new feature, and yarn test passes.
  • I have detailed the new feature in the relevant documentation.
  • I have added this feature to 'Pending' in the RELEASE_NOTES.md file (if one exists).
  • If this is a breaking change I've explained why.

Specify type as `ResolveTree` for returned `fields` in `simplifyParsedResolveInfoFragmentWithType`. Otherwise, the return type is simply `{}` which is not indexable in TS.
@dhritzkiv dhritzkiv marked this pull request as ready for review May 13, 2025 21:27
benjie
benjie previously approved these changes Jun 11, 2025
Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -352,7 +352,7 @@ export function simplifyParsedResolveInfoFragmentWithType(
type: GraphQLType
) {
const { fieldsByTypeName } = parsedResolveInfoFragment;
const fields = {};
const fields: ResolveTree = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/index.ts:355:9 - error TS2739: Type '{}' is missing the following properties from type 'ResolveTree': name, alias, args, fieldsByTypeName

355   const fields: ResolveTree = {};

@benjie benjie dismissed their stale review June 11, 2025 09:58

Types don't match.

@dhritzkiv
Copy link
Author

Sorry about that – I didn't see that tests fail when I initially submitted this PR.

I've now changed the syntax to allow for treating fields as ResolveTree, when initializing it.

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.

2 participants