paypal / mocca

Mocca is a GraphQL client for JVM languages with the goal of being easy to use, flexible and modular.
MIT License
15 stars 14 forks source link

how to consume the GraphQL API of dgraph ? #67

Closed iRobinZ closed 2 years ago

iRobinZ commented 2 years ago

the endpoint is : http://localhost:8080/graphql first use PostMan check the API that is works.

request query:
query { getNode(id:"0x44") { id name parts { name, self{ id, name, parts{ name } } } } }

response: { "data": { "getNode": { "id": "0x44", "name": "Java", "parts": [] } }, "extensions": { "touched_uids": 5, "tracing": { "version": 1, "startTime": "2022-05-03T08:56:05.5613423Z", "endTime": "2022-05-03T08:56:05.7657608Z", "duration": 204418300, "execution": { "resolvers": [ { "path": [ "getNode" ], "parentType": "Query", "fieldName": "getNode", "returnType": "Node", "startOffset": 33556300, "duration": 170805800, "dgraph": [ { "label": "query", "startOffset": 35370200, "duration": 168979200 } ] } ] } } } }

the try consume the API from mocca , defined POJO class : class Node{ private String id; private String name; private String title; }

and client : @Query @SelectionSet("{id, name}") Node getNode(@Var("id") String id);

then call it .... , but throw error that looks relative to class 'MoccaFeignDecoder' , it show method 'decode' is failed.

I was wondering if mocca support DGraph API now or some step I missed ? thanks help !

iRobinZ commented 2 years ago

got reason ...

the POJO class should provide set/get property method ... or apply '@Data' Annotation