Skip to content
This repository has been archived by the owner on Mar 15, 2019. It is now read-only.

Den Endpunkt /resources/ids durch fields[TYPE] ersetzen #99

Open
kremer-io opened this issue Sep 26, 2017 · 16 comments
Open

Den Endpunkt /resources/ids durch fields[TYPE] ersetzen #99

kremer-io opened this issue Sep 26, 2017 · 16 comments
Assignees

Comments

@kremer-io
Copy link
Contributor

JSON-API bietet folgende Möglichkeit: http://jsonapi.org/format/#fetching-sparse-fieldsets

A client MAY request that an endpoint return only specific fields in the response on a per-type basis by including a fields[TYPE] parameter.

The value of the fields parameter MUST be a comma-separated (U+002C COMMA, “,”) list that refers to the name(s) of the fields to be returned.

If a client requests a restricted set of fields for a given resource type, an endpoint MUST NOT include additional fields in resource objects of that type in its response.

@niccokunzmann
Copy link
Contributor

Die id ist nicht Teil der attributes sondern im data feld neben type und attributes. Operiert fields aber nur auf attributes?
Welches Problem möchtest du lösen? Welche Nutzung soll erfolgen, die so nicht möglich ist?

@kremer-io
Copy link
Contributor Author

Die Spezifikation spricht ja nicht von attributes, sondern fields. Bzgl. des Problems: Die Route fühlt sich nicht RESTful an und könnte auf die genannte Weise (aus meiner Sicht) besser umgesetzt werden. Was ist z.B. wenn man nur die originIds haben will?

@niccokunzmann
Copy link
Contributor

niccokunzmann commented Sep 26, 2017

Also würden wir sagen, dass das die selbe Ressourcen zurück gibt:

/v1/resources/ids
/v1/resources?filter[type]=resource&fields[resource]=id

Bis auf, dass der Typ jetzt eine resource ist und keine id, sollte das gleich sein, oder?

@kremer-io
Copy link
Contributor Author

Ok, mit fields sind doch die attributes gemeint => siehe http://jsonapi.org/format/#document-resource-object-fields.

Eigentlich müsste doch das hier reichen:

/v1/resources?fields[resources]=id

Problem hier ist, dass es das id-Feld nicht in den Attributes ist. Warum soll es /resources/ids überhaupt geben?

@niccokunzmann
Copy link
Contributor

/resources/ids gibt es, um herauszufinden, welche Ressourcen der Crawler gepostet hat.

@niccokunzmann
Copy link
Contributor

/v1/resources?fields[resources]=id

Stimmt, das sollte reichen.

@kremer-io
Copy link
Contributor Author

kremer-io commented Sep 26, 2017

Warum nicht einfach /v1/resourcesdafür?

@niccokunzmann
Copy link
Contributor

Ja, aber dann müssen auch alle Attribute zurückkommen.

Fields for a resource object MUST share a common namespace with each other and with type and id. In other words, a resource can not have an attribute and relationship with the same name, nor can it have an attribute or relationship named type or id.

http://jsonapi.org/format/#document-resource-object-fields

/v1/resources?fields[resources]=id

könnte gehen, wie verstehst du das?

Ich denke aber auch, dass das gehen sollte:

/v1/resources?fields[resources]=

Dann bekommt man keine Attribute und nur die id, type und vielleicht noch links.

@kremer-io
Copy link
Contributor Author

Genau, fields leer lassen.

@niccokunzmann
Copy link
Contributor

Magst du eine Pull-Request machen?

Dann können wir das schöner machen. Bei der Resource API hatte ich noch nciht das Wissen, was ich durch die Search API erworben habe. Man kann fordern, dass /v1/resources?fields[resources]= unterstützt werden muss. Alles andere darf einen 400 error werfen.

Offene Fragen, wenn wir die Spec ausbauen wollen:

  • was ist, wenn eine Ressource das Attribut nicht beinhaltet? Scheint nicht spezifisiert zu sein.

@niccokunzmann
Copy link
Contributor

niccokunzmann commented Sep 26, 2017

Aber das ist echt viiiiiel besser als /ids.
Jetzt kann Arne auch nachsehen, z.B. indem er die Urls mit fetcht.
Danach ist noch wichtig, dass wir pagination dafür spezifisieren.

@niccokunzmann
Copy link
Contributor

@Charle42 schlägt vor, dass wir die selben Paginatonregeln bei der Search API und der Resources API anwenden.

@niccokunzmann
Copy link
Contributor

Brauchen wir hier pagination?

@kremer-io
Copy link
Contributor Author

Bzgl. Pagination extra Issue pls

@kremer-io
Copy link
Contributor Author

kremer-io commented Sep 26, 2017

Bzgl. "Was tun, wenn das ?field[]=xxx nicht vorhanden ist?": JSON-API sieht bei sorting Folgendes vor:

If the server does not support sorting as specified in the query parameter sort, it MUST return 400 Bad Request.

Würde ich für fields auch so machen.

@niccokunzmann
Copy link
Contributor

niccokunzmann commented Oct 26, 2017

Wir können nicht wissen, welche Felder noch hinzugefügt werden.
Ein Suchen nach solchen Feldern sollte möglich sein. Wenn wir dann ein 400 machen, kann es sein,
dass wir nur nach den "required" aber nicht nach den "optional" Attributen filtern können.
Ich würde sagen, dass alle Objekte, die das Feld nicht besitzen aus dem Ergebnnis rausgelassen werden: Wenn ein Feld einen Wert haben soll und das Feld nciht da ist, zählt das, als hätte es den Wert nicht.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants