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

Missing relationships for included resource #254

Open
bbprojectnet opened this issue Aug 7, 2023 · 0 comments
Open

Missing relationships for included resource #254

bbprojectnet opened this issue Aug 7, 2023 · 0 comments

Comments

@bbprojectnet
Copy link

Hi,

I have weird case, i have simple polls with hasMany questions resources. Questions resource also have self reference for parent question (enabledIfQuestion).

When i try to GET /api/polls/{id}?include=questions,questions.enabledIfQuestion everything works fine, but, when i define questions relationship in Poll model with ->orderBy(), like that:

	public function questions(): HasMany
	{
		return $this->hasMany(PollQuestion::class)->orderBy('order');
	}

then, in response, some (but not all) records has missing relationships in included section.

Without order:

		{
			"type": "poll-questions",
			"id": "gAa0pkGKYEZJYRxlXenVo5d4",
			"attributes": {
				...
			},
			"relationships": {
				"enabledIfQuestion": {
					"data": {
						"type": "poll-questions",
						"id": "Q0OkPGeARaLdERrdmwn1op9Y"
					}
				}
			}
		},

With order:

		{
			"type": "poll-questions",
			"id": "gAa0pkGKYEZJYRxlXenVo5d4",
			"attributes": {
				...
			}
		},
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

1 participant