简体   繁体   中英

Invalid graphql request in Gentics Mesh with rest client

I get an error when executing a graph query using the MeshRestClient -

{
  "errors": [
    {
      "message": "Validation error of type InvalidFragmentType: Fragment cannot be spread here as objects of type Node can never be of type teaching @ 'node/children/elements'",
      "type": "ValidationError",
      "locations": [
        {
          "line": 1,
          "column": 288
        }
      ]
    },
    {
      "message": "Validation error of type FieldUndefined: Field 'fields' in type 'teaching' is undefined @ 'node/children/elements/fields'",
      "type": "ValidationError",
      "locations": [
        {
          "line": 1,
          "column": 315
        }
      ]
    }
  ]
}

Although the same request works fine in Postman.

Update : I realized the client is executing the request against the /api/v1 when using the client.
If I post the same query against /api/v1 in Postman, I can reproduce the error.

I think if I can force the rest client to use /api/v2 , it should work..

You can use /api/v2 with the MeshRestClient by setting the base path when creating the client:

MeshRestClient.create(MeshRestClientConfig.newConfig()
    .setHost("demo.getmesh.io")
    .setPort(80)
    .setSsl(true)
    .setBasePath("/api/v2")
    .build());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM