elide icon indicating copy to clipboard operation
elide copied to clipboard

Atomic operations don't support non-root entities creation

Open HassanAzzam opened this issue 8 months ago • 0 comments

Expected Behavior

To create child/non-root entity and assign it to parent/root entity with one request.

Usually posting child entity to /parent/{parentId}/children creates and assigns the child to the parent.

I'm expecting the same when using atomic operations, to have the parent and the children created and assigned by passing the following JSON body:

{
	"atomic:operations": [
		{
			"op": "add",
			"href": "/parent",
			"data": {
				"type": "parent",
				"lid": "12345678-1234-1234-1234-1234567890ab",
				"attributes": {
					...
				}
			}
		},
		{
			"op": "add",
			"ref": {
				"type": "parent",
				"lid": "12345678-1234-1234-1234-1234567890ab",
				"relationship": "children"
			},
			"data": {
				"type": "child",
				"attributes": {
					...
				}
			}
		},
		{
			"op": "add",
			"ref": {
				"type": "parent",
				"lid": "12345678-1234-1234-1234-1234567890ab",
				"relationship": "children"
			},
			"data": {
				"type": "child",
				"attributes": {
					...
				}
			}
		}
	]
}

Current Behavior

Currently, I get this error response:

[
    {
        "errors": [
            {
                "detail": "Subsequent operation failed."
            }
        ]
    },
    {
        "errors": [
            {
                "detail": "Unknown identifier null for child",
                "status": "404"
            }
        ]
    },
    {
        "errors": [
            {
                "detail": "Operation not executed. Terminated by earlier failure."
            }
        ]
    }
]

Possible Solution

Steps to Reproduce (for bugs)

1- Have a parent class with rootLevel = true. 2- Have a child class with rootLevel = false. 3- Have a one-to-many relationship between parent and child. 4- Try to persist the parent and its children in one request using atomic operations(create entities and relate them).

Context

I'm trying to persist entities with non-root level alongside their parent in the same request using atomic operations.

Your Environment

  • Elide version used: 7.0.4
  • Environment name and version (Java 1.8.0_152): Java 17
  • Operating System and version: MacOS 14.2.1

HassanAzzam avatar Jun 14 '24 08:06 HassanAzzam