learning-graphql

command module
v0.0.0-...-ac9c94f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2023 License: MIT Imports: 19 Imported by: 0

README

learning-graphql

初めてのGraphQLの勉強用リポジトリです。

第5章を書籍ではjsですが、Goで書き換えています。

参考にしたサイト

【GraphQL × Go】gqlgenの基本構成とオーバーフェッチを防ぐmodel resolverの実装

環境構築

事前準備

gqlgenのinstall

gqlgenを利用しています 以下コマンドでgqlgenをinstallしてください

go install github.com/99designs/gqlgen
環境変数設定

.env.sample.envとし、環境変数を設定してください

サービス起動

docker compose up -d

でサービスが起動します。

サービスとその役割は以下です。

  • graphql-server
    • graphqlのサーバーです(websocketも対応)
    • localhost:8080でplaygroundが起動しgraphqlを叩けます
  • mongo
    • mongo-dbをデータベースに利用しています
  • mongo-express
    • GUIでmongo-dbを見れるサービスです
    • localhost:8081でアクセスできます

スキーマ変更方法

  1. ./graph/schema.graphqlsを編集

  2. rootディレクトリにてmake gqlgenを実行する

    以下ファイルが自動生成されます

    • ./graph/model/models_gen.go
    • ./graph/generated.go
    • ./graph/schema.resolver.go

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
app

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL