aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/99designs/gqlgen/handler/mock.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-05-15 18:20:54 +0200
committerGitHub <noreply@github.com>2019-05-15 18:20:54 +0200
commit22f435bd2a8fc35bde96eafb50b3f78650a5983b (patch)
tree629b72f3d95ac7b7806fb83096a3b89e14f745ef /vendor/github.com/99designs/gqlgen/handler/mock.go
parent97476ff5fadaf0a457d0f0133db58415b6075940 (diff)
parent8bab279114f06f10e22435b0caf9002201831555 (diff)
downloadgit-bug-22f435bd2a8fc35bde96eafb50b3f78650a5983b.tar.gz
Merge pull request #134 from A-Hilaly/gqlgen
Upgrade gqlgen version to v0.9.0
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/handler/mock.go')
-rw-r--r--vendor/github.com/99designs/gqlgen/handler/mock.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/vendor/github.com/99designs/gqlgen/handler/mock.go b/vendor/github.com/99designs/gqlgen/handler/mock.go
new file mode 100644
index 00000000..3e70cf03
--- /dev/null
+++ b/vendor/github.com/99designs/gqlgen/handler/mock.go
@@ -0,0 +1,57 @@
+package handler
+
+import (
+ "context"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/vektah/gqlparser"
+ "github.com/vektah/gqlparser/ast"
+)
+
+type executableSchemaMock struct {
+ MutationFunc func(ctx context.Context, op *ast.OperationDefinition) *graphql.Response
+}
+
+var _ graphql.ExecutableSchema = &executableSchemaMock{}
+
+func (e *executableSchemaMock) Schema() *ast.Schema {
+ return gqlparser.MustLoadSchema(&ast.Source{Input: `
+ schema { query: Query, mutation: Mutation }
+ type Query {
+ empty: String!
+ }
+ scalar Upload
+ type File {
+ id: Int!
+ }
+ input UploadFile {
+ id: Int!
+ file: Upload!
+ }
+ type Mutation {
+ singleUpload(file: Upload!): File!
+ singleUploadWithPayload(req: UploadFile!): File!
+ multipleUpload(files: [Upload!]!): [File!]!
+ multipleUploadWithPayload(req: [UploadFile!]!): [File!]!
+ }
+ `})
+}
+
+func (e *executableSchemaMock) Complexity(typeName, field string, childComplexity int, args map[string]interface{}) (int, bool) {
+ return 0, false
+}
+
+func (e *executableSchemaMock) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {
+ return graphql.ErrorResponse(ctx, "queries are not supported")
+}
+
+func (e *executableSchemaMock) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {
+ return e.MutationFunc(ctx, op)
+}
+
+func (e *executableSchemaMock) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {
+ return func() *graphql.Response {
+ <-ctx.Done()
+ return nil
+ }
+}