gqlgen初体验(一)

2021-05-01  本文已影响0人  戈壁堂

Building a GraphQL API in Go using gqlgen

依次执行以下命令,则完成了gqlgen站点的getting started的内容。

cd mygplprj/src
go mod init gitlab.com/jigar_xyz/mygplprj
cd cmd/go-graphql
go get github.com/99designs/gqlgen
go run github.com/99designs/gqlgen init --verbose

执行go run ./server.go就可以起到一个GraghQL站点。目录结构说明——

├── gqlgen.yml               - The gqlgen config file, knobs for controlling the generated code.
├── graph
│   ├── generated            - A package that only contains the generated runtime
│   │   └── generated.go
│   ├── model                - A package for all your graph models, generated or otherwise
│   │   └── models_gen.go
│   ├── resolver.go          - The root graph resolver type. This file wont get regenerated
│   ├── schema.graphqls      - Some schema. You can split the schema into as many graphql files as you like
│   └── schema.resolvers.go  - the resolver implementation for schema.graphql
└── server.go                - The entry point to your app. Customize it however you see fit

Introducing gqlgen: a GraphQL Server Generator for Go 项目开发人员对gqlgen的介绍

上一篇下一篇

猜你喜欢

热点阅读