Comments (3)
First on the formal part.
Rereading the spec, I don't see a ban on having
relationships.*.data.attributes
for POST/PATCH requests, so I'm going to proceed with using them until I hear a good reason not to.
On creating resources it states:
If a relationship is provided in the
relationships
member of the resource object, its value MUST be a relationship object with adata
member. The value of this key represents the linkage the new resource is to have.
Where linkage is zero or more resource identifier objects which only allow type
, id
, lid
and meta
.
On updating resources this isn't mentioned as explicit. But on updating relationships it is mentioned again that resource identifier objects should be used.
Further I feel your pain. It would be really handy if creating resource and its relationship could be done in one go.
I now often include an attribute on the primary resource which then would be passed on to the resource of the relationship:
{
"data": {
"type": "posts",
"attributes": {
"title": "Some title",
"tagNames": [
"foo", "bar"
]
}
}
}
I think the current alternative, next to the atomic extension, is to have multiple calls. I don't think that approach is very weird, but I also notice I often find myself being lazy to create that other endpoint which I wouldn't need otherwise.
from json-api.
If the Atomic Operations extension feels overly complex and your use care requires creation of resources only (not updating or deleting resources), the Bulk Create extension might be a good fit. It allows creation of multiple resources in a single, atomic request using a JSON:API document similar to compound documents.
from json-api.
Version 1.1 of the specification now allows adding specification semantics via extensions.
So from my understanding, you can define your own extension which extends the "data" object accordingly by the required fields.
from json-api.
Related Issues (20)
- Provide JSON Schema for JSON:API 1.1 HOT 2
- Provide an updates list/blog HOT 9
- 1.1 seems to contain a breaking change - 'lid' now required for resource creation? HOT 2
- How is 'lid' actually used? The 1.1 spec says nothing about this HOT 13
- Allow custom resource links HOT 13
- Why the square bracket syntax for query params? HOT 7
- consider support for implementation-specific members HOT 2
- JSON-LD integration example HOT 1
- Clarify intent of links member HOT 1
- How does one document a JSON:API HOT 4
- 1.1 spec disallows e.g. filter[author.name] HOT 4
- Inclusion of related resources for heterogeneous collections
- PrimaryResourceType not to be null at this point HOT 1
- ember-data link on implementations page is broken HOT 2
- Bulk delete as either extention or implementation HOT 4
- Extend Spec To Allow Creation of Multiple Resources in One API Call HOT 1
- Profiles should be allowed to define query parameters HOT 5
- JSONRenderer does not extract includes from PolymorphicModelSerializer properly HOT 1
- Version 1.1 is incomplete about where extension members are allowed.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-api.