diff --git a/invocation.go b/invocation.go index 234e580..6574cfb 100644 --- a/invocation.go +++ b/invocation.go @@ -2,15 +2,16 @@ package resolvers import "encoding/json" -type context struct { +// ContextData data received from AppSync +type ContextData struct { Arguments json.RawMessage `json:"arguments"` Source json.RawMessage `json:"source"` } // Invocation data received from AppSync type Invocation struct { - Resolve string `json:"resolve"` - Context context `json:"context"` + Resolve string `json:"resolve"` + Context ContextData `json:"context"` } func (in Invocation) isRoot() bool { diff --git a/invocation_test.go b/invocation_test.go index 8c91fd1..5e66ebd 100644 --- a/invocation_test.go +++ b/invocation_test.go @@ -11,7 +11,7 @@ var _ = Describe("Invocation", func() { Context("With Arguments", func() { data := Invocation{ Resolve: "exaple.resolver", - Context: context{ + Context: ContextData{ Arguments: json.RawMessage(`{ "foo": "bar" }`), }, } @@ -28,7 +28,7 @@ var _ = Describe("Invocation", func() { Context("With Source", func() { data := Invocation{ Resolve: "exaple.resolver", - Context: context{ + Context: ContextData{ Source: json.RawMessage(`{ "bar": "foo" }`), }, } diff --git a/middleware_test.go b/middleware_test.go index 2c18160..720bf1a 100644 --- a/middleware_test.go +++ b/middleware_test.go @@ -69,7 +69,7 @@ var _ = Describe("Middleware", func() { }) res, err := r.Handle(Invocation{ Resolve: "example.resolver", - Context: context{ + Context: ContextData{ Arguments: json.RawMessage(`{"bar":"foo"}`), }, }) @@ -124,7 +124,7 @@ var _ = Describe("Middleware", func() { }) res, err := r.Handle(Invocation{ Resolve: "example.resolver", - Context: context{ + Context: ContextData{ Arguments: json.RawMessage(`{"bar":"foo"}`), }, }) diff --git a/repository_test.go b/repository_test.go index a5eb100..3ca3ac6 100644 --- a/repository_test.go +++ b/repository_test.go @@ -22,7 +22,7 @@ var _ = Describe("Repository", func() { Context("Matching invocation", func() { res, err := r.Handle(Invocation{ Resolve: "example.resolver", - Context: context{ + Context: ContextData{ Arguments: json.RawMessage(`{"bar":"foo"}`), }, }) @@ -39,7 +39,7 @@ var _ = Describe("Repository", func() { Context("Matching invocation with error", func() { _, err := r.Handle(Invocation{ Resolve: "example.resolver.with.error", - Context: context{ + Context: ContextData{ Arguments: json.RawMessage(`{"bar":"foo"}`), }, }) @@ -52,7 +52,7 @@ var _ = Describe("Repository", func() { Context("Matching invocation with invalid payload", func() { _, err := r.Handle(Invocation{ Resolve: "example.resolver.with.error", - Context: context{ + Context: ContextData{ Arguments: json.RawMessage(`{"bar:foo"}`), }, }) @@ -65,7 +65,7 @@ var _ = Describe("Repository", func() { Context("Not matching invocation", func() { res, err := r.Handle(Invocation{ Resolve: "example.resolver.not.found", - Context: context{ + Context: ContextData{ Arguments: json.RawMessage(`{"bar":"foo"}`), }, })