Skip to content

Commit 6fb9e53

Browse files
mittalaaeloyekunlepavelnikolovMaxInertiaivanp
authored
Package update (#17)
* Support for embedded struct type in resolver * fix bug in slice pop * fix bug while finding field * add 'getFieldCount' to resolve ambiguity * Increase extensions test coverage * Remove duplicate unit tests * rename 'getFieldCount' to 'fieldCount' * add test for ambiguous field panic * add unit tests for embedded struct feature * rename TestEmbedded => TestEmbeddedStruct * Fixes graph-gophers#357 * Actually fix graph-gophers#357 * Print context to panic log * Add Example of Custom Errors Adding example and documentation for how to create custom error implementations which include `extensions` within their `error` payload * Clarify errors for mismatching input implementation Producing clearer error messages when field input arguments are implemented by code: * Which does not match the schema e.g. missing field; or * Function missing struct wrapper for field arguments * Allow `schema` to be omitted when using default root op names * Strip Common Indentation from BlockString Descriptions Multi-line descriptions need to have their common indentation level (which results from indentation of that part of the schema, rather than being intentional for the description text) removed to ensure the descriptions use the correct value, are formatted correctly etc This is to meet the condition documented in the GraphQL spec: https://graphql.github.io/graphql-spec/June2018/#sec-String-Value > Since block strings represent freeform text often used in indented > positions, the string value semantics of a block string excludes > uniform indentation and blank initial and trailing lines via > BlockStringValue(). * Syntax highlighting fixed in README * Add walkthrough Fixed small punctuation and added my walkthrough package * Update README.md * Add support for directives in schema parser * Use operationName from query if missing from POST * Fix SIGSEGV when client subs to multiple fields * bugfix: correctly determine fragment usage In previous versions of this code, this validation would exit when it encountered a fragment legitimately used twice. This bugfix skips the recursion but does not stop progress altogether allowing other fragments to be marked as used. * Limit the number of concurrent list nodes processed It uses the current capacity of the limiter as a hint as this is set based on the maxParallelism field on the schema. * Remove need for WaitGroup * More descriptive error when unmarshaling ID/Time This adds a tiny bit more information to the error messages produced when unmarshaling an input value to an ID or Time fails. * Improve README.md Fixes graph-gophers#307 Add short descriptions for different schema options. Move community examples to wiki. Add companies that use this library. * fix graph-gophers#241 Similar to graph-gophers#407, but adds test cases. * Add comment explaining why we limit concurrency * Issue graph-gophers#299: unclear error message in case of multiline string argument * handle case where interface is type-asserted to same interface * Issue graph-gophers#299: unclear error message in case of multiline strings * Issue graph-gophers#299: unclear error message in case of multiline string argument * Update logic to always check for nil pointer returns * Adding variables parameter for query validations. * Fixed `reflect.Value.Type on zero Value` panic when subscription resolver itself panicks The internal exec Subscribe method had code to deal with subscription resolver panicking when being called. But when such handling happen, the error is attached to the request object and it never checked later on. This leads to some zero checks to fail when we try to extract the type from the resolver's channel since this variable was never set. Doing this creates a second panic which is not handled and make the application die. To fix the issue, we now check if there is errors on the request object before continuing with the rest of the check, if there is errors, it's because a panic occurs and we return the response right away. * Added possibility to customize subscription resolver timeout value The previous value was hard-coded to 1 second. This is problematic for resolver that takes more time than this to return a result. When parsing the schema, it's not possible to pass a custom value for the subscription resolver timeout. Extracted from graph-gophers#317 * Allowed Subscription resolver to return `*QueryError` directly Previously, any error returned by the Subscription resolver was immediately wrapped inside its own `*QueryError` value even if the returned error was already a `*QueryError`. Now, when receiving such types, we use it as-is without wrapping again. * Adding/removing empty lines where needed * DisableIntrospection should not skip __typename for usages of GraphQL union types * Add context to validation tracing Context is needed for tracing to access the current span, in order to add tags to it, or create child spans. As presently defined (without a context), this cannot be done: new spans could be created, but they would not be associated with the existing request trace. OpenTracingTracer implements the new interface (it never implemented the old one). Via this 'extension interface', the tracer configured (or the default tracer) will be used as the validation tracer if: * The tracer implements the (optional) interface; and * A validation tracer isn't provided using the deprecated option What this means is that the deprecated option is _preferred_ as an override. This allows users to migrate in a non-breaking, non-behaviour changing way, until such time as they intentionally remove the use of the deprecated option. For those who are currently using the default tracer, and not supplying a validation tracer, validation will be traced immediately with no change required to configuration options. * Add support for nullable types This allows to differentiate between an omitted value and a null value in an input struct. * Fixed duplicated __typename in response (fixes graph-gophers#369) * Create CHANGELOG.md * Update CHANGELOG.md * ignore JetBrains IDEA and vscode meta directories * expose packer.Unmarshaler interface as graphql.Unmarshaler - add tests for graphql.Time as reference implementation * move packer.Unmarshaler interface to decode.Unmarshaler, so the methods are actually visible * add types package Part of graph-gophers#434 and related to graph-gophers#116 this change adds a new package containing all types used by graphql-go in representing the GraphQL specification. The names used in this package should match the specification as closely as possible. In order to have cohesion, all internal packages that use GraphQL types have been changed to use this new package. This change is large but mostly mechanical. I recommend starting by reading through the `types` package to build familiarity. I'll call out places in the code where I made decisions and what the tradeoffs were. * add getter for the types.Schema field This additive function shouldn't break backward compatibility will allow those who want access to the types to get at an AST version of the `types.Schema` * unused fields * rename to match types * remove unused * use a string and not an Ident for a FieldDefinition's name This was an error. When this field was renamed from schema.Field (to avoid ambiguity) its name field changed to match query.Field (to Ident). This caused a cascade of useless changes that will be rolled back in the next commit * fix compile errors introduced by ab449f0 * merge conflict errors * add location fields to type definitions * Fix dir in readme * coerce float64 to int32 in NullInt and vice versa in NullFloat * errors.Errorf preserves original error similar to fmt.Error * removed test dependency on errors.Is * checkErrors ignores the raw error for purposes of determining if the test passed or failed * Update CHANGELOG.md * internal/exec: assign parent type name to __typename fields * Accepting value Json in parameter of request's body in custom Scalar (graph-gophers#467) Accept JSON value in resolver args * Add option for custom panic handler (graph-gophers#468) Add option for custom panic handler * Tests showing query variables are validated correctly (graph-gophers#470) * README nit -- Move '$' out of cut/paste buffer (graph-gophers#473) Move '$' out of cut/paste buffer * internal/exec/resolvable: include struct field name in errors (graph-gophers#477) * internal/exec/resolvable: include struct field name in errors We were only adding method name, which meant that it was taking an empty string if the resolver was a struct field. This was making the error messages hard to parse as the user can't know which field has the error. Added a check to use the correct variable. * improve test * ci: setup SemaphoreCI v2 (graph-gophers#479) Update Semaphore configuration * Support "Interfaces Implementing Interfaces" (graph-gophers#471) Interface implementing interfaces support https://spec.graphql.org/draft/#sec-Interfaces.Interfaces-Implementing-Interfaces * README.md: Fix build status badge I broke this accidentally when removing the legacy SemaphoreCI integration. * fix golangci lint errors in the codebase (graph-gophers#478) Added a base golangci-config to the codebase to get started. Some more changes are pending, and those checks are commented out in the config. * Improve Sempahore CI (graph-gophers#481) Improve Sempahore CI build * Make some more golang-ci improvements (graph-gophers#483) * graphql.Time unmarshal unix nano time (graph-gophers#486) * validation: fix bug in maxDepth fragment spread logic (graph-gophers#492) * Create codeql-analysis.yml * Add OpenTelemetry Support (graph-gophers#493) Add OpenTelemetry tracer implementation * Improve the Getting Started section * Update README.md * Improve the Getting Started section in the README * Create SECURITY.md * Fix the OTEL tracer package name (graph-gophers#495) * Fix parseObjectDef will terminate when object has bad syntax (graph-gophers#491) (graph-gophers#500) Thank you for your contribution * Fix remove checkNilCase test helper function (graph-gophers#504) * Add graphql.Time example (graph-gophers#508) * Apollo Federation Spec: Fetch service capabilities (graph-gophers#507) Add basic support for Apollo Federation Co-authored-by: Alam <sulthan.alam@lemonilo.com> Co-authored-by: pavelnikolov <me@pavelnikolov.net> * Ignore yarn.lock file * add support for repeatable directives (graph-gophers#502) add support for repeatable directives * Fix example/social code (graph-gophers#510) The `Friends` field had higher priority than the `FriendsResolver` method. This is the reason why the field was renamed to a value, that doesn't match the GraphQL resolver. * Fix lint error (graph-gophers#512) * Refactor trace package (graph-gophers#513) Remove dependency for graphql-go on OpenTracing and OpenTelemetry except where those tracers are explicitly configured for use. * Adding in primitive value validation. (graph-gophers#515) * Update README.md * Update README.md * Improve type assertion method argument validation (require zero) (graph-gophers#516) Improve type assertion method argument validation (require zero) It's tempting to include a context argument (or think it's allowed), but not discover that this will fail until a query is executed. Validating the resolver during schema parsing reduces the chance of inadvertant errors here. Signed-off-by: Evan Owen <kainosnoema@gmail.com> * Disallow repeat of non repeatable directives (graph-gophers#525) * Disallow repeat of non repeatable directives * Remove unnecessary scallar * Added changes lost after package update * merging old prs * adding gqlerrors support * adding dev message, error code support * Readded Export query name method functionality after package update * Fix: extension initialisation and updated error method to return extension details * updated QueryError Extensions to not emit if empty --------- Signed-off-by: Evan Owen <kainosnoema@gmail.com> Co-authored-by: Elijah Oyekunle <eloyekunle@gmail.com> Co-authored-by: Pavel Nikolov <me@pavelnikolov.net> Co-authored-by: Pavel Nikolov <pavelnikolov@users.noreply.github.com> Co-authored-by: Dorian Thiessen <Dorian.thiessen@usask.ca> Co-authored-by: Ivan <ivan.petrus@kumparan.com> Co-authored-by: David Ackroyd <dackroyd@fairfaxmedia.com.au> Co-authored-by: pavemaksim <pavemaksim@gmail.com> Co-authored-by: Tony Ghita <ghita71@gmail.com> Co-authored-by: Zaydek <zaydekdotcom@gmail.com> Co-authored-by: Sylvain Cleymans <sylvain@movio.co> Co-authored-by: will@newrelic.com <will@newrelic.com> Co-authored-by: Nicolas Maquet <nicolas@movio.co> Co-authored-by: Sean Sorrell <seansorr@twitch.tv> Co-authored-by: Ryan Slade <ryanslade@gmail.com> Co-authored-by: Thorsten Ball <mrnugget@gmail.com> Co-authored-by: obei <obei.sideg@gmail.com> Co-authored-by: Quinn Slack <quinn@slack.org> Co-authored-by: suntoucha <suntoucha@gmail.com> Co-authored-by: Barry Dutton <dutbarry@justin.tv> Co-authored-by: Sebastian Motavita <Sebastian.Motavita@endava.com> Co-authored-by: Matthieu Vachon <matt@dfuse.io> Co-authored-by: Epsirom <chenhuarongzp@gmail.com> Co-authored-by: David Ackroyd <23301187+dackroyd@users.noreply.github.com> Co-authored-by: Vincent Composieux <vincent@composieux.fr> Co-authored-by: Silvio Ginter <silvio.ginter@esome.com> Co-authored-by: Sam Ko <samuko@twitch.tv> Co-authored-by: jinleileiking <jinleileiking@gmail.com> Co-authored-by: Edward Ma <edward@catch.co> Co-authored-by: Matt Ho <matt.ho@gmail.com> Co-authored-by: Tony Ghita <tony@twitch.tv> Co-authored-by: Gustavo Delfim <gusttavodelfim@gmail.com> Co-authored-by: John Starich <johnstarich@gmail.com> Co-authored-by: Florian Suess <floriansuess96@icloud.com> Co-authored-by: wejafoo <79415032+wejafoo@users.noreply.github.com> Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in> Co-authored-by: Steve Gray <steve-gray@users.noreply.github.com> Co-authored-by: Connor Vanderhook <14183191+cnnrrss@users.noreply.github.com> Co-authored-by: roaris <61813626+roaris@users.noreply.github.com> Co-authored-by: Sulthan Alam <40392850+aeramu@users.noreply.github.com> Co-authored-by: Alam <sulthan.alam@lemonilo.com> Co-authored-by: speezepearson <speezepearson@users.noreply.github.com> Co-authored-by: Dallas Phillips <dallasphillips24@gmail.com> Co-authored-by: Evan Owen <kainosnoema@gmail.com> Co-authored-by: Igor <9917165+ostrea@users.noreply.github.com> Co-authored-by: Amritansh Kumar <amritansh.kumar@tokopedia.com> Co-authored-by: kumaramritansh <105722986+kumaramritansh@users.noreply.github.com>
1 parent 36d47ba commit 6fb9e53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+7208
-1463
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/.idea
2+
/.vscode
13
/internal/validation/testdata/graphql-js
24
/internal/validation/testdata/node_modules
35
/vendor

.golangci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
run:
2+
timeout: 5m
3+
4+
linters-settings:
5+
gofmt:
6+
simplify: true
7+
govet:
8+
check-shadowing: true
9+
enable-all: true
10+
disable:
11+
- fieldalignment
12+
- deepequalerrors # remove later
13+
14+
linters:
15+
disable-all: true
16+
enable:
17+
- deadcode
18+
- gofmt
19+
- gosimple
20+
- govet
21+
- ineffassign
22+
- exportloopref
23+
- structcheck
24+
- staticcheck
25+
- unconvert
26+
- unused
27+
- varcheck
28+
- misspell
29+
- goimports
30+
31+
issues:
32+
exclude-rules:
33+
- linters:
34+
- unused
35+
path: "graphql_test.go"

.semaphore/semaphore.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: v1.0
2+
name: Go
3+
agent:
4+
machine:
5+
type: e1-standard-2
6+
os_image: ubuntu2004
7+
blocks:
8+
- name: Style Check
9+
task:
10+
jobs:
11+
- name: fmt
12+
commands:
13+
- sem-version go 1.17
14+
- checkout
15+
- ./scripts/golangci_install.sh -b $(go env GOPATH)/bin v1.42.1
16+
- export PATH=$(go env GOPATH)/bin:$PATH
17+
- golangci-lint run ./...
18+
19+
- name: Test & Build
20+
task:
21+
prologue:
22+
commands:
23+
- sem-version go 1.17
24+
- export PATH=$(go env GOPATH)/bin:$PATH
25+
- checkout
26+
- go version
27+
28+
jobs:
29+
- name: Test
30+
commands:
31+
- go test ./...
32+
33+
- name: Build
34+
commands:
35+
- go build -v .

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CHANGELOG
2+
3+
[v1.1.0](https://github.com/tokopedia/graphql-go/releases/tag/v1.1.0) Release v1.1.0
4+
* [FEATURE] Add types package #437
5+
* [FEATURE] Expose `packer.Unmarshaler` as `decode.Unmarshaler` to the public #450
6+
* [FEATURE] Add location fields to type definitions #454
7+
* [FEATURE] `errors.Errorf` preserves original error similar to `fmt.Errorf` #456
8+
* [BUGFIX] Fix duplicated __typename in response (fixes #369) #443
9+
10+
[v1.0.0](https://github.com/tokopedia/graphql-go/releases/tag/v1.0.0) Initial release

README.md

Lines changed: 121 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# graphql-go [![Sourcegraph](https://sourcegraph.com/github.com/tokopedia/graphql-go/-/badge.svg)](https://sourcegraph.com/github.com/tokopedia/graphql-go?badge) [![Build Status](https://semaphoreci.com/api/v1/graph-gophers/graphql-go/branches/master/badge.svg)](https://semaphoreci.com/graph-gophers/graphql-go) [![GoDoc](https://godoc.org/github.com/tokopedia/graphql-go?status.svg)](https://godoc.org/github.com/tokopedia/graphql-go)
1+
# graphql-go [![Sourcegraph](https://sourcegraph.com/github.com/tokopedia/graphql-go/-/badge.svg)](https://sourcegraph.com/github.com/tokopedia/graphql-go?badge) [![Build Status](https://tokopedia.semaphoreci.com/badges/graphql-go/branches/master.svg?style=shields)](https://tokopedia.semaphoreci.com/projects/graphql-go) [![GoDoc](https://godoc.org/github.com/tokopedia/graphql-go?status.svg)](https://godoc.org/github.com/tokopedia/graphql-go)
22

33
<p align="center"><img src="docs/img/logo.png" width="300"></p>
44

@@ -11,13 +11,13 @@ safe for production use.
1111

1212
- minimal API
1313
- support for `context.Context`
14-
- support for the `OpenTracing` standard
14+
- support for the `OpenTelemetry` and `OpenTracing` standards
1515
- schema type-checking against resolvers
1616
- resolvers are matched to the schema based on method sets (can resolve a GraphQL schema with a Go interface or Go struct).
1717
- handles panics in resolvers
1818
- parallel execution of resolvers
1919
- subscriptions
20-
- [sample WS transport](https://github.com/graph-gophers/graphql-transport-ws)
20+
- [sample WS transport](https://github.com/tokopedia/graphql-transport-ws)
2121

2222
## Roadmap
2323

@@ -26,8 +26,9 @@ Feedback is welcome and appreciated.
2626

2727
## (Some) Documentation
2828

29-
### Basic Sample
29+
### Getting started
3030

31+
In order to run a simple GraphQL server locally create a `main.go` file with the following content:
3132
```go
3233
package main
3334

@@ -45,9 +46,6 @@ func (_ *query) Hello() string { return "Hello, world!" }
4546

4647
func main() {
4748
s := `
48-
schema {
49-
query: Query
50-
}
5149
type Query {
5250
hello: String!
5351
}
@@ -57,11 +55,12 @@ func main() {
5755
log.Fatal(http.ListenAndServe(":8080", nil))
5856
}
5957
```
60-
61-
To test:
58+
Then run the file with `go run main.go`. To test:
59+
6260
```sh
63-
$ curl -XPOST -d '{"query": "{ hello }"}' localhost:8080/query
61+
curl -XPOST -d '{"query": "{ hello }"}' localhost:8080/query
6462
```
63+
For more realistic usecases check our [examples section](https://github.com/tokopedia/graphql-go/wiki/Examples).
6564

6665
### Resolvers
6766

@@ -103,10 +102,118 @@ func (r *helloWorldResolver) Hello(ctx context.Context) (string, error) {
103102
}
104103
```
105104

106-
### Community Examples
105+
### Schema Options
106+
107+
- `UseStringDescriptions()` enables the usage of double quoted and triple quoted. When this is not enabled, comments are parsed as descriptions instead.
108+
- `UseFieldResolvers()` specifies whether to use struct field resolvers.
109+
- `MaxDepth(n int)` specifies the maximum field nesting depth in a query. The default is 0 which disables max depth checking.
110+
- `MaxParallelism(n int)` specifies the maximum number of resolvers per request allowed to run in parallel. The default is 10.
111+
- `Tracer(tracer trace.Tracer)` is used to trace queries and fields. It defaults to `noop.Tracer`.
112+
- `Logger(logger log.Logger)` is used to log panics during query execution. It defaults to `exec.DefaultLogger`.
113+
- `PanicHandler(panicHandler errors.PanicHandler)` is used to transform panics into errors during query execution. It defaults to `errors.DefaultPanicHandler`.
114+
- `DisableIntrospection()` disables introspection queries.
115+
116+
### Custom Errors
117+
118+
Errors returned by resolvers can include custom extensions by implementing the `ResolverError` interface:
119+
120+
```go
121+
type ResolverError interface {
122+
error
123+
Extensions() map[string]interface{}
124+
}
125+
```
126+
127+
Example of a simple custom error:
128+
129+
```go
130+
type droidNotFoundError struct {
131+
Code string `json:"code"`
132+
Message string `json:"message"`
133+
}
134+
135+
func (e droidNotFoundError) Error() string {
136+
return fmt.Sprintf("error [%s]: %s", e.Code, e.Message)
137+
}
138+
139+
func (e droidNotFoundError) Extensions() map[string]interface{} {
140+
return map[string]interface{}{
141+
"code": e.Code,
142+
"message": e.Message,
143+
}
144+
}
145+
```
146+
147+
Which could produce a GraphQL error such as:
148+
149+
```go
150+
{
151+
"errors": [
152+
{
153+
"message": "error [NotFound]: This is not the droid you are looking for",
154+
"path": [
155+
"droid"
156+
],
157+
"extensions": {
158+
"code": "NotFound",
159+
"message": "This is not the droid you are looking for"
160+
}
161+
}
162+
],
163+
"data": null
164+
}
165+
```
166+
167+
### Tracing
168+
169+
By default the library uses `noop.Tracer`. If you want to change that you can use the OpenTelemetry or the OpenTracing implementations, respectively:
170+
171+
```go
172+
// OpenTelemetry tracer
173+
package main
174+
175+
import (
176+
"github.com/tokopedia/graphql-go"
177+
"github.com/tokopedia/graphql-go/example/starwars"
178+
otelgraphql "github.com/tokopedia/graphql-go/trace/otel"
179+
"github.com/tokopedia/graphql-go/trace/tracer"
180+
)
181+
// ...
182+
_, err := graphql.ParseSchema(starwars.Schema, nil, graphql.Tracer(otelgraphql.DefaultTracer()))
183+
// ...
184+
```
185+
Alternatively you can pass an existing trace.Tracer instance:
186+
```go
187+
tr := otel.Tracer("example")
188+
_, err = graphql.ParseSchema(starwars.Schema, nil, graphql.Tracer(&otelgraphql.Tracer{Tracer: tr}))
189+
```
190+
191+
192+
```go
193+
// OpenTracing tracer
194+
package main
195+
196+
import (
197+
"github.com/tokopedia/graphql-go"
198+
"github.com/tokopedia/graphql-go/example/starwars"
199+
"github.com/tokopedia/graphql-go/trace/opentracing"
200+
"github.com/tokopedia/graphql-go/trace/tracer"
201+
)
202+
// ...
203+
_, err := graphql.ParseSchema(starwars.Schema, nil, graphql.Tracer(opentracing.Tracer{}))
204+
205+
// ...
206+
```
207+
208+
If you need to implement a custom tracer the library would accept any tracer which implements the interface below:
209+
```go
210+
type Tracer interface {
211+
TraceQuery(ctx context.Context, queryString string, operationName string, variables map[string]interface{}, varTypes map[string]*introspection.Type) (context.Context, func([]*errors.QueryError))
212+
TraceField(ctx context.Context, label, typeName, fieldName string, trivial bool, args map[string]interface{}) (context.Context, func(*errors.QueryError))
213+
TraceValidation(context.Context) func([]*errors.QueryError)
214+
}
215+
```
107216

108-
[tonyghita/graphql-go-example](https://github.com/tonyghita/graphql-go-example) - A more "productionized" version of the Star Wars API example given in this repository.
109217

110-
[deltaskelta/graphql-go-pets-example](https://github.com/deltaskelta/graphql-go-pets-example) - graphql-go resolving against a sqlite database
218+
### [Examples](https://github.com/tokopedia/graphql-go/wiki/Examples)
111219

112-
[OscarYuen/go-graphql-starter](https://github.com/OscarYuen/go-graphql-starter) - a starter application integrated with dataloader, psql and basic authentication

SECURITY.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
We always try to maintain the library secure and suggest our users to upgrade to the latest stable version. We realize that sometimes this is not possible.
6+
7+
| Version | Supported |
8+
| ------- | ------------------ |
9+
| 1.x | :white_check_mark: |
10+
| < 1.0 | :x: |
11+
12+
## MaxDepth
13+
If you are using the `graphql.MaxDepth` schema option, make sure that you upgrade to version v1.3.0 or higher due to a bug causing security vulnerability in earlier versions.
14+
15+
## Reporting a Vulnerability
16+
17+
If you find a security vulnerability with this library, please, DO NOT submit a pull request right away. Please, report the issue to @pavelnikolov and/or @tony in the Gophers Slack in a private message.

decode/decode.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package decode
2+
3+
// Unmarshaler defines the api of Go types mapped to custom GraphQL scalar types
4+
type Unmarshaler interface {
5+
// ImplementsGraphQLType maps the implementing custom Go type
6+
// to the GraphQL scalar type in the schema.
7+
ImplementsGraphQLType(name string) bool
8+
// UnmarshalGraphQL is the custom unmarshaler for the implementing type
9+
//
10+
// This function will be called whenever you use the
11+
// custom GraphQL scalar type as an input
12+
UnmarshalGraphQL(input interface{}) error
13+
}

0 commit comments

Comments
 (0)