Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor handler package #885

Merged
merged 56 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
249b602
Start drafting new handler interfaces
vektah Sep 30, 2019
da98618
port over the setter request context middleware
vektah Oct 1, 2019
311887d
convert APQ to middleware
vektah Oct 1, 2019
afe241b
port over tracing
vektah Oct 2, 2019
d0f6830
port json post
vektah Oct 2, 2019
b5089ca
Split transports into subpackage
vektah Oct 28, 2019
eed1515
Split middlware out of handler package
vektah Oct 28, 2019
cb99b42
Add websocket transport
vektah Oct 28, 2019
2e0c9ca
mark validation and parse errors separately to execution errors
vektah Oct 28, 2019
a7c5e66
build middleware graph once at startup
vektah Oct 28, 2019
f00e5fa
use plugins instead of middleware so multiple hooks can be configured
vektah Oct 29, 2019
c3dbcf8
Add apollo tracing
vektah Oct 30, 2019
ab5665a
Add result context
vektah Oct 30, 2019
4a69bcd
Bring operation middleware inline with other handler interfaces
vektah Oct 30, 2019
72c47c9
rename result handler to response handler
vektah Oct 30, 2019
9d1d77e
split context.go into 3 files
vektah Oct 31, 2019
a70e93b
consistently name transports
vektah Oct 31, 2019
64cfc9a
extract shared handler test server stubs
vektah Oct 31, 2019
aede7d1
Add multipart from transport
vektah Oct 31, 2019
0965420
Add query document caching
vektah Oct 31, 2019
8c5340c
Add complexity limit plugin
vektah Oct 31, 2019
e7e913d
Remove remains of old handler package
vektah Oct 31, 2019
c7bb03a
merge executable schema entrypoints
vektah Nov 1, 2019
631142c
move writer all the way back to the transport
vektah Nov 1, 2019
473a0d2
Implement bc shim for old handler package
vektah Nov 1, 2019
bc98156
Combine root handlers in ExecutableSchema into a single Exec method
vektah Nov 5, 2019
479abbe
update generated code
vektah Nov 5, 2019
3476ac4
fix linting issues
vektah Nov 5, 2019
1b57bc3
Rename RequestContext to OperationContext
vektah Nov 5, 2019
40f0886
add NewDefaultServer
vektah Nov 5, 2019
848c627
remove DirectiveMiddleware
vektah Nov 5, 2019
092ed95
collect field timing in generated code
vektah Nov 5, 2019
2898a62
rename ResolverContext to FieldContext
vektah Nov 5, 2019
f2ef5ec
more deprecations and more compat
vektah Nov 6, 2019
0a39ae2
add fixed complexity limit
vektah Nov 11, 2019
fc727c9
Add a signpost method to handler extension interface
vektah Nov 11, 2019
e9502ae
Make extensions validatable
vektah Nov 11, 2019
67fa210
allow extensions to declare their own stats
vektah Nov 11, 2019
7cbd75d
fix APQ signature
vektah Nov 11, 2019
0ee185b
fix duplicate header sends
vektah Nov 11, 2019
a77d9fc
Add generated stanzas back in
vektah Nov 11, 2019
631b48a
remove automatic field stat collection to reduce time calls
vektah Nov 11, 2019
c3f9381
fix benchmark
vektah Nov 11, 2019
a6f9462
Merge remote-tracking branch 'origin/master' into handler-refactor
vektah Nov 11, 2019
dc62234
Tune allocs for benchmarks
vektah Nov 11, 2019
572fb41
remove all references to deprecated handler package
vektah Nov 11, 2019
dc76d02
Merge remote-tracking branch 'origin/master' into handler-refactor
vektah Nov 12, 2019
d0836b7
Expose APQ stats
vektah Nov 28, 2019
458fa0d
Add more interface assertions
vektah Nov 28, 2019
a13a0f5
add docs on extension name conventions
vektah Nov 28, 2019
a339a04
panic if operation context is missing when requested
vektah Nov 28, 2019
14dbf1a
use new handler package in new test
vektah Nov 28, 2019
922db1e
always return OperationContext for postpone process
vvakame Nov 28, 2019
5106480
Merge pull request #947 from 99designs/handler-oc-handling
vektah Nov 28, 2019
dca9e4a
Add migration docs
vektah Nov 28, 2019
bac79c5
force clean git checkout
vektah Nov 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/gorilla/websocket v1.2.0
github.com/hashicorp/golang-lru v0.5.0
github.com/kr/pretty v0.1.0 // indirect
github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd // indirect
github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047
github.com/opentracing/basictracer-go v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.0.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd h1:HvFwW+cm9bCbZ/+vuGNq7CRWXql8c0y8nGeYpqmpvmk=
github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8=
github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/opentracing/basictracer-go v1.0.0 h1:YyUAhaEfjoWXclZVJ9sGoNct7j4TVk7lZWlQw5UXuoo=
Expand Down
28 changes: 28 additions & 0 deletions graphql/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,34 @@ func (rc *RequestContext) Validate(ctx context.Context) error {
return nil
}

// AddRequestMiddleware allows you to define a function that will be called around the root request,
// after the query has been parsed. This is useful for logging
func (cfg *RequestContext) AddRequestMiddleware(middleware RequestMiddleware) {
if cfg.RequestMiddleware == nil {
cfg.RequestMiddleware = middleware
return
}

lastResolve := cfg.RequestMiddleware
cfg.RequestMiddleware = func(ctx context.Context, next func(ctx context.Context) []byte) []byte {
return lastResolve(ctx, func(ctx context.Context) []byte {
return middleware(ctx, next)
})
}
}

func (cfg *RequestContext) AddTracer(tracer Tracer) {
if cfg.Tracer == nil {
cfg.Tracer = tracer
return
}
lastTracer := cfg.Tracer
cfg.Tracer = &tracerWrapper{
tracer1: lastTracer,
tracer2: tracer,
}
}

func DefaultResolverMiddleware(ctx context.Context, next Resolver) (res interface{}, err error) {
return next(ctx)
}
Expand Down
279 changes: 279 additions & 0 deletions graphql/esmock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions graphql/exec.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate go run github.com/matryer/moq -out esmock.go . ExecutableSchema

package graphql

import (
Expand Down
Loading