Hacker News new | ask | show | jobs
by theswan 3048 days ago
At Samsara our golang graphql implementation (https://github.com/samsarahq/thunder) works this way. We write out resolver functions using plain old go types and use some reflection magic at startup to compute the graphql type information.

Our docs are a bit spare at the moment, but this means with code like:

  type User struct {
    Id int64
    Name string
  }

  func rootUser(ctx context.Context, args struct { id int64 }) (*User, error) {
    // ...
  }

  schemaRoot.FieldFunc("user", rootUser);
We can derive the graphql SDL types automatically (looking at the arguments and return values) and use them with other graphql tooling, but it saves folks time from writing out a separate schema and keeping it in sync.