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

Updating fails when an object with has a relationship in 'camelCase' #199

Open
dcantu96 opened this issue Aug 8, 2019 · 1 comment
Open

Comments

@dcantu96
Copy link

dcantu96 commented Aug 8, 2019

Im trying to do this

await jsonApi.update("match", {
    id: this.match.id,
    date: date,
    homeTeam: { id: homeTeam.id },
    visitTeam: { id: visitTeam.id },
    tournament: { id: tournament.id }
});

It returns a bad request because homeTeam is serialized to "homeTeam" not "home-team" like it should be.

I tried this with postman and it worked as expected.

{ "data": { "id": 1, "type": "matches", "attributes": { "date": "2019-08-12T11:40:57.747-09:00" }, "relationships": { "home-team": { "data": { "type": "teams", "id": 5 } } } } }

What am I doing wrong?
Thanks ❤️

@Auspicus
Copy link
Collaborator

@dcantu96 I'm not sure if we're translating camelCase names to kebab-case names automatically anymore since we've run into several issues with that and it's hard to make it consistently perform as expected across all JSON:API implementations. Are you able to do something like:

await jsonApi.update("match", {
    id: this.match.id,
    date: date,
    'home-team': { id: homeTeam.id },
    'visit-team': { id: visitTeam.id },
    tournament: { id: tournament.id }
});

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

2 participants