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

Set common loader key in BaseLoader getBaseRelatedIdLoader #1506

Conversation

juan871003
Copy link
Contributor

Set common loader key so we can properly batch related entities and make one call to findByRelatedId with all the batched keys.

const loaderKey = `${gqlTypeName}-${relatedField}-${JSON.stringify(
		filter
	)}`; /* gqlTypeName-fieldname-filterObject */

👆 The above code causes the loaderKey to be unique for each related entity instead of having a common key.

const loaderKey = `${gqlTypeName}-${relatedField}`; /* gqlTypeName-fieldname */

👆 This makes a common key per entity and field

Set common loader key so we can properly batch related entities and make one call to findByRelatedId with all the batched keys.
```
const loaderKey = `${gqlTypeName}-${relatedField}-${JSON.stringify(
		filter
	)}`; /* gqlTypeName-fieldname-filterObject */
```
👆 The above code causes the `loaderKey` to be unique for each related entity instead of having a common key.

```
const loaderKey = `${gqlTypeName}-${relatedField}`; /* gqlTypeName-fieldname */
```
This makes a common key per entity and field
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.

1 participant