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

Singleton `get` doesn't return `fields` #857

Open
andrewn opened this issue Sep 11, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@andrewn
Copy link

commented Sep 11, 2018

#856 was about returning a singleton's schema via an endpoint but /api/collections/get/{name} also returns the schema in the response.

Would it make sense for /api/singletons/get/{name} to return the a _fields property containing the schema? I guess it couldn't be called fields as it might conflict with a user-defined field named fields 😕.

For example /api/collections/get/{name} returns the fields and entries:

{
  "fields": {
    "title": {
      "name": "title",
      "type": "text",
      "localize": false,
      "options": []
    },
    "images": {
      "name": "images",
      "type": "gallery",
      "localize": false,
      "options": []
    }
  },
  "entries": [
    {
      "title": "abc",
      "images": [
        {
          "meta": { "title": "", "asset": "5b98385430323600140000c0" },
          "path":
            "/storage/uploads/2018/09/11/5b983854e3bb316072013_proto_manifesto_UH.jpeg"
        }
      ],
      "_mby": "5b98380730323600100002b3",
      "_by": "5b98380730323600100002b3",
      "_modified": 1536705671,
      "_created": 1536705671,
      "_id": "5b984487303236001400002e"
    }
  ],
  "total": 1
}

but /api/singletons/get/{name} doesn't return the fields:

{
  "title": null,
  "images": [
    {
      "meta": { "title": "", "asset": "5b98385430323600140000c0" },
      "path":
        "/storage/uploads/2018/09/11/5b983854e3bb316072013_proto_manifesto_UH.jpeg"
    }
  ],
  "_mby": "5b98380730323600100002b3",
  "_by": "5b98380730323600100002b3"
}
@gryphonmyers

This comment has been minimized.

Copy link

commented Sep 11, 2018

Yes unfortunately with the data at the top level, we lose the ability to attach metadata. I think this is why specs like jsonapi advise storing the payload in a "data" member.

@WhippetsAintDogs

This comment has been minimized.

Copy link

commented Jan 2, 2019

Hi, adding such metadata could be useful for our GatsbyJS source plugin as well.

fikaproductions/fika-gatsby-source-cockpit#4

EDIT: Nevermind, I just found the new /api/singletons/singleton/{singletonname} endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.