GithubHelp home page GithubHelp logo

Comments (3)

lode avatar lode commented on May 29, 2024

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 a data 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.

jelhan avatar jelhan commented on May 29, 2024

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.

FranzDeschler avatar FranzDeschler commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.