pax_global_header 0000666 0000000 0000000 00000000064 14171626705 0014523 g ustar 00root root 0000000 0000000 52 comment=eae31ca73eb3473c544710955d1dbebc22605bfe
graphql-go-1.3.0/ 0000775 0000000 0000000 00000000000 14171626705 0013565 5 ustar 00root root 0000000 0000000 graphql-go-1.3.0/.gitignore 0000664 0000000 0000000 00000000154 14171626705 0015555 0 ustar 00root root 0000000 0000000 /.idea
/.vscode
/internal/validation/testdata/graphql-js
/internal/validation/testdata/node_modules
/vendor
graphql-go-1.3.0/.golangci.yml 0000664 0000000 0000000 00000001015 14171626705 0016146 0 ustar 00root root 0000000 0000000 run:
timeout: 5m
linters-settings:
gofmt:
simplify: true
govet:
check-shadowing: true
enable-all: true
disable:
- fieldalignment
- deepequalerrors # remove later
linters:
disable-all: true
enable:
- deadcode
- gofmt
- gosimple
- govet
- ineffassign
- exportloopref
- structcheck
- staticcheck
- unconvert
- unused
- varcheck
- misspell
- goimports
issues:
exclude-rules:
- linters:
- unused
path: "graphql_test.go" graphql-go-1.3.0/.semaphore/ 0000775 0000000 0000000 00000000000 14171626705 0015626 5 ustar 00root root 0000000 0000000 graphql-go-1.3.0/.semaphore/semaphore.yml 0000664 0000000 0000000 00000001362 14171626705 0020336 0 ustar 00root root 0000000 0000000 version: v1.0
name: Go
agent:
machine:
type: e1-standard-2
os_image: ubuntu2004
blocks:
- name: Style Check
task:
jobs:
- name: fmt
commands:
- sem-version go 1.17
- checkout
- ./scripts/golangci_install.sh -b $(go env GOPATH)/bin v1.42.1
- export PATH=$(go env GOPATH)/bin:$PATH
- golangci-lint run ./...
- name: Test & Build
task:
prologue:
commands:
- sem-version go 1.17
- export PATH=$(go env GOPATH)/bin:$PATH
- checkout
- go version
jobs:
- name: Test
commands:
- go test ./...
- name: Build
commands:
- go build -v .
graphql-go-1.3.0/CHANGELOG.md 0000664 0000000 0000000 00000001004 14171626705 0015371 0 ustar 00root root 0000000 0000000 CHANGELOG
[v1.1.0](https://github.com/graph-gophers/graphql-go/releases/tag/v1.1.0) Release v1.1.0
* [FEATURE] Add types package #437
* [FEATURE] Expose `packer.Unmarshaler` as `decode.Unmarshaler` to the public #450
* [FEATURE] Add location fields to type definitions #454
* [FEATURE] `errors.Errorf` preserves original error similar to `fmt.Errorf` #456
* [BUGFIX] Fix duplicated __typename in response (fixes #369) #443
[v1.0.0](https://github.com/graph-gophers/graphql-go/releases/tag/v1.0.0) Initial release
graphql-go-1.3.0/CONTRIBUTING.md 0000664 0000000 0000000 00000001156 14171626705 0016021 0 ustar 00root root 0000000 0000000 ## Contributing
- With issues:
- Use the search tool before opening a new issue.
- Please provide source code and commit sha if you found a bug.
- Review existing issues and provide feedback or react to them.
- With pull requests:
- Open your pull request against `master`
- Your pull request should have no more than two commits, if not you should squash them.
- It should pass all tests in the available continuous integrations systems such as TravisCI.
- You should add/modify tests to cover your proposed code changes.
- If your pull request contains a new feature, please document it on the README. graphql-go-1.3.0/LICENSE 0000664 0000000 0000000 00000002417 14171626705 0014576 0 ustar 00root root 0000000 0000000 Copyright (c) 2016 Richard Musiol. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
graphql-go-1.3.0/README.md 0000664 0000000 0000000 00000013307 14171626705 0015050 0 ustar 00root root 0000000 0000000 # graphql-go [](https://sourcegraph.com/github.com/graph-gophers/graphql-go?badge) [](https://graph-gophers.semaphoreci.com/projects/graphql-go) [](https://godoc.org/github.com/graph-gophers/graphql-go)

The goal of this project is to provide full support of the [GraphQL draft specification](https://facebook.github.io/graphql/draft) with a set of idiomatic, easy to use Go packages.
While still under heavy development (`internal` APIs are almost certainly subject to change), this library is
safe for production use.
## Features
- minimal API
- support for `context.Context`
- support for the `OpenTracing` standard
- schema type-checking against resolvers
- resolvers are matched to the schema based on method sets (can resolve a GraphQL schema with a Go interface or Go struct).
- handles panics in resolvers
- parallel execution of resolvers
- subscriptions
- [sample WS transport](https://github.com/graph-gophers/graphql-transport-ws)
## Roadmap
We're trying out the GitHub Project feature to manage `graphql-go`'s [development roadmap](https://github.com/graph-gophers/graphql-go/projects/1).
Feedback is welcome and appreciated.
## (Some) Documentation
### Basic Sample
```go
package main
import (
"log"
"net/http"
graphql "github.com/graph-gophers/graphql-go"
"github.com/graph-gophers/graphql-go/relay"
)
type query struct{}
func (_ *query) Hello() string { return "Hello, world!" }
func main() {
s := `
type Query {
hello: String!
}
`
schema := graphql.MustParseSchema(s, &query{})
http.Handle("/query", &relay.Handler{Schema: schema})
log.Fatal(http.ListenAndServe(":8080", nil))
}
```
To test:
```sh
curl -XPOST -d '{"query": "{ hello }"}' localhost:8080/query
```
### Resolvers
A resolver must have one method or field for each field of the GraphQL type it resolves. The method or field name has to be [exported](https://golang.org/ref/spec#Exported_identifiers) and match the schema's field's name in a non-case-sensitive way.
You can use struct fields as resolvers by using `SchemaOpt: UseFieldResolvers()`. For example,
```
opts := []graphql.SchemaOpt{graphql.UseFieldResolvers()}
schema := graphql.MustParseSchema(s, &query{}, opts...)
```
When using `UseFieldResolvers` schema option, a struct field will be used *only* when:
- there is no method for a struct field
- a struct field does not implement an interface method
- a struct field does not have arguments
The method has up to two arguments:
- Optional `context.Context` argument.
- Mandatory `*struct { ... }` argument if the corresponding GraphQL field has arguments. The names of the struct fields have to be [exported](https://golang.org/ref/spec#Exported_identifiers) and have to match the names of the GraphQL arguments in a non-case-sensitive way.
The method has up to two results:
- The GraphQL field's value as determined by the resolver.
- Optional `error` result.
Example for a simple resolver method:
```go
func (r *helloWorldResolver) Hello() string {
return "Hello world!"
}
```
The following signature is also allowed:
```go
func (r *helloWorldResolver) Hello(ctx context.Context) (string, error) {
return "Hello world!", nil
}
```
### Schema Options
- `UseStringDescriptions()` enables the usage of double quoted and triple quoted. When this is not enabled, comments are parsed as descriptions instead.
- `UseFieldResolvers()` specifies whether to use struct field resolvers.
- `MaxDepth(n int)` specifies the maximum field nesting depth in a query. The default is 0 which disables max depth checking.
- `MaxParallelism(n int)` specifies the maximum number of resolvers per request allowed to run in parallel. The default is 10.
- `Tracer(tracer trace.Tracer)` is used to trace queries and fields. It defaults to `trace.OpenTracingTracer`.
- `ValidationTracer(tracer trace.ValidationTracer)` is used to trace validation errors. It defaults to `trace.NoopValidationTracer`.
- `Logger(logger log.Logger)` is used to log panics during query execution. It defaults to `exec.DefaultLogger`.
- `PanicHandler(panicHandler errors.PanicHandler)` is used to transform panics into errors during query execution. It defaults to `errors.DefaultPanicHandler`.
- `DisableIntrospection()` disables introspection queries.
### Custom Errors
Errors returned by resolvers can include custom extensions by implementing the `ResolverError` interface:
```go
type ResolverError interface {
error
Extensions() map[string]interface{}
}
```
Example of a simple custom error:
```go
type droidNotFoundError struct {
Code string `json:"code"`
Message string `json:"message"`
}
func (e droidNotFoundError) Error() string {
return fmt.Sprintf("error [%s]: %s", e.Code, e.Message)
}
func (e droidNotFoundError) Extensions() map[string]interface{} {
return map[string]interface{}{
"code": e.Code,
"message": e.Message,
}
}
```
Which could produce a GraphQL error such as:
```go
{
"errors": [
{
"message": "error [NotFound]: This is not the droid you are looking for",
"path": [
"droid"
],
"extensions": {
"code": "NotFound",
"message": "This is not the droid you are looking for"
}
}
],
"data": null
}
```
### [Examples](https://github.com/graph-gophers/graphql-go/wiki/Examples)
### [Companies that use this library](https://github.com/graph-gophers/graphql-go/wiki/Users)
graphql-go-1.3.0/decode/ 0000775 0000000 0000000 00000000000 14171626705 0015010 5 ustar 00root root 0000000 0000000 graphql-go-1.3.0/decode/decode.go 0000664 0000000 0000000 00000000757 14171626705 0016573 0 ustar 00root root 0000000 0000000 package decode
// Unmarshaler defines the api of Go types mapped to custom GraphQL scalar types
type Unmarshaler interface {
// ImplementsGraphQLType maps the implementing custom Go type
// to the GraphQL scalar type in the schema.
ImplementsGraphQLType(name string) bool
// UnmarshalGraphQL is the custom unmarshaler for the implementing type
//
// This function will be called whenever you use the
// custom GraphQL scalar type as an input
UnmarshalGraphQL(input interface{}) error
}
graphql-go-1.3.0/docs/ 0000775 0000000 0000000 00000000000 14171626705 0014515 5 ustar 00root root 0000000 0000000 graphql-go-1.3.0/docs/img/ 0000775 0000000 0000000 00000000000 14171626705 0015271 5 ustar 00root root 0000000 0000000 graphql-go-1.3.0/docs/img/logo.png 0000664 0000000 0000000 00000172177 14171626705 0016756 0 ustar 00root root 0000000 0000000 PNG
IHDR , ʽ sRGB pHYs =iTXtXML:com.adobe.xmp
2018:04:05 21:04:08
2018-03-28T15:56:49-04:00
2018-04-04T21:59:28-04:00
Pixelmator 3.7
adobe:docid:photoshop:5563f4c0-3874-11e8-a9f6-8d6dce19aad7
xmp.did:7c134ef2-c9d9-a04a-8074-010bf2d714fe
xmp.iid:3a473a35-1b61-7548-b8c1-d37321342166
xmp.iid:2cea00a6-7265-0d42-8fa8-49801ffc3443
Adobe Photoshop CC 2017 (Windows)
2018-03-28T15:56:49-04:00
xmp.iid:7c134ef2-c9d9-a04a-8074-010bf2d714fe
created
Adobe Photoshop CC 2017 (Windows)
/
2018-03-28T16:01:58-04:00
xmp.iid:72410e7c-2c06-c54b-aa85-be4234c69957
saved
Adobe Photoshop CC 2017 (Windows)
/
2018-04-04T21:59:28-04:00
xmp.iid:3a473a35-1b61-7548-b8c1-d37321342166
saved
converted
from application/vnd.adobe.photoshop to image/png
derived
converted from application/vnd.adobe.photoshop to image/png
Adobe Photoshop CC 2017 (Windows)
/
2018-04-04T21:59:28-04:00
xmp.iid:2cea00a6-7265-0d42-8fa8-49801ffc3443
saved
adobe:docid:photoshop:ea9698db-3874-11e8-a9f6-8d6dce19aad7
xmp.did:7c134ef2-c9d9-a04a-8074-010bf2d714fe
300
229
1
image/png
72
5
2
1
72
sRGB IEC61966-2.1
adobe:docid:photoshop:a6ba20b8-337c-11e8-9a61-a538f610f253
xmp.did:ac00a4cc-1034-4276-87d5-15fd99ebc41b
3
(Q @ IDATx]ˑK3 9IߏbF>bYTD%$|䜹zoٙݻ#+=vBOOOOOuU*?2B۷4QQQ#q?)++vhhhի~ᇩ?ca4Ҋ@zys1Ȥի(55.ϯƅOO>>MS<((ʕ+ܽ{w;^b*zJ_~yH0`