GraphQL

Serving a SunSpec (Modbus TCP) device over GraphQL

For SunSpec a very simple to use docker image is available that allows you to create a (read only) GraphQL interface around any SunSpec device.

Just create a docker compose config which provides the modbus parameters to connect to it (i.e. hostname, port and unitid) like this.

docker-compose.yml
services:
  sunspec-graphql:
    image: nielsbasjes/sunspec-graphql:latest
    command: '--sunspec.host=sunspec.iot.basjes.nl --sunspec.port=502 --sunspec.unit=126'
    ports:
      - 8080:8080

Or run it directly on the commandline with something like this:

sudo docker run -p8080:8080 nielsbasjes/sunspec-graphql:latest --sunspec.host=sunspec.iot.basjes.nl  --sunspec.port=502  --sunspec.unit=126

When you run this you’ll get a GraphiQL UI at http://localhost:8080

For more information have a look at the GraphQL page.