httpdynamic

command
v0.7.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2019 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Basically, if we have data.json like this:

[
  { "id": "1", "name": "Dan" },
  { "id": "2", "name": "Lee" },
  { "id": "3", "name": "Nick" }
]

... and go run main.go, we can query records:

$ curl -g 'http://localhost:8080/graphql?query={user(name:"Dan"){id}}'
{"data":{"user":{"id":"1"}}}

... now let's give Dan a surname:

[
  { "id": "1", "name": "Dan", "surname": "Jones" },
  { "id": "2", "name": "Lee" },
  { "id": "3", "name": "Nick" }
]

... and kick the server:

kill -SIGUSR1 52114

And ask for Dan's surname:

$ curl -g 'http://localhost:8080/graphql?query={user(name:"Dan"){id,surname}}'
{"data":{"user":{"id":"1","surname":"Jones"}}}

... or ask Jones's name and ID:

$ curl -g 'http://localhost:8080/graphql?query={user(surname:"Jones"){id,name}}'
{"data":{"user":{"id":"1","name":"Dan"}}}

If you look at main.go, the file is not field-aware. That is, all it knows is how to work with []map[string]string type.

With this, we are not that far from exposing dynamic fields and filters which fully depend on what we have stored, all without changing our tooling.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL