# Can't get GraphQL working for tree and singleton

**URL:** <https://discourse.getcockpit.com/t/cant-get-graphql-working-for-tree-and-singleton/2649>\
**Category:** Cockpit v2\
**Created:** [December 27, 2022, 5:05pm UTC](https://discourse.getcockpit.com/t/cant-get-graphql-working-for-tree-and-singleton/2649 "2022-12-27T17:05:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![letima](https://avatars.discourse-cdn.com/v4/letter/l/9e8a1a/32.png) [@letima](https://discourse.getcockpit.com/u/letima)\
**Post date:** [December 27, 2022, 5:05pm UTC](https://discourse.getcockpit.com/t/cant-get-graphql-working-for-tree-and-singleton/2649/1 "2022-12-27T17:05:38Z")

</div>

I would like to use GraphQL to query elements in the playground (By the way: is there any documentation how to authorize with GraphQL). If I use an API key in the playground, I only get an “Internal Server Error” with Singleton and Tree. Collections work fine.  
If I omit the API key then I get empty objects back.

My JSON:

```auto
{
  SeitenModel {
    _id
    _created
    _modified
    Menuetitle
    Seitentitel
    Permalink
    Keywords
  }
}

```

I get:

```auto
{
  "errors": [
    {
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 6,
          "column": 2
        }
      ],
      "path": [
        "SeitenModel",
        0,
        "Menuetitle"
      ]
    },
    {
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 6,
          "column": 2
        }
      ],
      "path": [
        "SeitenModel",
        1,
        "Menuetitle"
      ]
    },
    {
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 6,
          "column": 2
        }
      ],
      "path": [
        "SeitenModel",
        2,
        "Menuetitle"
      ]
    },
    {
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 6,
          "column": 2
        }
      ],
      "path": [
        "SeitenModel",
        3,
        "Menuetitle"
      ]
    },
    {
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 6,
          "column": 2
        }
      ],
      "path": [
        "SeitenModel",
        4,
        "Menuetitle"
      ]
    }
  ],
  "data": {
    "SeitenModel": [
      null,
      null,
      null,
      null,
      null
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![letima](https://avatars.discourse-cdn.com/v4/letter/l/9e8a1a/32.png) [@letima](https://discourse.getcockpit.com/u/letima)\
**Post date:** [December 28, 2022, 1:16pm UTC](https://discourse.getcockpit.com/t/cant-get-graphql-working-for-tree-and-singleton/2649/2 "2022-12-28T13:16:44Z")

</div>

I’ve now tried it outside of the playground (a query via PHP and curl). Also here I get an internal server error.  
As I said, I get everything clean via the REST API, with GraphQL only collections work properly. Unfortunately, I can’t find any errors either - neither in my script (there’s not much there) nor in Cockpit.  
The error message (extension and location) doesn’t really help me.

EDIT: I got it worked on Singleton also. For another tree I get an empty object nevertheless I added items in the backend.

---

<div class="post-metadata">

**Author:** ![faridbouchdak](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/faridbouchdak/32/1132_2.png) [@faridbouchdak](https://discourse.getcockpit.com/u/faridbouchdak)\
**Post date:** [December 29, 2022, 9:47am UTC](https://discourse.getcockpit.com/t/cant-get-graphql-working-for-tree-and-singleton/2649/3 "2022-12-29T09:47:05Z")

</div>

I can’t reproduce your errors.  
Tree-collection:

 ![CleanShot 2022-12-29 at 10.31.59@2x](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/2X/1/111954ecd5524f138baeb59d54d09a3e19e28cee.png)

 ![CleanShot 2022-12-29 at 10.32.33@2x](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/2X/1/1472551a17aa204449f7590d963bb476dc728b06.png)

GraphQl:

 ![CleanShot 2022-12-29 at 10.38.56@2x](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/2X/a/a83eea2413bcda8f872fef2bf2b0e9dbd2055ad3.png)

Singleton:

 ![CleanShot 2022-12-29 at 10.38.29@2x](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/2X/2/2d9883215dc2e480c5d7ea2a4d058f27c22581af.png)

Both are with API-key:

 ![CleanShot 2022-12-29 at 10.43.34@2x](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/2X/e/e29c727881b5622ecf8189f3d6677f0b8e75379a.png)

Make sure you give the role that contains the API-key the right permissions and that the items are published.

 ![CleanShot 2022-12-29 at 10.45.15@2x](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/2X/e/ee95a1d60b436ce6d5e8c64adddd810678cb25db.png)
