diff --git a/_examples/chat/chat_test.go b/_examples/chat/chat_test.go index 8a4081bdb81..c3dd59abeea 100644 --- a/_examples/chat/chat_test.go +++ b/_examples/chat/chat_test.go @@ -6,10 +6,11 @@ import ( "sync" "testing" - "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql/handler" ) func TestChatSubscriptions(t *testing.T) { diff --git a/_examples/chat/server/server.go b/_examples/chat/server/server.go index 19e938f340c..5627f4d2a02 100644 --- a/_examples/chat/server/server.go +++ b/_examples/chat/server/server.go @@ -6,11 +6,6 @@ import ( "net/url" "time" - "github.com/99designs/gqlgen/graphql/handler/extension" - "github.com/99designs/gqlgen/graphql/handler/transport" - - "github.com/99designs/gqlgen/graphql/playground" - "github.com/gorilla/websocket" "github.com/opentracing/opentracing-go" "github.com/rs/cors" @@ -20,6 +15,9 @@ import ( "github.com/99designs/gqlgen/_examples/chat" "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/99designs/gqlgen/graphql/playground" ) func main() { diff --git a/_examples/dataloader/dataloader_test.go b/_examples/dataloader/dataloader_test.go index c70b45b95a0..34dc9e427d2 100644 --- a/_examples/dataloader/dataloader_test.go +++ b/_examples/dataloader/dataloader_test.go @@ -3,10 +3,11 @@ package dataloader import ( "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/stretchr/testify/require" ) func TestTodo(t *testing.T) { diff --git a/_examples/embedding/subdir/embedding_test.go b/_examples/embedding/subdir/embedding_test.go index d7794552366..3f2e97d24c0 100644 --- a/_examples/embedding/subdir/embedding_test.go +++ b/_examples/embedding/subdir/embedding_test.go @@ -3,10 +3,11 @@ package subdir import ( "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/_examples/embedding/subdir/gendir" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestEmbeddingWorks(t *testing.T) { diff --git a/_examples/fileupload/fileupload_test.go b/_examples/fileupload/fileupload_test.go index 29ef9dc3fbc..c4138c14c91 100644 --- a/_examples/fileupload/fileupload_test.go +++ b/_examples/fileupload/fileupload_test.go @@ -8,12 +8,13 @@ import ( "os" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/_examples/fileupload/model" gqlclient "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/stretchr/testify/require" ) func TestFileUpload(t *testing.T) { diff --git a/_examples/fileupload/server/server.go b/_examples/fileupload/server/server.go index 75a47b73b62..55dc08d883a 100644 --- a/_examples/fileupload/server/server.go +++ b/_examples/fileupload/server/server.go @@ -7,15 +7,13 @@ import ( "log" "net/http" - "github.com/99designs/gqlgen/graphql/handler/extension" - "github.com/99designs/gqlgen/graphql/handler/transport" - - "github.com/99designs/gqlgen/graphql/playground" - "github.com/99designs/gqlgen/_examples/fileupload" "github.com/99designs/gqlgen/_examples/fileupload/model" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/99designs/gqlgen/graphql/playground" ) func main() { diff --git a/_examples/go.mod b/_examples/go.mod index bd3fcb10bc5..b6dfdaa00be 100644 --- a/_examples/go.mod +++ b/_examples/go.mod @@ -25,6 +25,7 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/sosodev/duration v1.1.0 // indirect golang.org/x/mod v0.10.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/tools v0.9.3 // indirect diff --git a/_examples/go.sum b/_examples/go.sum index 0efcf708e3d..98f0ac96a29 100644 --- a/_examples/go.sum +++ b/_examples/go.sum @@ -48,6 +48,8 @@ github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06B github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 h1:pXY9qYc/MP5zdvqWEUH6SjNiu7VhSjuVFTFiTcphaLU= github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= +github.com/sosodev/duration v1.1.0 h1:kQcaiGbJaIsRqgQy7VGlZrVw1giWO+lDoX3MCPnpVO4= +github.com/sosodev/duration v1.1.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= diff --git a/_examples/scalars/scalar_test.go b/_examples/scalars/scalar_test.go index f9ca2b1dd14..0d3228b1413 100644 --- a/_examples/scalars/scalar_test.go +++ b/_examples/scalars/scalar_test.go @@ -4,10 +4,11 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/stretchr/testify/require" ) type RawUser struct { diff --git a/_examples/selection/selection.go b/_examples/selection/selection.go index 5890d14ab9f..6a6b0f9bec3 100644 --- a/_examples/selection/selection.go +++ b/_examples/selection/selection.go @@ -7,8 +7,9 @@ import ( "fmt" "time" - "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/graphql" ) type Resolver struct{} diff --git a/_examples/selection/selection_test.go b/_examples/selection/selection_test.go index c6874033220..72495e927bd 100644 --- a/_examples/selection/selection_test.go +++ b/_examples/selection/selection_test.go @@ -3,9 +3,10 @@ package selection import ( "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestSelection(t *testing.T) { diff --git a/_examples/starwars/resolvers.go b/_examples/starwars/resolvers.go index e7b9629d12f..6c94a2ea0fb 100644 --- a/_examples/starwars/resolvers.go +++ b/_examples/starwars/resolvers.go @@ -12,7 +12,6 @@ import ( "time" "github.com/99designs/gqlgen/_examples/starwars/generated" - "github.com/99designs/gqlgen/_examples/starwars/models" ) diff --git a/_examples/starwars/starwars_test.go b/_examples/starwars/starwars_test.go index 8cbe861b0ca..a01f9fb7b50 100644 --- a/_examples/starwars/starwars_test.go +++ b/_examples/starwars/starwars_test.go @@ -3,11 +3,12 @@ package starwars import ( "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/_examples/starwars/generated" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/stretchr/testify/require" ) func TestStarwars(t *testing.T) { diff --git a/_examples/todo/todo.go b/_examples/todo/todo.go index ad3da2c392e..f8a710722e8 100644 --- a/_examples/todo/todo.go +++ b/_examples/todo/todo.go @@ -8,8 +8,9 @@ import ( "fmt" "time" - "github.com/99designs/gqlgen/graphql" "github.com/mitchellh/mapstructure" + + "github.com/99designs/gqlgen/graphql" ) var ( diff --git a/_examples/todo/todo_test.go b/_examples/todo/todo_test.go index a6cef4ac057..348ecc70237 100644 --- a/_examples/todo/todo_test.go +++ b/_examples/todo/todo_test.go @@ -3,10 +3,11 @@ package todo import ( "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/stretchr/testify/require" ) func TestTodo(t *testing.T) { diff --git a/_examples/type-system-extension/server/server.go b/_examples/type-system-extension/server/server.go index 2ddca5f7b9b..6fec1d24037 100644 --- a/_examples/type-system-extension/server/server.go +++ b/_examples/type-system-extension/server/server.go @@ -5,10 +5,9 @@ import ( "net/http" "os" - "github.com/99designs/gqlgen/graphql/playground" - extension "github.com/99designs/gqlgen/_examples/type-system-extension" "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/playground" ) const defaultPort = "8080" diff --git a/_examples/websocket-initfunc/server/server.go b/_examples/websocket-initfunc/server/server.go index 64c3010f81c..7027e9728e2 100644 --- a/_examples/websocket-initfunc/server/server.go +++ b/_examples/websocket-initfunc/server/server.go @@ -8,14 +8,15 @@ import ( "os" "time" - "github.com/99designs/gqlgen/graphql/handler" - "github.com/99designs/gqlgen/graphql/handler/extension" - "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/99designs/gqlgen/graphql/playground" "github.com/go-chi/chi" "github.com/gorilla/websocket" "github.com/gqlgen/_examples/websocket-initfunc/server/graph" "github.com/rs/cors" + + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/extension" + "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/99designs/gqlgen/graphql/playground" ) func webSocketInit(ctx context.Context, initPayload transport.InitPayload) (context.Context, *transport.InitPayload, error) { diff --git a/api/generate_test.go b/api/generate_test.go index 417e6f3060c..7778f953433 100644 --- a/api/generate_test.go +++ b/api/generate_test.go @@ -5,8 +5,9 @@ import ( "path" "testing" - "github.com/99designs/gqlgen/codegen/config" "github.com/stretchr/testify/require" + + "github.com/99designs/gqlgen/codegen/config" ) func cleanup(workDir string) { diff --git a/api/option_test.go b/api/option_test.go index 5819c4bdd07..d84da902fdc 100644 --- a/api/option_test.go +++ b/api/option_test.go @@ -3,12 +3,13 @@ package api import ( "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/plugin" "github.com/99designs/gqlgen/plugin/federation" "github.com/99designs/gqlgen/plugin/modelgen" "github.com/99designs/gqlgen/plugin/resolvergen" - "github.com/stretchr/testify/require" ) type testPlugin struct{} diff --git a/client/client_test.go b/client/client_test.go index 4755ca5fa8d..d7b95dcae24 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -12,9 +12,10 @@ import ( "testing" "time" - "github.com/99designs/gqlgen/client" "github.com/mitchellh/mapstructure" "github.com/stretchr/testify/require" + + "github.com/99designs/gqlgen/client" ) func TestClient(t *testing.T) { diff --git a/client/withfilesoption_test.go b/client/withfilesoption_test.go index dbb7756cd75..054c3622fe5 100644 --- a/client/withfilesoption_test.go +++ b/client/withfilesoption_test.go @@ -10,8 +10,9 @@ import ( "strings" "testing" - "github.com/99designs/gqlgen/client" "github.com/stretchr/testify/require" + + "github.com/99designs/gqlgen/client" ) func TestWithFiles(t *testing.T) { diff --git a/codegen/args.go b/codegen/args.go index c4cecea9326..2f174332c7a 100644 --- a/codegen/args.go +++ b/codegen/args.go @@ -5,9 +5,10 @@ import ( "go/types" "strings" + "github.com/vektah/gqlparser/v2/ast" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" - "github.com/vektah/gqlparser/v2/ast" ) type ArgSet struct { diff --git a/codegen/config/binder_test.go b/codegen/config/binder_test.go index ae6b3027fbc..f436a8efe37 100644 --- a/codegen/config/binder_test.go +++ b/codegen/config/binder_test.go @@ -4,11 +4,11 @@ import ( "go/types" "testing" - "github.com/99designs/gqlgen/internal/code" - "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/internal/code" ) func TestBindingToInvalid(t *testing.T) { diff --git a/codegen/data_test.go b/codegen/data_test.go index a1ac4d3df9f..64ca8c621fb 100644 --- a/codegen/data_test.go +++ b/codegen/data_test.go @@ -3,10 +3,10 @@ package codegen import ( "testing" - "github.com/99designs/gqlgen/codegen/config" + "github.com/stretchr/testify/assert" "github.com/vektah/gqlparser/v2/ast" - "github.com/stretchr/testify/assert" + "github.com/99designs/gqlgen/codegen/config" ) func TestData_Directives(t *testing.T) { diff --git a/codegen/directive.go b/codegen/directive.go index 973061129a2..f955665be8e 100644 --- a/codegen/directive.go +++ b/codegen/directive.go @@ -5,8 +5,9 @@ import ( "strconv" "strings" - "github.com/99designs/gqlgen/codegen/templates" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/codegen/templates" ) type DirectiveList map[string]*Directive diff --git a/codegen/field.go b/codegen/field.go index a7e1fb2ba68..6d11538a028 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -10,11 +10,12 @@ import ( "strconv" "strings" - "github.com/99designs/gqlgen/codegen/config" - "github.com/99designs/gqlgen/codegen/templates" "github.com/vektah/gqlparser/v2/ast" "golang.org/x/text/cases" "golang.org/x/text/language" + + "github.com/99designs/gqlgen/codegen/config" + "github.com/99designs/gqlgen/codegen/templates" ) type Field struct { diff --git a/codegen/field_test.go b/codegen/field_test.go index 642d2d3f5c5..0d5eb16216e 100644 --- a/codegen/field_test.go +++ b/codegen/field_test.go @@ -8,9 +8,10 @@ import ( "go/types" "testing" - "github.com/99designs/gqlgen/codegen/config" "github.com/stretchr/testify/require" ast2 "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/codegen/config" ) func TestFindField(t *testing.T) { diff --git a/codegen/generate.go b/codegen/generate.go index 1ce8c329dc3..d63758abf10 100644 --- a/codegen/generate.go +++ b/codegen/generate.go @@ -9,9 +9,10 @@ import ( "runtime" "strings" + "github.com/vektah/gqlparser/v2/ast" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" - "github.com/vektah/gqlparser/v2/ast" ) //go:embed *.gotpl diff --git a/codegen/object.go b/codegen/object.go index 8609232719b..7164560e105 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -7,10 +7,11 @@ import ( "strings" "unicode" - "github.com/99designs/gqlgen/codegen/config" "github.com/vektah/gqlparser/v2/ast" "golang.org/x/text/cases" "golang.org/x/text/language" + + "github.com/99designs/gqlgen/codegen/config" ) type GoFieldType int diff --git a/codegen/templates/import_test.go b/codegen/templates/import_test.go index 483fd5ece82..d709f72cc9d 100644 --- a/codegen/templates/import_test.go +++ b/codegen/templates/import_test.go @@ -6,9 +6,9 @@ import ( "os" "testing" - "github.com/99designs/gqlgen/internal/code" - "github.com/stretchr/testify/require" + + "github.com/99designs/gqlgen/internal/code" ) func TestImports(t *testing.T) { diff --git a/codegen/templates/templates_test.go b/codegen/templates/templates_test.go index 12ccbb23c10..277a979cdb3 100644 --- a/codegen/templates/templates_test.go +++ b/codegen/templates/templates_test.go @@ -7,10 +7,10 @@ import ( "path/filepath" "testing" - "github.com/99designs/gqlgen/internal/code" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/99designs/gqlgen/internal/code" ) //go:embed *.gotpl diff --git a/codegen/testserver/followschema/complexity_test.go b/codegen/testserver/followschema/complexity_test.go index 6a91e0f0005..fd69a79c5e6 100644 --- a/codegen/testserver/followschema/complexity_test.go +++ b/codegen/testserver/followschema/complexity_test.go @@ -4,10 +4,11 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" - "github.com/stretchr/testify/require" ) func TestComplexityCollisions(t *testing.T) { diff --git a/codegen/testserver/followschema/defaults_test.go b/codegen/testserver/followschema/defaults_test.go index e5708a72e33..26adaa1373d 100644 --- a/codegen/testserver/followschema/defaults_test.go +++ b/codegen/testserver/followschema/defaults_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func assertDefaults(t *testing.T, ret *DefaultParametersMirror) { diff --git a/codegen/testserver/followschema/directive_test.go b/codegen/testserver/followschema/directive_test.go index e995b2721cd..b6d84d69325 100644 --- a/codegen/testserver/followschema/directive_test.go +++ b/codegen/testserver/followschema/directive_test.go @@ -5,10 +5,11 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) type ckey string diff --git a/codegen/testserver/followschema/embedded_test.go b/codegen/testserver/followschema/embedded_test.go index b5e1575bac3..207ea88182e 100644 --- a/codegen/testserver/followschema/embedded_test.go +++ b/codegen/testserver/followschema/embedded_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) type fakeUnexportedEmbeddedInterface struct{} diff --git a/codegen/testserver/followschema/enums_test.go b/codegen/testserver/followschema/enums_test.go index e7c80c29d2a..c72293f1690 100644 --- a/codegen/testserver/followschema/enums_test.go +++ b/codegen/testserver/followschema/enums_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestEnumsResolver(t *testing.T) { diff --git a/codegen/testserver/followschema/fields_order_test.go b/codegen/testserver/followschema/fields_order_test.go index d521c8fc995..2be70d9da52 100644 --- a/codegen/testserver/followschema/fields_order_test.go +++ b/codegen/testserver/followschema/fields_order_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) type FieldsOrderPayloadResults struct { diff --git a/codegen/testserver/followschema/generated_test.go b/codegen/testserver/followschema/generated_test.go index 9d10cde2c35..1792b0b4e40 100644 --- a/codegen/testserver/followschema/generated_test.go +++ b/codegen/testserver/followschema/generated_test.go @@ -8,9 +8,10 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestForcedResolverFieldIsPointer(t *testing.T) { diff --git a/codegen/testserver/followschema/input_test.go b/codegen/testserver/followschema/input_test.go index 9a13f2d17f0..27f6ada77ad 100644 --- a/codegen/testserver/followschema/input_test.go +++ b/codegen/testserver/followschema/input_test.go @@ -6,9 +6,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestInput(t *testing.T) { diff --git a/codegen/testserver/followschema/interfaces_test.go b/codegen/testserver/followschema/interfaces_test.go index 3a7820fe52c..2ef7312841a 100644 --- a/codegen/testserver/followschema/interfaces_test.go +++ b/codegen/testserver/followschema/interfaces_test.go @@ -6,10 +6,11 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestInterfaces(t *testing.T) { diff --git a/codegen/testserver/followschema/introspection_test.go b/codegen/testserver/followschema/introspection_test.go index ef2bfafb53b..2f3fbc30cbf 100644 --- a/codegen/testserver/followschema/introspection_test.go +++ b/codegen/testserver/followschema/introspection_test.go @@ -4,12 +4,13 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/stretchr/testify/require" ) func TestIntrospection(t *testing.T) { diff --git a/codegen/testserver/followschema/maps_test.go b/codegen/testserver/followschema/maps_test.go index fe9750450fb..314dc6055dd 100644 --- a/codegen/testserver/followschema/maps_test.go +++ b/codegen/testserver/followschema/maps_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestMaps(t *testing.T) { diff --git a/codegen/testserver/followschema/middleware_test.go b/codegen/testserver/followschema/middleware_test.go index 16fe10e6121..3d214dc05ba 100644 --- a/codegen/testserver/followschema/middleware_test.go +++ b/codegen/testserver/followschema/middleware_test.go @@ -5,12 +5,12 @@ import ( "sync" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestMiddleware(t *testing.T) { diff --git a/codegen/testserver/followschema/modelmethod_test.go b/codegen/testserver/followschema/modelmethod_test.go index 4cf1803729e..3fda4b2a393 100644 --- a/codegen/testserver/followschema/modelmethod_test.go +++ b/codegen/testserver/followschema/modelmethod_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestModelMethods(t *testing.T) { diff --git a/codegen/testserver/followschema/mutation_with_custom_scalar_test.go b/codegen/testserver/followschema/mutation_with_custom_scalar_test.go index 2f46c3ad4d0..67f14ef31ad 100644 --- a/codegen/testserver/followschema/mutation_with_custom_scalar_test.go +++ b/codegen/testserver/followschema/mutation_with_custom_scalar_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestErrorInsideMutationArgument(t *testing.T) { diff --git a/codegen/testserver/followschema/nulls_test.go b/codegen/testserver/followschema/nulls_test.go index 6049a7ca6e9..e738ffecf5b 100644 --- a/codegen/testserver/followschema/nulls_test.go +++ b/codegen/testserver/followschema/nulls_test.go @@ -5,9 +5,10 @@ import ( "errors" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestNullBubbling(t *testing.T) { diff --git a/codegen/testserver/followschema/panics_test.go b/codegen/testserver/followschema/panics_test.go index 4433aad01a3..e22fc144b18 100644 --- a/codegen/testserver/followschema/panics_test.go +++ b/codegen/testserver/followschema/panics_test.go @@ -5,12 +5,12 @@ import ( "fmt" "testing" - "github.com/99designs/gqlgen/graphql" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/gqlerror" "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" - "github.com/vektah/gqlparser/v2/gqlerror" ) func TestPanics(t *testing.T) { diff --git a/codegen/testserver/followschema/primitive_objects_test.go b/codegen/testserver/followschema/primitive_objects_test.go index 87de88bb452..106518caccd 100644 --- a/codegen/testserver/followschema/primitive_objects_test.go +++ b/codegen/testserver/followschema/primitive_objects_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/assert" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/assert" ) func TestPrimitiveObjects(t *testing.T) { diff --git a/codegen/testserver/followschema/ptr_to_any_test.go b/codegen/testserver/followschema/ptr_to_any_test.go index c1e78b8d800..3af48a89eda 100644 --- a/codegen/testserver/followschema/ptr_to_any_test.go +++ b/codegen/testserver/followschema/ptr_to_any_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestPtrToAny(t *testing.T) { diff --git a/codegen/testserver/followschema/ptr_to_ptr_input_test.go b/codegen/testserver/followschema/ptr_to_ptr_input_test.go index ab40d1d68da..785b3bceb7b 100644 --- a/codegen/testserver/followschema/ptr_to_ptr_input_test.go +++ b/codegen/testserver/followschema/ptr_to_ptr_input_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) type UpdatePtrToPtrResults struct { diff --git a/codegen/testserver/followschema/ptr_to_slice_test.go b/codegen/testserver/followschema/ptr_to_slice_test.go index 20818cc4d1a..a95b6b46c95 100644 --- a/codegen/testserver/followschema/ptr_to_slice_test.go +++ b/codegen/testserver/followschema/ptr_to_slice_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestPtrToSlice(t *testing.T) { diff --git a/codegen/testserver/followschema/response_extension_test.go b/codegen/testserver/followschema/response_extension_test.go index 4ee1b5749f8..92d1ade4afa 100644 --- a/codegen/testserver/followschema/response_extension_test.go +++ b/codegen/testserver/followschema/response_extension_test.go @@ -4,10 +4,11 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestResponseExtension(t *testing.T) { diff --git a/codegen/testserver/followschema/scalar_context_test.go b/codegen/testserver/followschema/scalar_context_test.go index 2e2a0dc3613..2d4bf1c8ba9 100644 --- a/codegen/testserver/followschema/scalar_context_test.go +++ b/codegen/testserver/followschema/scalar_context_test.go @@ -5,9 +5,10 @@ import ( "math" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestFloatInfAndNaN(t *testing.T) { diff --git a/codegen/testserver/followschema/scalar_default_test.go b/codegen/testserver/followschema/scalar_default_test.go index f6fc05cb09e..f0faa0139ea 100644 --- a/codegen/testserver/followschema/scalar_default_test.go +++ b/codegen/testserver/followschema/scalar_default_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestDefaultScalarImplementation(t *testing.T) { diff --git a/codegen/testserver/followschema/slices_test.go b/codegen/testserver/followschema/slices_test.go index 19df15816ba..de296861865 100644 --- a/codegen/testserver/followschema/slices_test.go +++ b/codegen/testserver/followschema/slices_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestSlices(t *testing.T) { diff --git a/codegen/testserver/followschema/subscription_test.go b/codegen/testserver/followschema/subscription_test.go index c4490451903..b25fb53bd63 100644 --- a/codegen/testserver/followschema/subscription_test.go +++ b/codegen/testserver/followschema/subscription_test.go @@ -8,12 +8,12 @@ import ( "testing" "time" - "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestSubscriptions(t *testing.T) { diff --git a/codegen/testserver/followschema/time_test.go b/codegen/testserver/followschema/time_test.go index 60a098750a9..947c1cc293c 100644 --- a/codegen/testserver/followschema/time_test.go +++ b/codegen/testserver/followschema/time_test.go @@ -5,9 +5,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestTime(t *testing.T) { diff --git a/codegen/testserver/followschema/typefallback_test.go b/codegen/testserver/followschema/typefallback_test.go index 764661f84b8..013ac1b7f84 100644 --- a/codegen/testserver/followschema/typefallback_test.go +++ b/codegen/testserver/followschema/typefallback_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestTypeFallback(t *testing.T) { diff --git a/codegen/testserver/followschema/validtypes_test.go b/codegen/testserver/followschema/validtypes_test.go index 2c0e67942a0..026ebe029ce 100644 --- a/codegen/testserver/followschema/validtypes_test.go +++ b/codegen/testserver/followschema/validtypes_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestValidType(t *testing.T) { diff --git a/codegen/testserver/followschema/wrapped_type_test.go b/codegen/testserver/followschema/wrapped_type_test.go index 95280b3d952..d28db51c3db 100644 --- a/codegen/testserver/followschema/wrapped_type_test.go +++ b/codegen/testserver/followschema/wrapped_type_test.go @@ -4,10 +4,11 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestWrappedTypes(t *testing.T) { diff --git a/codegen/testserver/singlefile/complexity_test.go b/codegen/testserver/singlefile/complexity_test.go index ac8e05a8c35..4dfbdffe7df 100644 --- a/codegen/testserver/singlefile/complexity_test.go +++ b/codegen/testserver/singlefile/complexity_test.go @@ -4,10 +4,11 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" - "github.com/stretchr/testify/require" ) func TestComplexityCollisions(t *testing.T) { diff --git a/codegen/testserver/singlefile/defaults_test.go b/codegen/testserver/singlefile/defaults_test.go index 4b403ad1515..f69efcf49af 100644 --- a/codegen/testserver/singlefile/defaults_test.go +++ b/codegen/testserver/singlefile/defaults_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func assertDefaults(t *testing.T, ret *DefaultParametersMirror) { diff --git a/codegen/testserver/singlefile/defer_test.go b/codegen/testserver/singlefile/defer_test.go index 876123401ff..a5a1628da1a 100644 --- a/codegen/testserver/singlefile/defer_test.go +++ b/codegen/testserver/singlefile/defer_test.go @@ -9,11 +9,12 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestDefer(t *testing.T) { diff --git a/codegen/testserver/singlefile/directive_test.go b/codegen/testserver/singlefile/directive_test.go index 0b7cb97df82..e5df58d2e53 100644 --- a/codegen/testserver/singlefile/directive_test.go +++ b/codegen/testserver/singlefile/directive_test.go @@ -5,10 +5,11 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) type ckey string diff --git a/codegen/testserver/singlefile/embedded_test.go b/codegen/testserver/singlefile/embedded_test.go index dd9ededd14a..d3dc9a1a71c 100644 --- a/codegen/testserver/singlefile/embedded_test.go +++ b/codegen/testserver/singlefile/embedded_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) type fakeUnexportedEmbeddedInterface struct{} diff --git a/codegen/testserver/singlefile/enums_test.go b/codegen/testserver/singlefile/enums_test.go index 11ac0d1fbf7..9a12bd3fb50 100644 --- a/codegen/testserver/singlefile/enums_test.go +++ b/codegen/testserver/singlefile/enums_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestEnumsResolver(t *testing.T) { diff --git a/codegen/testserver/singlefile/fields_order_test.go b/codegen/testserver/singlefile/fields_order_test.go index eac294187f4..daff5b6a38f 100644 --- a/codegen/testserver/singlefile/fields_order_test.go +++ b/codegen/testserver/singlefile/fields_order_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) type FieldsOrderPayloadResults struct { diff --git a/codegen/testserver/singlefile/generated_test.go b/codegen/testserver/singlefile/generated_test.go index 6d1dfa7e3cc..63a6a4f2a1b 100644 --- a/codegen/testserver/singlefile/generated_test.go +++ b/codegen/testserver/singlefile/generated_test.go @@ -8,9 +8,10 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestForcedResolverFieldIsPointer(t *testing.T) { diff --git a/codegen/testserver/singlefile/input_test.go b/codegen/testserver/singlefile/input_test.go index d33081b26c6..ea05b2edfbc 100644 --- a/codegen/testserver/singlefile/input_test.go +++ b/codegen/testserver/singlefile/input_test.go @@ -6,9 +6,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestInput(t *testing.T) { diff --git a/codegen/testserver/singlefile/interfaces_test.go b/codegen/testserver/singlefile/interfaces_test.go index 23b3fb0206b..9a38a3f9420 100644 --- a/codegen/testserver/singlefile/interfaces_test.go +++ b/codegen/testserver/singlefile/interfaces_test.go @@ -6,10 +6,11 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestInterfaces(t *testing.T) { diff --git a/codegen/testserver/singlefile/introspection_test.go b/codegen/testserver/singlefile/introspection_test.go index f78a8202c10..64958e7e797 100644 --- a/codegen/testserver/singlefile/introspection_test.go +++ b/codegen/testserver/singlefile/introspection_test.go @@ -4,12 +4,13 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/introspection" - "github.com/stretchr/testify/require" ) func TestIntrospection(t *testing.T) { diff --git a/codegen/testserver/singlefile/maps_test.go b/codegen/testserver/singlefile/maps_test.go index 0c7129ae61f..1c9cbb465f7 100644 --- a/codegen/testserver/singlefile/maps_test.go +++ b/codegen/testserver/singlefile/maps_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestMaps(t *testing.T) { diff --git a/codegen/testserver/singlefile/middleware_test.go b/codegen/testserver/singlefile/middleware_test.go index 5a840d0751b..7b404d41ea2 100644 --- a/codegen/testserver/singlefile/middleware_test.go +++ b/codegen/testserver/singlefile/middleware_test.go @@ -5,12 +5,12 @@ import ( "sync" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestMiddleware(t *testing.T) { diff --git a/codegen/testserver/singlefile/modelmethod_test.go b/codegen/testserver/singlefile/modelmethod_test.go index aefb14aa7b7..a584b35b781 100644 --- a/codegen/testserver/singlefile/modelmethod_test.go +++ b/codegen/testserver/singlefile/modelmethod_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestModelMethods(t *testing.T) { diff --git a/codegen/testserver/singlefile/mutation_with_custom_scalar_test.go b/codegen/testserver/singlefile/mutation_with_custom_scalar_test.go index 3290b373e26..5237e99f2fa 100644 --- a/codegen/testserver/singlefile/mutation_with_custom_scalar_test.go +++ b/codegen/testserver/singlefile/mutation_with_custom_scalar_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestErrorInsideMutationArgument(t *testing.T) { diff --git a/codegen/testserver/singlefile/nulls_test.go b/codegen/testserver/singlefile/nulls_test.go index 853428f4851..c2609676fcd 100644 --- a/codegen/testserver/singlefile/nulls_test.go +++ b/codegen/testserver/singlefile/nulls_test.go @@ -5,9 +5,10 @@ import ( "errors" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestNullBubbling(t *testing.T) { diff --git a/codegen/testserver/singlefile/panics_test.go b/codegen/testserver/singlefile/panics_test.go index 209344d79d8..a426130618a 100644 --- a/codegen/testserver/singlefile/panics_test.go +++ b/codegen/testserver/singlefile/panics_test.go @@ -5,12 +5,12 @@ import ( "fmt" "testing" - "github.com/99designs/gqlgen/graphql" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/gqlerror" "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" - "github.com/vektah/gqlparser/v2/gqlerror" ) func TestPanics(t *testing.T) { diff --git a/codegen/testserver/singlefile/primitive_objects_test.go b/codegen/testserver/singlefile/primitive_objects_test.go index 80e7a96d7af..c16e305565f 100644 --- a/codegen/testserver/singlefile/primitive_objects_test.go +++ b/codegen/testserver/singlefile/primitive_objects_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/assert" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/assert" ) func TestPrimitiveObjects(t *testing.T) { diff --git a/codegen/testserver/singlefile/ptr_to_any_test.go b/codegen/testserver/singlefile/ptr_to_any_test.go index 88feadecc72..7ad1dcb408a 100644 --- a/codegen/testserver/singlefile/ptr_to_any_test.go +++ b/codegen/testserver/singlefile/ptr_to_any_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestPtrToAny(t *testing.T) { diff --git a/codegen/testserver/singlefile/ptr_to_ptr_input_test.go b/codegen/testserver/singlefile/ptr_to_ptr_input_test.go index 1e46e7e33c7..f5f1f381bdd 100644 --- a/codegen/testserver/singlefile/ptr_to_ptr_input_test.go +++ b/codegen/testserver/singlefile/ptr_to_ptr_input_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) type UpdatePtrToPtrResults struct { diff --git a/codegen/testserver/singlefile/ptr_to_slice_test.go b/codegen/testserver/singlefile/ptr_to_slice_test.go index 0eee0bb873f..5549ec68ab3 100644 --- a/codegen/testserver/singlefile/ptr_to_slice_test.go +++ b/codegen/testserver/singlefile/ptr_to_slice_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestPtrToSlice(t *testing.T) { diff --git a/codegen/testserver/singlefile/response_extension_test.go b/codegen/testserver/singlefile/response_extension_test.go index 9e570dbda06..8fca678027b 100644 --- a/codegen/testserver/singlefile/response_extension_test.go +++ b/codegen/testserver/singlefile/response_extension_test.go @@ -4,10 +4,11 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestResponseExtension(t *testing.T) { diff --git a/codegen/testserver/singlefile/scalar_context_test.go b/codegen/testserver/singlefile/scalar_context_test.go index 2070b0996b6..63d2ad32fb2 100644 --- a/codegen/testserver/singlefile/scalar_context_test.go +++ b/codegen/testserver/singlefile/scalar_context_test.go @@ -5,9 +5,10 @@ import ( "math" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestFloatInfAndNaN(t *testing.T) { diff --git a/codegen/testserver/singlefile/scalar_default_test.go b/codegen/testserver/singlefile/scalar_default_test.go index 556a3eccb4c..f23f6c2e825 100644 --- a/codegen/testserver/singlefile/scalar_default_test.go +++ b/codegen/testserver/singlefile/scalar_default_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestDefaultScalarImplementation(t *testing.T) { diff --git a/codegen/testserver/singlefile/slices_test.go b/codegen/testserver/singlefile/slices_test.go index b6c3e37b9ae..596e332528a 100644 --- a/codegen/testserver/singlefile/slices_test.go +++ b/codegen/testserver/singlefile/slices_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestSlices(t *testing.T) { diff --git a/codegen/testserver/singlefile/subscription_test.go b/codegen/testserver/singlefile/subscription_test.go index 567b5acd03c..6199bab6d5c 100644 --- a/codegen/testserver/singlefile/subscription_test.go +++ b/codegen/testserver/singlefile/subscription_test.go @@ -8,12 +8,12 @@ import ( "testing" "time" - "github.com/99designs/gqlgen/graphql/handler/transport" + "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestSubscriptions(t *testing.T) { diff --git a/codegen/testserver/singlefile/time_test.go b/codegen/testserver/singlefile/time_test.go index 90c8a0c5399..1a7c9f9ac37 100644 --- a/codegen/testserver/singlefile/time_test.go +++ b/codegen/testserver/singlefile/time_test.go @@ -5,9 +5,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestTime(t *testing.T) { diff --git a/codegen/testserver/singlefile/typefallback_test.go b/codegen/testserver/singlefile/typefallback_test.go index 13ba74449c9..55f49282ed2 100644 --- a/codegen/testserver/singlefile/typefallback_test.go +++ b/codegen/testserver/singlefile/typefallback_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestTypeFallback(t *testing.T) { diff --git a/codegen/testserver/singlefile/validtypes_test.go b/codegen/testserver/singlefile/validtypes_test.go index 28c5f07974c..6b27a4a3997 100644 --- a/codegen/testserver/singlefile/validtypes_test.go +++ b/codegen/testserver/singlefile/validtypes_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestValidType(t *testing.T) { diff --git a/codegen/testserver/singlefile/wrapped_type_test.go b/codegen/testserver/singlefile/wrapped_type_test.go index 13a9ccab840..98ffaa3a7cc 100644 --- a/codegen/testserver/singlefile/wrapped_type_test.go +++ b/codegen/testserver/singlefile/wrapped_type_test.go @@ -4,10 +4,11 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg" "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" ) func TestWrappedTypes(t *testing.T) { diff --git a/complexity/complexity.go b/complexity/complexity.go index e3ecf7612d5..aa0f86432ee 100644 --- a/complexity/complexity.go +++ b/complexity/complexity.go @@ -1,8 +1,9 @@ package complexity import ( - "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/graphql" ) func Calculate(es graphql.ExecutableSchema, op *ast.OperationDefinition, vars map[string]interface{}) int { diff --git a/complexity/complexity_test.go b/complexity/complexity_test.go index 0c4be24e1ca..e99acf0efb8 100644 --- a/complexity/complexity_test.go +++ b/complexity/complexity_test.go @@ -4,10 +4,11 @@ import ( "math" "testing" - "github.com/99designs/gqlgen/graphql" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/graphql" ) var schema = gqlparser.MustLoadSchema( diff --git a/docs/content/reference/scalars.md b/docs/content/reference/scalars.md index abec39910ce..137d3db8f66 100644 --- a/docs/content/reference/scalars.md +++ b/docs/content/reference/scalars.md @@ -71,6 +71,23 @@ scalar Any Maps an arbitrary GraphQL value to a `interface{}` Go type. +### Duration + +```graphql +scalar Duration +``` +This maps a `Duration` scalar value conforming to the `ISO8601` standard (ex.: `P1Y2D`) to a `time.Duration` type. + +If you add to gqlgen.yml: +```yaml +models: + Duration: + model: + - github.com/99designs/gqlgen/graphql.Duration +``` + +And then add `scalar Duration` to `schema.graphql` + ## Custom scalars with user defined types For user defined types you can implement the [graphql.Marshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#Marshaler) and [graphql.Unmarshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#Unmarshaler) or implement the [graphql.ContextMarshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#ContextMarshaler) and [graphql.ContextUnmarshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#ContextUnmarshaler) interfaces and they will be called. diff --git a/go.mod b/go.mod index f856dac1cf5..b2bbd184b19 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/mattn/go-colorable v0.1.13 github.com/mattn/go-isatty v0.0.19 github.com/mitchellh/mapstructure v1.5.0 + github.com/sosodev/duration v1.1.0 github.com/stretchr/testify v1.8.2 github.com/urfave/cli/v2 v2.25.5 github.com/vektah/gqlparser/v2 v2.5.10 diff --git a/go.sum b/go.sum index 85c8dff9fdd..46bd6ffb744 100644 --- a/go.sum +++ b/go.sum @@ -37,6 +37,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sosodev/duration v1.1.0 h1:kQcaiGbJaIsRqgQy7VGlZrVw1giWO+lDoX3MCPnpVO4= +github.com/sosodev/duration v1.1.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= diff --git a/graphql/duration.go b/graphql/duration.go new file mode 100644 index 00000000000..3eb392db87c --- /dev/null +++ b/graphql/duration.go @@ -0,0 +1,27 @@ +package graphql + +import ( + "fmt" + "time" + + dur "github.com/sosodev/duration" +) + +// UnmarshalDuration returns the duration from a string in ISO8601 format +func UnmarshalDuration(v interface{}) (time.Duration, error) { + input, ok := v.(string) + if !ok { + return 0, fmt.Errorf("input must be a string") + } + + d2, err := dur.Parse(input) + if err != nil { + return 0, err + } + return d2.ToTimeDuration(), nil +} + +// MarshalDuration returns the duration on ISO8601 format +func MarshalDuration(d time.Duration) Marshaler { + return MarshalString(dur.Format(d)) +} diff --git a/graphql/duration_test.go b/graphql/duration_test.go new file mode 100644 index 00000000000..56b6031f710 --- /dev/null +++ b/graphql/duration_test.go @@ -0,0 +1,26 @@ +package graphql + +import ( + "bytes" + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestDurationMarshaling(t *testing.T) { + t.Run("UnmarshalDuration", func(t *testing.T) { + d, err := UnmarshalDuration("P2Y") + assert.NoError(t, err) + + assert.Equal(t, float64(365*24*2), d.Hours()) + }) + t.Run("MarshalDuration", func(t *testing.T) { + m := MarshalDuration(time.Hour * 365 * 24 * 2) + + buf := new(bytes.Buffer) + m.MarshalGQL(buf) + + assert.Equal(t, "\"P2Y\"", buf.String()) + }) +} diff --git a/graphql/executor/executor.go b/graphql/executor/executor.go index c46a007b99e..ef0603eaa00 100644 --- a/graphql/executor/executor.go +++ b/graphql/executor/executor.go @@ -3,12 +3,13 @@ package executor import ( "context" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/errcode" "github.com/vektah/gqlparser/v2/ast" "github.com/vektah/gqlparser/v2/gqlerror" "github.com/vektah/gqlparser/v2/parser" "github.com/vektah/gqlparser/v2/validator" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/errcode" ) // Executor executes graphql queries against a schema. diff --git a/graphql/executor/executor_test.go b/graphql/executor/executor_test.go index cf1944bd9d6..79530c1fc7d 100644 --- a/graphql/executor/executor_test.go +++ b/graphql/executor/executor_test.go @@ -4,14 +4,15 @@ import ( "context" "testing" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/errcode" - "github.com/99designs/gqlgen/graphql/executor/testexecutor" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2/ast" "github.com/vektah/gqlparser/v2/gqlerror" "github.com/vektah/gqlparser/v2/parser" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/errcode" + "github.com/99designs/gqlgen/graphql/executor/testexecutor" ) func TestExecutor(t *testing.T) { diff --git a/graphql/executor/testexecutor/testexecutor.go b/graphql/executor/testexecutor/testexecutor.go index bf8fd9850f2..a3e0a300dc3 100644 --- a/graphql/executor/testexecutor/testexecutor.go +++ b/graphql/executor/testexecutor/testexecutor.go @@ -8,10 +8,11 @@ import ( "io" "time" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/executor" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/executor" ) type MockResponse struct { diff --git a/graphql/handler/apollofederatedtracingv1/tracing.go b/graphql/handler/apollofederatedtracingv1/tracing.go index b186201bebe..1c969b4f64a 100644 --- a/graphql/handler/apollofederatedtracingv1/tracing.go +++ b/graphql/handler/apollofederatedtracingv1/tracing.go @@ -5,8 +5,9 @@ import ( "encoding/base64" "fmt" - "github.com/99designs/gqlgen/graphql" "google.golang.org/protobuf/proto" + + "github.com/99designs/gqlgen/graphql" ) type ( diff --git a/graphql/handler/apollofederatedtracingv1/tracing_test.go b/graphql/handler/apollofederatedtracingv1/tracing_test.go index 7217217ed6f..aa05de71277 100644 --- a/graphql/handler/apollofederatedtracingv1/tracing_test.go +++ b/graphql/handler/apollofederatedtracingv1/tracing_test.go @@ -12,6 +12,11 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/gqlerror" + "google.golang.org/protobuf/proto" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler/apollofederatedtracingv1" "github.com/99designs/gqlgen/graphql/handler/apollofederatedtracingv1/generated" @@ -19,10 +24,6 @@ import ( "github.com/99designs/gqlgen/graphql/handler/lru" "github.com/99designs/gqlgen/graphql/handler/testserver" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/vektah/gqlparser/v2/gqlerror" - "google.golang.org/protobuf/proto" ) type alwaysError struct{} diff --git a/graphql/handler/apollofederatedtracingv1/tree_builder.go b/graphql/handler/apollofederatedtracingv1/tree_builder.go index a54b12db580..e211e626c0f 100644 --- a/graphql/handler/apollofederatedtracingv1/tree_builder.go +++ b/graphql/handler/apollofederatedtracingv1/tree_builder.go @@ -6,9 +6,10 @@ import ( "sync" "time" + "google.golang.org/protobuf/types/known/timestamppb" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler/apollofederatedtracingv1/generated" - "google.golang.org/protobuf/types/known/timestamppb" ) type TreeBuilder struct { diff --git a/graphql/handler/apollotracing/tracer.go b/graphql/handler/apollotracing/tracer.go index d1e92bbfdcd..0d5fc597c05 100644 --- a/graphql/handler/apollotracing/tracer.go +++ b/graphql/handler/apollotracing/tracer.go @@ -5,8 +5,9 @@ import ( "sync" "time" - "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/graphql" ) type ( diff --git a/graphql/handler/apollotracing/tracer_test.go b/graphql/handler/apollotracing/tracer_test.go index 789448cae9a..74e4e6e127d 100644 --- a/graphql/handler/apollotracing/tracer_test.go +++ b/graphql/handler/apollotracing/tracer_test.go @@ -9,16 +9,17 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler/apollotracing" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/lru" "github.com/99designs/gqlgen/graphql/handler/testserver" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/vektah/gqlparser/v2/ast" - "github.com/vektah/gqlparser/v2/gqlerror" ) type alwaysError struct{} diff --git a/graphql/handler/extension/apq.go b/graphql/handler/extension/apq.go index 866276eed99..465c2ada61a 100644 --- a/graphql/handler/extension/apq.go +++ b/graphql/handler/extension/apq.go @@ -6,12 +6,11 @@ import ( "encoding/hex" "fmt" - "github.com/99designs/gqlgen/graphql/errcode" - + "github.com/mitchellh/mapstructure" "github.com/vektah/gqlparser/v2/gqlerror" "github.com/99designs/gqlgen/graphql" - "github.com/mitchellh/mapstructure" + "github.com/99designs/gqlgen/graphql/errcode" ) const ( diff --git a/graphql/handler/extension/apq_test.go b/graphql/handler/extension/apq_test.go index 66970c62e9c..92b06a51339 100644 --- a/graphql/handler/extension/apq_test.go +++ b/graphql/handler/extension/apq_test.go @@ -5,11 +5,12 @@ import ( "net/http" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/testserver" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/stretchr/testify/require" ) func TestAPQIntegration(t *testing.T) { diff --git a/graphql/handler/extension/complexity.go b/graphql/handler/extension/complexity.go index e88848d18c3..a5b6a60409b 100644 --- a/graphql/handler/extension/complexity.go +++ b/graphql/handler/extension/complexity.go @@ -4,10 +4,11 @@ import ( "context" "fmt" + "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/99designs/gqlgen/complexity" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/errcode" - "github.com/vektah/gqlparser/v2/gqlerror" ) const errComplexityLimit = "COMPLEXITY_LIMIT_EXCEEDED" diff --git a/graphql/handler/extension/complexity_test.go b/graphql/handler/extension/complexity_test.go index e533403e1a5..5141f43ee44 100644 --- a/graphql/handler/extension/complexity_test.go +++ b/graphql/handler/extension/complexity_test.go @@ -7,11 +7,12 @@ import ( "strings" "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/testserver" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/stretchr/testify/require" ) func TestHandlerComplexity(t *testing.T) { diff --git a/graphql/handler/extension/introspection.go b/graphql/handler/extension/introspection.go index acc5db2fbcc..8e3912651d7 100644 --- a/graphql/handler/extension/introspection.go +++ b/graphql/handler/extension/introspection.go @@ -3,8 +3,9 @@ package extension import ( "context" - "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/99designs/gqlgen/graphql" ) // EnableIntrospection enables clients to reflect all of the types available on the graph. diff --git a/graphql/handler/extension/introspection_test.go b/graphql/handler/extension/introspection_test.go index e001eb529f0..f719c262a6b 100644 --- a/graphql/handler/extension/introspection_test.go +++ b/graphql/handler/extension/introspection_test.go @@ -4,8 +4,9 @@ import ( "context" "testing" - "github.com/99designs/gqlgen/graphql" "github.com/stretchr/testify/require" + + "github.com/99designs/gqlgen/graphql" ) func TestIntrospection(t *testing.T) { diff --git a/graphql/handler/lru/lru.go b/graphql/handler/lru/lru.go index 68241ababf9..6ae8a38e644 100644 --- a/graphql/handler/lru/lru.go +++ b/graphql/handler/lru/lru.go @@ -3,8 +3,9 @@ package lru import ( "context" - "github.com/99designs/gqlgen/graphql" lru "github.com/hashicorp/golang-lru/v2" + + "github.com/99designs/gqlgen/graphql" ) type LRU struct { diff --git a/graphql/handler/server.go b/graphql/handler/server.go index b6524d8da13..fd365ccbbf7 100644 --- a/graphql/handler/server.go +++ b/graphql/handler/server.go @@ -7,12 +7,13 @@ import ( "net/http" "time" + "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/executor" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/lru" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/vektah/gqlparser/v2/gqlerror" ) type ( diff --git a/graphql/handler/server_test.go b/graphql/handler/server_test.go index b1ac60fb492..4b31c09ac41 100644 --- a/graphql/handler/server_test.go +++ b/graphql/handler/server_test.go @@ -8,14 +8,15 @@ import ( "net/url" "testing" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/handler/testserver" - "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2/ast" "github.com/vektah/gqlparser/v2/gqlerror" "github.com/vektah/gqlparser/v2/parser" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestServer(t *testing.T) { diff --git a/graphql/handler/testserver/testserver.go b/graphql/handler/testserver/testserver.go index 9556d6828a9..85dc7d2899c 100644 --- a/graphql/handler/testserver/testserver.go +++ b/graphql/handler/testserver/testserver.go @@ -5,10 +5,11 @@ import ( "fmt" "time" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/handler" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler" ) // New provides a server for use in tests that isn't relying on generated code. It isnt a perfect reproduction of diff --git a/graphql/handler/transport/error.go b/graphql/handler/transport/error.go index b1aeaf144dd..18f09f55676 100644 --- a/graphql/handler/transport/error.go +++ b/graphql/handler/transport/error.go @@ -5,8 +5,9 @@ import ( "fmt" "net/http" - "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/99designs/gqlgen/graphql" ) // SendError sends a best effort error to a raw response writer. It assumes the client can understand the standard diff --git a/graphql/handler/transport/headers_test.go b/graphql/handler/transport/headers_test.go index 4673522de71..93fa4bf6b6a 100644 --- a/graphql/handler/transport/headers_test.go +++ b/graphql/handler/transport/headers_test.go @@ -6,14 +6,15 @@ import ( "net/http/httptest" "testing" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/handler" - "github.com/99designs/gqlgen/graphql/handler/testserver" - "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestHeadersWithPOST(t *testing.T) { diff --git a/graphql/handler/transport/http_form_multipart_test.go b/graphql/handler/transport/http_form_multipart_test.go index 4eb636378b1..6d7c327933a 100644 --- a/graphql/handler/transport/http_form_multipart_test.go +++ b/graphql/handler/transport/http_form_multipart_test.go @@ -11,12 +11,13 @@ import ( "net/textproto" "testing" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/handler" - "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestFileUpload(t *testing.T) { diff --git a/graphql/handler/transport/http_form_urlencode_test.go b/graphql/handler/transport/http_form_urlencode_test.go index 8eecf449e15..fb984167a0c 100644 --- a/graphql/handler/transport/http_form_urlencode_test.go +++ b/graphql/handler/transport/http_form_urlencode_test.go @@ -7,9 +7,10 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" + "github.com/99designs/gqlgen/graphql/handler/testserver" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/stretchr/testify/assert" ) func TestUrlEncodedForm(t *testing.T) { diff --git a/graphql/handler/transport/http_get.go b/graphql/handler/transport/http_get.go index 324fd986834..9a47bfbef87 100644 --- a/graphql/handler/transport/http_get.go +++ b/graphql/handler/transport/http_get.go @@ -7,10 +7,11 @@ import ( "net/url" "strings" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/errcode" "github.com/vektah/gqlparser/v2/ast" "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/errcode" ) // GET implements the GET side of the default HTTP transport diff --git a/graphql/handler/transport/http_get_test.go b/graphql/handler/transport/http_get_test.go index 5e46d231855..6e0dde07f5c 100644 --- a/graphql/handler/transport/http_get_test.go +++ b/graphql/handler/transport/http_get_test.go @@ -4,9 +4,10 @@ import ( "net/http" "testing" + "github.com/stretchr/testify/assert" + "github.com/99designs/gqlgen/graphql/handler/testserver" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/stretchr/testify/assert" ) func TestGET(t *testing.T) { diff --git a/graphql/handler/transport/http_graphql_test.go b/graphql/handler/transport/http_graphql_test.go index e1add4a498d..53fb891f000 100644 --- a/graphql/handler/transport/http_graphql_test.go +++ b/graphql/handler/transport/http_graphql_test.go @@ -7,9 +7,10 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" + "github.com/99designs/gqlgen/graphql/handler/testserver" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/stretchr/testify/assert" ) func TestGRAPHQL(t *testing.T) { diff --git a/graphql/handler/transport/http_post_test.go b/graphql/handler/transport/http_post_test.go index a26ba12912e..a7ecd7d5eb0 100644 --- a/graphql/handler/transport/http_post_test.go +++ b/graphql/handler/transport/http_post_test.go @@ -7,9 +7,10 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" + "github.com/99designs/gqlgen/graphql/handler/testserver" "github.com/99designs/gqlgen/graphql/handler/transport" - "github.com/stretchr/testify/assert" ) func TestPOST(t *testing.T) { diff --git a/graphql/handler/transport/util.go b/graphql/handler/transport/util.go index ce845c1964c..19b7521c08f 100644 --- a/graphql/handler/transport/util.go +++ b/graphql/handler/transport/util.go @@ -5,8 +5,9 @@ import ( "fmt" "io" - "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/99designs/gqlgen/graphql" ) func writeJson(w io.Writer, response *graphql.Response) { diff --git a/graphql/handler/transport/websocket.go b/graphql/handler/transport/websocket.go index 1969f9e2855..e1334b92904 100644 --- a/graphql/handler/transport/websocket.go +++ b/graphql/handler/transport/websocket.go @@ -12,10 +12,11 @@ import ( "sync" "time" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/errcode" "github.com/gorilla/websocket" "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/errcode" ) type ( diff --git a/graphql/handler/transport/websocket_test.go b/graphql/handler/transport/websocket_test.go index f05a9df1898..e9336772487 100644 --- a/graphql/handler/transport/websocket_test.go +++ b/graphql/handler/transport/websocket_test.go @@ -10,16 +10,17 @@ import ( "testing" "time" - "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/handler" - "github.com/99designs/gqlgen/graphql/handler/testserver" - "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/gorilla/websocket" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/testserver" + "github.com/99designs/gqlgen/graphql/handler/transport" ) type ckey string diff --git a/handler/handler.go b/handler/handler.go index 19491020de1..08e6a4c0e11 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -5,13 +5,14 @@ import ( "net/http" "time" + "github.com/gorilla/websocket" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/lru" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" - "github.com/gorilla/websocket" ) // Deprecated: switch to graphql/handler.New diff --git a/integration/server/cmd/integration/server.go b/integration/server/cmd/integration/server.go index fec1c4827a0..df542a40456 100644 --- a/integration/server/cmd/integration/server.go +++ b/integration/server/cmd/integration/server.go @@ -8,6 +8,8 @@ import ( "os" "time" + "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" @@ -15,7 +17,6 @@ import ( "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" "github.com/99designs/gqlgen/integration/server" - "github.com/vektah/gqlparser/v2/gqlerror" ) const defaultPort = "8080" diff --git a/internal/imports/prune.go b/internal/imports/prune.go index d42a4157913..f5fc71c6971 100644 --- a/internal/imports/prune.go +++ b/internal/imports/prune.go @@ -10,10 +10,10 @@ import ( "go/token" "strings" - "github.com/99designs/gqlgen/internal/code" - "golang.org/x/tools/go/ast/astutil" "golang.org/x/tools/imports" + + "github.com/99designs/gqlgen/internal/code" ) type visitFn func(node ast.Node) diff --git a/internal/imports/prune_test.go b/internal/imports/prune_test.go index 0006aec9ac0..d312aff6bc0 100644 --- a/internal/imports/prune_test.go +++ b/internal/imports/prune_test.go @@ -5,8 +5,9 @@ import ( "strings" "testing" - "github.com/99designs/gqlgen/internal/code" "github.com/stretchr/testify/require" + + "github.com/99designs/gqlgen/internal/code" ) func TestPrune(t *testing.T) { diff --git a/internal/imports/testdata/unused.expected.go b/internal/imports/testdata/unused.expected.go index 95cbe2d00ff..f9d393d7eec 100644 --- a/internal/imports/testdata/unused.expected.go +++ b/internal/imports/testdata/unused.expected.go @@ -3,6 +3,7 @@ package testdata import ( a "fmt" "time" + _ "underscore" ) diff --git a/internal/imports/testdata/unused.go b/internal/imports/testdata/unused.go index 95cbe2d00ff..f9d393d7eec 100644 --- a/internal/imports/testdata/unused.go +++ b/internal/imports/testdata/unused.go @@ -3,6 +3,7 @@ package testdata import ( a "fmt" "time" + _ "underscore" ) diff --git a/internal/rewrite/rewriter.go b/internal/rewrite/rewriter.go index 1ca722dcfd4..7e68e55de99 100644 --- a/internal/rewrite/rewriter.go +++ b/internal/rewrite/rewriter.go @@ -10,8 +10,9 @@ import ( "strconv" "strings" - "github.com/99designs/gqlgen/internal/code" "golang.org/x/tools/go/packages" + + "github.com/99designs/gqlgen/internal/code" ) type Rewriter struct { diff --git a/internal/rewrite/rewriter_test.go b/internal/rewrite/rewriter_test.go index fae86668fb0..9ac5ffb0e7f 100644 --- a/internal/rewrite/rewriter_test.go +++ b/internal/rewrite/rewriter_test.go @@ -26,14 +26,14 @@ func TestRewriter(t *testing.T) { imps := r.ExistingImports("testdata/example.go") require.Len(t, imps, 2) assert.Equal(t, []Import{ - { - Alias: "", - ImportPath: "fmt", - }, { Alias: "lol", ImportPath: "bytes", }, + { + Alias: "", + ImportPath: "fmt", + }, }, imps) }) diff --git a/internal/rewrite/testdata/example.go b/internal/rewrite/testdata/example.go index 949bbe8235d..6a3297ad2b9 100644 --- a/internal/rewrite/testdata/example.go +++ b/internal/rewrite/testdata/example.go @@ -1,9 +1,8 @@ package testdata import ( - "fmt" - lol "bytes" + "fmt" ) type Foo struct { diff --git a/main.go b/main.go index af365bfeb99..e0420d15028 100644 --- a/main.go +++ b/main.go @@ -12,12 +12,13 @@ import ( "os" "path/filepath" + "github.com/urfave/cli/v2" + "github.com/99designs/gqlgen/api" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/internal/code" "github.com/99designs/gqlgen/plugin/servergen" - "github.com/urfave/cli/v2" ) //go:embed init-templates/schema.graphqls diff --git a/plugin/federation/entity.go b/plugin/federation/entity.go index 04a3c033b06..042dd59ad77 100644 --- a/plugin/federation/entity.go +++ b/plugin/federation/entity.go @@ -3,10 +3,11 @@ package federation import ( "go/types" + "github.com/vektah/gqlparser/v2/ast" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" "github.com/99designs/gqlgen/plugin/federation/fieldset" - "github.com/vektah/gqlparser/v2/ast" ) // Entity represents a federated type diff --git a/plugin/federation/federation_entityresolver_test.go b/plugin/federation/federation_entityresolver_test.go index 4cbc1602458..cd96c5d498a 100644 --- a/plugin/federation/federation_entityresolver_test.go +++ b/plugin/federation/federation_entityresolver_test.go @@ -7,10 +7,10 @@ import ( "strings" "testing" - "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/plugin/federation/testdata/entityresolver" "github.com/99designs/gqlgen/plugin/federation/testdata/entityresolver/generated" ) diff --git a/plugin/federation/federation_test.go b/plugin/federation/federation_test.go index cc5b20ee3bc..14587431743 100644 --- a/plugin/federation/federation_test.go +++ b/plugin/federation/federation_test.go @@ -3,9 +3,10 @@ package federation import ( "testing" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" - "github.com/stretchr/testify/require" ) func TestWithEntities(t *testing.T) { diff --git a/plugin/federation/fieldset/fieldset.go b/plugin/federation/fieldset/fieldset.go index 059a3c8325a..59e47753688 100644 --- a/plugin/federation/fieldset/fieldset.go +++ b/plugin/federation/fieldset/fieldset.go @@ -4,9 +4,10 @@ import ( "fmt" "strings" + "github.com/vektah/gqlparser/v2/ast" + "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/templates" - "github.com/vektah/gqlparser/v2/ast" ) // Set represents a FieldSet that is used in federation directives @key and @requires. diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index 4383d76c92a..798a936f579 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -9,10 +9,11 @@ import ( "strings" "text/template" + "github.com/vektah/gqlparser/v2/ast" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" "github.com/99designs/gqlgen/plugin" - "github.com/vektah/gqlparser/v2/ast" ) //go:embed models.gotpl diff --git a/plugin/modelgen/models_test.go b/plugin/modelgen/models_test.go index 8607615772e..a9182d02f02 100644 --- a/plugin/modelgen/models_test.go +++ b/plugin/modelgen/models_test.go @@ -14,6 +14,9 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/plugin/modelgen/internal/extrafields" @@ -23,8 +26,6 @@ import ( "github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_true" "github.com/99designs/gqlgen/plugin/modelgen/out_nullable_input_omittable" "github.com/99designs/gqlgen/plugin/modelgen/out_struct_pointers" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestModelGeneration(t *testing.T) { diff --git a/plugin/plugin.go b/plugin/plugin.go index 69801c8816a..214c58d9e18 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -3,9 +3,10 @@ package plugin import ( + "github.com/vektah/gqlparser/v2/ast" + "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" - "github.com/vektah/gqlparser/v2/ast" ) type Plugin interface { diff --git a/plugin/resolvergen/resolver_test.go b/plugin/resolvergen/resolver_test.go index 2cf9713f7c5..17650e8f200 100644 --- a/plugin/resolvergen/resolver_test.go +++ b/plugin/resolvergen/resolver_test.go @@ -6,10 +6,11 @@ import ( "syscall" "testing" - "github.com/99designs/gqlgen/codegen" - "github.com/99designs/gqlgen/codegen/config" "github.com/stretchr/testify/require" "golang.org/x/tools/go/packages" + + "github.com/99designs/gqlgen/codegen" + "github.com/99designs/gqlgen/codegen/config" ) func TestLayoutSingleFile(t *testing.T) { diff --git a/plugin/stubgen/stubs.go b/plugin/stubgen/stubs.go index 01db65b1f9b..8f1b81293cf 100644 --- a/plugin/stubgen/stubs.go +++ b/plugin/stubgen/stubs.go @@ -5,11 +5,10 @@ import ( "path/filepath" "syscall" - "github.com/99designs/gqlgen/internal/code" - "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/internal/code" "github.com/99designs/gqlgen/plugin" )