shahidhk / gql

A (WIP) client library for GraphQL written in Go with codegen for GraphQL types

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gql

A (WIP) client library for GraphQL written in Go with codegen for GraphQL types

package main

import (
    "fmt"
    "log"

	"github.com/shahidhk/gql"
)

type Author struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}
type Authors struct {
	Authors []Authors `json:"authors"`
}

func main() {
	client := gql.NewClient("http://localhost:8080/v1/graphql", nil)
	var authors Authors
	err := client.Execute(gql.Request{Query: `query { authors {id name}}`}, &authors)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(authors)
}

About

A (WIP) client library for GraphQL written in Go with codegen for GraphQL types

License:MIT License


Languages

Language:Go 100.0%