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

@defer gives TypeError: Cannot read properties of undefined (reading 'length') #12245

Open
VinceBT-BG opened this issue Dec 27, 2024 · 8 comments
Labels
🏓 awaiting-team-response requires input from the apollo team

Comments

@VinceBT-BG
Copy link

This is an example of query:

query listAuthorsWithStats(
	$authorIds: [ID!]
	$startDate: DateTime!
	$endDate: DateTime!
	$timeZone: String!
) {
	listAuthors(
		authorIds: $authorIds
		startDate: $startDate
		endDate: $endDate
	) {
		authors {
			id
			... @defer {
				stats(startDate: $startDate, endDate: $endDate, timeZone: $timeZone) {
					aggregates {
						labels
						value
					}
				}
			}
		}
	}
}

And this is the stacktrace of the error that I get:

[Network]: TypeError: Cannot read properties of undefined (reading 'length')
0:" at eval (webpack-internal:///../../node_modules/.pnpm/@[email protected]_@[email protected][email protected]_bwcf472rfi3np7dy47bczsyb6q/node_modules/@apollo/client/utilities/common/incrementalResult.js:38:31)"
1:" at Array.forEach (<anonymous>)"
2:" at mergeIncrementalData (webpack-internal:///../../node_modules/.pnpm/@[email protected]_@[email protected][email protected]_bwcf472rfi3np7dy47bczsyb6q/node_modules/@apollo/client/utilities/common/incrementalResult.js:36:28)"
3:" at QueryInfo.markResult (webpack-internal:///../../node_modules/.pnpm/@[email protected]_@[email protected][email protected]_bwcf472rfi3np7dy47bczsyb6q/node_modules/@apollo/client/core/QueryInfo.js:274:103)"
4:" at eval (webpack-internal:///../../node_modules/.pnpm/@[email protected]_@[email protected][email protected]_bwcf472rfi3np7dy47bczsyb6q/node_modules/@apollo/client/core/QueryManager.js:812:27)"
5:" at both (webpack-internal:///../../node_modules/.pnpm/@[email protected]_@[email protected][email protected]_bwcf472rfi3np7dy47bczsyb6q/node_modules/@apollo/client/utilities/observables/asyncMap.js:27:31)"

I have been following the tutorial from here

These are the versions that I use:

"@apollo/client": "^3.12.4"
"graphql": "^17.0.0-alpha.7"
@jerelmiller
Copy link
Member

Hey @VinceBT-BG 👋

Apollo Client is only compatible with the 17.0.0-alpha.2 format of @defer responses, so your issue is likely there. Can you try downgrading graphql to 17.0.0-alpha.2 and see if that fixes your issue?

@jerelmiller jerelmiller added 🏓 awaiting-contributor-response requires input from a contributor ℹ needs-more-info Needs more information to determine root cause labels Jan 6, 2025
@VinceBT-BG
Copy link
Author

It looks like it fixed my issue, thanks
Is there somewhere we can keep track of the evolution of the @defer and @stream features for future production use ?

@jerelmiller
Copy link
Member

@VinceBT-BG are you looking to track it from the GraphQL spec itself or Apollo's implementation of it? I'll give you both links anyways 😆

We're hoping the format is settled sometime soon so that we can update the client to support the newer format from the spec, but we've held off so that we aren't introducing too much churn in the client. I believe alpha.2 is the most popular format in the ecosystem right now, but here's to hoping we are able to move forward sometime soon 🤞

@robrichard
Copy link

Hi @jerelmiller, have you had a chance to review the latest incremental delivery response format? I think it would be a big help in moving the proposal forward if we have buy in from the major GraphQL clients. Would you or any other maintainers of apollo-client be willing to review and let us know that the current proposal works for you?

@jerelmiller
Copy link
Member

@robrichard I was reading through it this morning, though I'm going to spend some more time with it (apologies, I haven't followed the spec changes super closely up until now). Barring any significant feedback, does it look like this might be the final or close to final version?

We have a team meeting this week to discuss @defer as well so I might have some updates there soon from us.

@github-actions github-actions bot removed the 🏓 awaiting-contributor-response requires input from a contributor label Jan 8, 2025
@robrichard
Copy link

@jerelmiller I can't guarantee this will be the final version until the spec edits are accepted, but there haven't been any proposed changes to the response format since the June 2023 version. I'm working now on getting the spec edits reviewed, but getting buy in from the wider graphql ecosystem will help give us confidence to move forward.

@jerelmiller
Copy link
Member

@robrichard ok thats great to hear! Thanks for chiming in. I'll try and provide an update if I have one after our meeting this morning.

@jerelmiller
Copy link
Member

Ok an update from our end:

We took a look at this as a team and will eventually set some time aside, but it will take a bit of time. We do plan to bake in a defer sprint eventually, but we need to tackle some existing defer issues to get a proper vetting of the new format. We'd also like to bring some internal teams with us which make take a bit of time. We will do our best to get to this as soon as we can but bear with us in the mean time!

@jerelmiller jerelmiller added 🏓 awaiting-team-response requires input from the apollo team and removed ℹ needs-more-info Needs more information to determine root cause labels Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏓 awaiting-team-response requires input from the apollo team
Projects
None yet
Development

No branches or pull requests

3 participants