lecle / aloxide

Aloxide is a pragmatic abstraction layer for various blockchain softwares.
Apache License 2.0
10 stars 5 forks source link

createdAt and updatedAt which are available on REST aren't available on GraphQL #119

Open flowersinthesand opened 4 years ago

flowersinthesand commented 4 years ago

Using example-api-gateway I found that items returned by REST API have createdAt and updatedAt value.

➜  example-api-gateway git:(master) ✗ curl http://localhost:4000/api-gateway/polls\?limit\=2\&after\=0         {"total":37,"items":[{"id":"1","name":"Dynamic Configuration Agent","body":"Et odit ullam nam ut. Totam quia deleniti quia. Omnis voluptas quidem dolorum officia est harum culpa.","createdAt":"2020-11-10T04:58:15.980Z","updatedAt":"2020-11-10T04:58:15.980Z"},{"id":"2","name":"Internal Paradigm Officer","body":"Ratione itaque nam eum tenetur architecto rerum dolore earum rerum. Explicabo eum mollitia qui beatae modi nihil et ipsa. Doloremque eveniet itaque nesciunt quo consectetur qui. Et nam saepe porro. Maxime autem nesciunt eum rerum iure. Hic accusamus unde atque veritatis reiciendis.","createdAt":"2020-11-10T04:58:17.974Z","updatedAt":"2020-11-10T04:58:17.974Z"}]}%                                           

However, these date values are not defined in GraphQL schema so if I include createdAt and updatedAt in a GraphQL query it throws the following error:

➜  example-api-gateway git:(master) ✗ curl --request POST --header "Content-Type: application/json" --data '{"query":"{queryPoll(first: 25) {edges {node {id name body createdAt updatedAt}}}}"}' http://localhost:4000/graphql

{"errors":[{"message":"Cannot query field \"createdAt\" on type \"Poll\".","locations":[{"line":1,"column":50}]},{"message":"Cannot query field \"updatedAt\" on type \"Poll\".","locations":[{"line":1,"column":60}]}]}

Personally I prefer to add createdAt and updatedAt fields to GraphQL interface too for convenience.