Pro Yearly is on sale from $80 to $50! »

TECHPULSE 2019 - Go-ing GraphQL in LINE SPOT API Gateway for Microservices

TECHPULSE 2019 - Go-ing GraphQL in LINE SPOT API Gateway for Microservices

BY Denny Tsai@LINE TECHPULSE 2019 https://techpulse.line.me/

2102a6b8760bd6f57f672805723dd83a?s=128

line_developers_tw

December 04, 2019
Tweet

Transcript

  1. None
  2. > Denny Tsai / UIT, LINE Taiwan Go-ing GraphQL in

    LINE SPOT API Gateway for Microservices
  3. About Me Role Front-End Team LINE SPOT From LINE Taiwan

  4. LINE SPOT Location-Based Points of Interests and Services >date/november 20-21

    >place/grand nikko tokyo
  5. API Gateway

  6. Clients to Microservices Service A Service B Service C Service

    D
  7. Clients to API Gateway Service A Service B Service C

    Service D API Gateway
  8. GraphQL

  9. What is GraphQL Single Endpoint (HTTP) Typed Schema Transport Agnostic

    Consumer Centric Data Graph
  10. GitHub API v3 (REST API) GraphQL vs REST https://api.github.com/repos/golang/go/issues [

    { "url": "https://api.github.com/repos/golang/go/issues/31459", "number": 31459, "title": "cmd/link: Apple's symbols tool unable to read DWARF data from c-archive go.o", "user": { "login": "tmm1", "avatar_url": "https://avatars2.githubusercontent.com/u/2567?v=4", }, "state": "open" }, { "url": "https://api.github.com/repos/golang/go/issues/31458", "number": 31458, "title": "cmd/go: mod meta tag causes infinite loop in GOPROXY", "user": { "login": "marwan-at-work", "avatar_url": "https://avatars0.githubusercontent.com/u/16294261?v=4",
  11. GitHub API v4 (GraphQL API) GraphQL vs REST Add your

    text here Whatever it is you want to message your friend, you will find the sticker that expresses your feelings best, like nothing else available in the market. Add your text here Whatever it is you want to message your friend, you will find the sticker that expresses your feelings best, like nothing else available in the market. { repository( owner: "golang" name: "go" ) { name issues( first: 2 orderBy: { field: CREATED_AT direction: DESC } ) { totalCount nodes { number title } } } } { "data": { "repository": { "name": "go", "issues": { "totalCount": 30761, "nodes": [ { "number": 31459, "title": "cmd/link: Apple's symbols tool ..." }, { "number": 31458, "title": "cmd/go: mod meta tag causes ..." } ] } } } }
  12. GraphQL x Go

  13. Go GraphQL Libraries github.com/graphql-go/graphql code first github.com/99designs/gqlgen schema + codegen

    github.com/graph-gophers/graphql-go schema first
  14. Go GraphQL Libraries github.com/graphql-go/graphql code first github.com/99designs/gqlgen schema + codegen

    github.com/graph-gophers/graphql-go schema first
  15. Define Schema with SDL Create a schema type Query {

    posts: [Post] post(id: Int!): Post } type Post { id: Int! title: String! body: String! }
  16. Generated Models Generated models type Post struct { ID int

    `json:"id"` Title string `json:"title"` Body string `json:"body"` }
  17. Generated Resolver Interface Resolver Interface type QueryResolver interface { Posts(ctx

    context.Context) ([]*Post, error) Post(ctx context.Context, id int) (*Post, error) }
  18. Implement Resolvers Resolvers type Resolver struct{} func (r *Resolver) Query()

    QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } func (r *queryResolver) Posts(ctx context.Context) ([]*Post, error) { panic("not implemented") } func (r *queryResolver) Post(ctx context.Context, id int) (*Post, error) { panic("not implemented") }
  19. Create a Server c := Config{ Resolvers: &Resolver{} } http.Handle("/graphql",

    handler.GraphQL(NewExecutableSchema(c))
  20. Thank You