Skip to content

Latest commit

 

History

History

graphql-go

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

graphql-go

Introduction

This example shows how to use graphql-go in hertz server.

Usage

  • Start server
go run main.go
  • Test
  • Use curl to send a request
curl -X POST 'http://localhost:9090/' --header 'content-type: application/json' --data-raw '{"query":"query{hello}"}'

Result:

> curl -X POST 'http://localhost:9090/' --header 'content-type: application/json' --data-raw '{"query":"query{hello}"}'
{"data":{"hello":"world"}}
curl 'http://localhost:9090/?query=query%7Bhello%7D'

Result:

> curl 'http://localhost:9090/?query=query%7Bhello%7D'
{"data":{"hello":"world"}}
query {
  hello
}
{
  "data": {
    "hello": "world"
  }
}

Warning

We do not recommend using gqlgen in hertz. Because adapting the Go standard library http.Handler and http.HandlerFunc methods results in a performance hit.