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

Resource Creation: Server-Side generated ID's #23

Open
chris-doehring opened this issue Apr 16, 2020 · 1 comment
Open

Resource Creation: Server-Side generated ID's #23

chris-doehring opened this issue Apr 16, 2020 · 1 comment

Comments

@chris-doehring
Copy link

chris-doehring commented Apr 16, 2020

Hi,

The JSON:API protocol accepts both server and client side generated resource IDs. This implements, that a resource id can be left out when executing the create resource request (see the protocol docs for reference).

Unfortunately, the ResourceInterface expects the ID to be a string, so the only solution for a server-side generated ID would be to submit an empty ID string. In my case this breaks the server-side validation, as the server correctly assumes a non-existing id resource member.

I guess the only correct solution would be to make the id function nullable in the ResourceInterface, which will break other stuff. I must find another temporary solution for this in order to proceed without adjusting the server-side validation.

Are there any plans to support the server-side generated ID's in this package? Thanks in advance!

@chris-doehring
Copy link
Author

I was able to find a workaround by creating a custom Serializer which removes empty IDs from the resources, but that's not an ideal solution.

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