Skip to content

Commit

Permalink
chore: Merge Graphql (#35)
Browse files Browse the repository at this point in the history
* chore: merge master into v1.14.x (#31)

* feat: add the example of transform carbon (#21)

* feat: add the example of transform carbon

* optimize unit test

* optimize unit test

* Switch sqlite

* fix: unit tests (#23)

* fix: unit tests

* remove postgres

* remove db

* feat: add CRUD example (#24)

* feat: add curl example

* add resource route

* update comments

* feat: sync latest framework changes (#20)

* feat: sync latest framework changes

* feat: add rate limiter example

* fix: lint

* fix: lint

* fix: lint

* fix: lint

* feat: add throttle test

* feat: optimize throttle test

* feat: bump postgres version to 16

* feat: modify port

* fix: test

* fix: test

* optimize test

* optimize test

* optimize test

* optimize test

---------

Co-authored-by: Bowen <[email protected]>

* upgrade v1.14.5

* optimize test cases

* demo: auth (#27)

* demo: auth

* rename

* rename

* upgrade: v1.14.7 (#29)

---------

Co-authored-by: 耗子 <[email protected]>

* fix: [#523] [Bug] The same listener can not be registered by multiple events, framework will threw an error: job signature duplicate (#33)

* fix: [#523] [Bug] The same listener can not be registered by multiple events, framework will threw an error: job signature duplicate

* Optimize test

* Update go.mod

* Update go.mod

* Add redis

* Add GraphQL (#34)

* Add graphql setup

* Missed modified files

---------

Co-authored-by: 耗子 <[email protected]>
Co-authored-by: Viet Pham <[email protected]>
  • Loading branch information
3 people authored Dec 3, 2024
1 parent 77b4331 commit 14e08df
Show file tree
Hide file tree
Showing 22 changed files with 5,136 additions and 170 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start Redis
uses: supercharge/[email protected]
with:
redis-version: 7
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ Welcome to star, PR and issues!

[About air]: https://www.goravel.dev/getting-started/installation.html#live-reload

### GraphQL

```bash
# download and install gqlgen locally, only need to run it once
go get -d github.com/99designs/gqlgen
# regenerate code
go run github.com/99designs/gqlgen generate
```

### DB

[app/http/controllers/db_controller.go](https://github.com/goravel/example/blob/master/app/http/controllers/db_controller.go)
Expand Down
14 changes: 14 additions & 0 deletions app/events/order_canceled.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package events

import "github.com/goravel/framework/contracts/event"

type OrderCanceled struct {
}

func NewOrderCanceled() *OrderCanceled {
return &OrderCanceled{}
}

func (receiver *OrderCanceled) Handle(args []event.Arg) ([]event.Arg, error) {
return args, nil
}
14 changes: 14 additions & 0 deletions app/events/order_shipped.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package events

import "github.com/goravel/framework/contracts/event"

type OrderShipped struct {
}

func NewOrderShipped() *OrderShipped {
return &OrderShipped{}
}

func (receiver *OrderShipped) Handle(args []event.Arg) ([]event.Arg, error) {
return args, nil
}
35 changes: 35 additions & 0 deletions app/listeners/send_shipment_notification.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package listeners

import (
"github.com/goravel/framework/contracts/event"
"github.com/spf13/cast"
)

var TestResultOfSendShipmentNotification []string

type SendShipmentNotification struct {
}

func NewSendShipmentNotification() *SendShipmentNotification {
return &SendShipmentNotification{}
}

func (receiver *SendShipmentNotification) Signature() string {
return "send_shipment_notification"
}

func (receiver *SendShipmentNotification) Queue(args ...any) event.Queue {
return event.Queue{
Enable: true,
Connection: "",
Queue: "",
}
}

func (receiver *SendShipmentNotification) Handle(args ...any) error {
if len(args) > 0 {
TestResultOfSendShipmentNotification = append(TestResultOfSendShipmentNotification, cast.ToString(args[0]))
}

return nil
}
12 changes: 11 additions & 1 deletion app/providers/event_service_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"github.com/goravel/framework/contracts/event"
"github.com/goravel/framework/contracts/foundation"
"github.com/goravel/framework/facades"

"goravel/app/events"
"goravel/app/listeners"
)

type EventServiceProvider struct {
Expand All @@ -18,5 +21,12 @@ func (receiver *EventServiceProvider) Boot(app foundation.Application) {
}

func (receiver *EventServiceProvider) listen() map[event.Event][]event.Listener {
return map[event.Event][]event.Listener{}
return map[event.Event][]event.Listener{
events.NewOrderShipped(): {
listeners.NewSendShipmentNotification(),
},
events.NewOrderCanceled(): {
listeners.NewSendShipmentNotification(),
},
}
}
1 change: 1 addition & 0 deletions app/providers/route_service_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func (receiver *RouteServiceProvider) Boot(app foundation.Application) {
// Add routes
routes.Web()
routes.Api()
routes.Graphql()
}

func (receiver *RouteServiceProvider) configureRateLimiting() {
Expand Down
2 changes: 1 addition & 1 deletion config/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func init() {
config := facades.Config()
config.Add("queue", map[string]any{
// Default Queue Connection Name
"default": config.Env("QUEUE_CONNECTION", "sync"),
"default": config.Env("QUEUE_CONNECTION", "redis"),

// Queue Connections
//
Expand Down
90 changes: 48 additions & 42 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
module goravel

go 1.21
go 1.22.7

toolchain go1.23.3

require (
github.com/99designs/gqlgen v0.17.57
github.com/go-resty/resty/v2 v2.13.1
github.com/gofiber/fiber/v2 v2.52.5
github.com/gofiber/template/html/v2 v2.1.2
github.com/goravel/example-proto v0.0.1
github.com/goravel/fiber v1.2.4
github.com/goravel/framework v1.14.7
github.com/goravel/framework v1.14.8
github.com/goravel/gin v1.2.5
github.com/gorilla/websocket v1.5.0
github.com/opentracing/opentracing-go v1.2.0
Expand All @@ -18,15 +21,16 @@ require (
github.com/swaggo/http-swagger/v2 v2.0.2
github.com/swaggo/swag v1.16.2
github.com/uber/jaeger-client-go v2.30.0+incompatible
google.golang.org/grpc v1.65.0
github.com/vektah/gqlparser/v2 v2.5.19
google.golang.org/grpc v1.68.0
)

require (
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/pubsub v1.36.1 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
Expand All @@ -39,6 +43,7 @@ require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae // indirect
github.com/RichardKnop/machinery/v2 v2.0.13 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aws/aws-sdk-go v1.49.6 // indirect
Expand All @@ -47,32 +52,30 @@ require (
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/catppuccin/go v0.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charmbracelet/bubbles v0.18.0 // indirect
github.com/charmbracelet/bubbletea v0.26.6 // indirect
github.com/charmbracelet/huh v0.5.2 // indirect
github.com/charmbracelet/huh/spinner v0.0.0-20240803000013-2eb851f67645 // indirect
github.com/charmbracelet/lipgloss v0.12.1 // indirect
github.com/charmbracelet/x/ansi v0.1.4 // indirect
github.com/charmbracelet/bubbles v0.20.0 // indirect
github.com/charmbracelet/bubbletea v1.2.3 // indirect
github.com/charmbracelet/huh v0.6.0 // indirect
github.com/charmbracelet/huh/spinner v0.0.0-20241119235641-e7e76ffbce9f // indirect
github.com/charmbracelet/lipgloss v1.0.0 // indirect
github.com/charmbracelet/x/ansi v0.4.5 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
github.com/charmbracelet/x/input v0.1.3 // indirect
github.com/charmbracelet/x/term v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.1.2 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.10.0 // indirect
github.com/glebarez/go-sqlite v1.22.0 // indirect
github.com/glebarez/sqlite v1.11.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
Expand All @@ -84,13 +87,14 @@ require (
github.com/go-redsync/redsync/v4 v4.8.1 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofiber/template v1.8.3 // indirect
github.com/gofiber/utils v1.1.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang-migrate/migrate/v4 v4.17.1 // indirect
github.com/golang-module/carbon/v2 v2.3.12 // indirect
github.com/golang-migrate/migrate/v4 v4.18.1 // indirect
github.com/golang-module/carbon/v2 v2.4.1 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -104,12 +108,13 @@ require (
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/gookit/filter v1.2.1 // indirect
github.com/gookit/goutil v0.6.15 // indirect
github.com/gookit/goutil v0.6.17 // indirect
github.com/gookit/validate v1.5.2 // indirect
github.com/goravel/file-rotatelogs/v2 v2.4.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
Expand All @@ -133,20 +138,20 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/microsoft/go-mssqldb v1.6.0 // indirect
github.com/microsoft/go-mssqldb v1.7.2 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/pterm/pterm v0.12.79 // indirect
github.com/rabbitmq/amqp091-go v1.9.0 // indirect
github.com/redis/go-redis/v9 v9.6.1 // indirect
github.com/redis/go-redis/v9 v9.7.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
Expand All @@ -158,6 +163,7 @@ require (
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/savioxavier/termlink v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sosodev/duration v1.3.1 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -169,7 +175,7 @@ require (
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/unrolled/secure v1.15.0 // indirect
github.com/urfave/cli/v2 v2.27.3 // indirect
github.com/urfave/cli/v2 v2.27.5 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.55.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
Expand All @@ -182,36 +188,36 @@ require (
go.mongodb.org/mongo-driver v1.7.5 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.23.0 // indirect
golang.org/x/tools v0.27.0 // indirect
google.golang.org/api v0.171.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/protobuf v1.34.1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/mysql v1.5.7 // indirect
gorm.io/driver/postgres v1.5.9 // indirect
gorm.io/driver/sqlserver v1.5.3 // indirect
gorm.io/gorm v1.25.11 // indirect
gorm.io/plugin/dbresolver v1.5.2 // indirect
gorm.io/driver/sqlserver v1.5.4 // indirect
gorm.io/gorm v1.25.12 // indirect
gorm.io/plugin/dbresolver v1.5.3 // indirect
modernc.org/libc v1.37.6 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
Expand Down
Loading

0 comments on commit 14e08df

Please sign in to comment.