热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

WhenItrytobuildmyprojectinsidedockeritthrowsanerror

ExpectedBehaviourIntheprevversionofgqlgeneverythingwasfineandwor


Expected Behaviour

In the prev version of gqlgen everything was fine and worked great but after release, it does not work

Actual Behavior

When I run my code on local machine it works but when I start to build dockerfile it throws an error

1
graphTry/server/server.go:22:68: cannot use graphTry.NewExecutableSchema(graphTry.Config literal) (type "github.com/USERNAME/user-name/vendor/github.com/99designs/gqlgen/graphql".ExecutableSchema) as type "github.com/99designs/gqlgen/graphql".ExecutableSchema in argument to handler.GraphQL: "github.com/Username/user-name/vendor/github.com/99designs/gqlgen/graphql".ExecutableSchema does not implement "github.com/99designs/gqlgen/graphql".ExecutableSchema (wrong type for Mutation method) have Mutation(context.Context, *"github.com/Username/user-name/vendor/github.com/vektah/gqlparser/ast".OperationDefinition) *"github.com/Username/user-name/vendor/github.com/99designs/gqlgen/graphql".Response want Mutation(context.Context, *"github.com/vektah/gqlparser/ast".OperationDefinition) *"github.com/99designs/gqlgen/graphql".Response

my main file looks like this
` package main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 import (

    //"Stack/overflow/finance/graphTry"

    "github.com/Username/user-name/graphTry"

    "net/http"

     "os"

     "github.com/99designs/gqlgen/handler"

     "github.com/go-chi/chi"

     "github.com/rs/cors"



 )



 const defaultPort = "8080"



func main() {

    port := os.Getenv("PORT")

    if port == "" {

        port = defaultPort

    }



    router := chi.NewRouter()





router.Use(cors.New(cors.Options{

    AllowedOrigins:   []string{"*"},

    AllowCredentials: true,

    Debug:            true,

}).Handler)





router.Handle("/", handler.Playground("graphtry", "/query"))

router.Handle("/query",



  handler.GraphQL(graphTry.NewExecutableSchema(graphTry.Config{Resolvers:

         &graphTry.Resolver{}})),

    )



   err := http.ListenAndServe(":8080", router)

       if err != nil {

          panic(err)

       }

   }`

and my dockerfile

`FROM golang:1.10.2-alpine3.7 AS build
RUN apk --no-cache add gcc g++ make ca-certificates

WORKDIR /home/username/go/src/Stack/overflow/finance
RUN ls
RUN pwd
COPY . .
RUN pwd

RUN apk update && apk add git
RUN go get github.com/golang/protobuf/jsonpb
RUN go get github.com/golang/protobuf/proto
RUN go get github.com/lib/pq
RUN go get github.com/twitchtv/twirp
RUN go get github.com/twitchtv/twirp/ctxsetters

RUN go get github.com/99designs/gqlgen/graphql
RUN go get github.com/99designs/gqlgen/graphql/introspection
RUN go get github.com/vektah/gqlparser
RUN go get github.com/vektah/gqlparser/ast
RUN go get github.com/99designs/gqlgen/cmd
RUN go get github.com/99designs/gqlgen/handler
RUN go get github.com/Username/user-name/server
RUN go get github.com/Username/user-name/rpc/finance
RUN go get github.com/Username/user-name/graphTry

RUN go get github.com/go-chi/chi
RUN go get github.com/rs/cors
RUN go get github.com/vektah/gqlparser

RUN go build -o /go/bin/stackexample ./graphTry/server/server.go

FROM alpine:3.7 as final
WORKDIR /usr/bin
COPY --from=build /go/bin .
EXPOSE 8080
CMD ["./stackexample"]`

Minimal graphql.schema and models to reproduce

该提问来源于开源项目:99designs/gqlgen

If it helps anyone, I had to change the version to 0.10.1 (in mod file) and the errors are gone





   



推荐阅读
author-avatar
起飞吧和谐号况
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有