From 588e0d4362f48be9c4f01284e9e9aba59714e6e5 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Mon, 12 Aug 2024 18:23:13 -0600 Subject: [PATCH] Adding workaround for updated gqlclient error wrapping --- client.go | 4 ++++ cmd/test/helpers.go | 19 +++++++++++++++---- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/client.go b/client.go index ae0db90..ed5e7e2 100644 --- a/client.go +++ b/client.go @@ -80,5 +80,9 @@ func Execute(ctx context.Context, op *gqlclient.Operation, result interface{}) e client = gqlclient.New(origin, httpClient) err := client.Execute(ctx, op, &result) + if graphErrors, ok := err.(interface{ Unwrap() []error }); ok { + errs := graphErrors.Unwrap() + err = errs[0] + } return err } diff --git a/cmd/test/helpers.go b/cmd/test/helpers.go index d096afc..5e500f6 100644 --- a/cmd/test/helpers.go +++ b/cmd/test/helpers.go @@ -28,6 +28,7 @@ import ( "github.com/99designs/gqlgen/graphql" "github.com/labstack/echo/v4" formguard "netlandish.com/x/gobwebs-formguard" + gobwebsgql "netlandish.com/x/gobwebs-graphql" oauth2 "netlandish.com/x/gobwebs-oauth2" feedback "netlandish.com/x/gobwebs-ses-feedback" gaccts "netlandish.com/x/gobwebs/accounts" @@ -172,10 +173,20 @@ func NewAPITestServer(t *testing.T) (*server.Server, *echo.Echo, string) { core.TimezoneContext(), crypto.Middleware(entropy), core.InternalAuthMiddleware(accounts.NewUserFetch()), - ). - WithSchema(schema, []string{ - "PROFILE", "LINKS", "ORGS", "DOMAINS", "BILLING", "ANALYTICS", "LISTS", "SHORTS", - }) + ) + + gqlGroup := e.Group("") + ext := gobwebsgql.NewGQLExtension(gqlGroup, schema, []string{ + "PROFILE", "LINKS", "ORGS", "DOMAINS", + "BILLING", "ANALYTICS", "LISTS", "SHORTS", + "QRCODES", + }) + + srv, err = srv.Extend(ext) + if err != nil { + t.Fatalf("Error extending server with graphql: %v\n", err) + } + srv.AddFuncs(template.FuncMap{ "buildURL": func(path string) string { baseURL := fmt.Sprintf("%s://%s", config.Scheme, config.Domain) diff --git a/go.mod b/go.mod index 22d2a5f..9f685f0 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( golang.org/x/text v0.16.0 netlandish.com/x/gobwebs v0.0.0-20240808204501-9f6e2ce74938 netlandish.com/x/gobwebs-formguard v0.0.0-20231224192353-29706d23f156 - netlandish.com/x/gobwebs-graphql v0.0.0-20240808204814-d5296213dffe + netlandish.com/x/gobwebs-graphql v0.0.0-20240813002048-cb0738b34957 netlandish.com/x/gobwebs-oauth2 v0.0.0-20240216010400-f0f42e2e3a7c netlandish.com/x/gobwebs-ses-feedback v0.0.0-20231224192331-d90c2b73e55d petersanchez.com/x/carrier v0.2.1 diff --git a/go.sum b/go.sum index ca429d6..5446efd 100644 --- a/go.sum +++ b/go.sum @@ -2585,8 +2585,8 @@ netlandish.com/x/gobwebs v0.0.0-20240808204501-9f6e2ce74938 h1:yJTZPnjffK+CJlael netlandish.com/x/gobwebs v0.0.0-20240808204501-9f6e2ce74938/go.mod h1:q3yov9FuD8gSfERwdfNoAv73dzilRFZBJ3RHEOMuNMI= netlandish.com/x/gobwebs-formguard v0.0.0-20231224192353-29706d23f156 h1:kbYL/3PDS6Pt5uE5QJWkVIgd+kzUgUUb3IKhAth35Bc= netlandish.com/x/gobwebs-formguard v0.0.0-20231224192353-29706d23f156/go.mod h1:+73MG8iQ7+cs1rbcbgBEJd5so1TyFNmqrwLNKtDUAvg= -netlandish.com/x/gobwebs-graphql v0.0.0-20240808204814-d5296213dffe h1:AXkvf2JGpMGOm7VAJzgL73SBGo4ao+3khQfMBC+AVxU= -netlandish.com/x/gobwebs-graphql v0.0.0-20240808204814-d5296213dffe/go.mod h1:ReVNw5lGqLm1kxtTLXEIL4+hVNE2WjjBcoBtRfH9uWQ= +netlandish.com/x/gobwebs-graphql v0.0.0-20240813002048-cb0738b34957 h1:nyK91IZXByLuuiOAAAKz5oMceo18qAJfNNe9UFYWESw= +netlandish.com/x/gobwebs-graphql v0.0.0-20240813002048-cb0738b34957/go.mod h1:ReVNw5lGqLm1kxtTLXEIL4+hVNE2WjjBcoBtRfH9uWQ= netlandish.com/x/gobwebs-oauth2 v0.0.0-20240216010400-f0f42e2e3a7c h1:OiR7uZB8Ix33d6uZcNucqWC53XQlJLqH5MyskIaFD20= netlandish.com/x/gobwebs-oauth2 v0.0.0-20240216010400-f0f42e2e3a7c/go.mod h1:YFuvoy5GEi60A+UfPZyC87DTAwFLrvUldZL6dr+ks1o= netlandish.com/x/gobwebs-ses-feedback v0.0.0-20231224192331-d90c2b73e55d h1:Qof6jqwfFMcmw08Qh5UocDsqjNIvpsZwZuxGqhbh8GE= -- 2.45.2