Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
cd docker || exit
docker compose cp ./mysql_data/sql mysql:/var/lib/mysql/
docker compose exec mysql bash -c "mysql -uroot -proot < /var/lib/mysql/sql/reset_database.e2e.sql"
// ReadConfigE2E reads config file for e2e.
func ReadConfigE2E() {
config.ReadConfig(config.ReadConfigOption{
AppEnv: environment.E2E,
})
}
package e2e
import (
"golang-clean-architecture-ent-gqlgen/ent"
"golang-clean-architecture-ent-gqlgen/pkg/adapter/controller"
"golang-clean-architecture-ent-gqlgen/pkg/infrastructure/graphql"
"golang-clean-architecture-ent-gqlgen/pkg/infrastructure/router"
"golang-clean-architecture-ent-gqlgen/pkg/registry"
"golang-clean-architecture-ent-gqlgen/testutil"
"net/http/httptest"
package mutation_test
import (
"context"
"golang-clean-architecture-ent-gqlgen/ent"
"golang-clean-architecture-ent-gqlgen/pkg/infrastructure/router"
"golang-clean-architecture-ent-gqlgen/testutil"
"golang-clean-architecture-ent-gqlgen/testutil/e2e"
"net/http"
"testing"
package graph
import (
"context"
"golang-ent-gqlgen-example/ent"
"golang-ent-gqlgen-example/ent/user"
"golang-ent-gqlgen-example/graph/generated"
"time"
)
// Configure the GraphQL server and start
srv := handler.NewDefaultServer(graph.NewSchema(client))
{
e.POST("/query", func(c echo.Context) error {
srv.ServeHTTP(c.Response(), c.Request())
return nil
})
e.GET("/playground", func(c echo.Context) error {
playground.Handler("GraphQL", "/query").ServeHTTP(c.Response(), c.Request())
package graph
import (
"golang-ent-gqlgen-example/ent"
"golang-ent-gqlgen-example/graph/generated"
"github.com/99designs/gqlgen/graphql"
)
type Resolver struct{ client *ent.Client }
// +build ignore
package main
import (
"errors"
"log"
"entgo.io/contrib/entgql"
"entgo.io/ent/entc"
type User {
id: ID!
name: String!
age: Int!
createdAt: String!
}
type Query {
user: User
}
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
schema:
- graph/*.graphqls
# Where should the generated server code go?
exec:
filename: graph/generated/generated.go
package: generated
# Uncomment to enable federation