Skip to content

Commit 440fdad

Browse files
committed
Update dependencies + regenerate schema
1 parent 47dab78 commit 440fdad

File tree

11 files changed

+961
-876
lines changed

11 files changed

+961
-876
lines changed

db/gql.go

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,16 @@ var gqlQueries map[string]string = map[string]string{
8383
}
8484
}`,
8585
// Extra - Bridge
86+
"queryExtra": `{
87+
"query": "query {{.QueryName}}($filter:{{.FilterType}}, $order:{{.OrderType}}, $first:Int, $offset:Int) {
88+
{{.QueryName}}{{.QueryInput}} {{.Directives}} {
89+
{{.QueryGraph}}
90+
}
91+
}",
92+
"variables": {{.VarMap}}
93+
}`,
8694
"addExtra": `{
87-
"query": "mutation {{.QueryName}}($input:[{{.InputType}}!]!){
95+
"query": "mutation {{.QueryName}}($input:[{{.InputType}}!]!) {
8896
{{.QueryName}}{{.QueryInput}} {
8997
{{.QueryGraph}}
9098
}
@@ -94,7 +102,7 @@ var gqlQueries map[string]string = map[string]string{
94102
}
95103
}`,
96104
"mutationExtra": `{
97-
"query": "mutation {{.QueryName}}($input:{{.InputType}}!){
105+
"query": "mutation {{.QueryName}}($input:{{.InputType}}!) {
98106
{{.QueryName}}{{.QueryInput}} {
99107
{{.QueryGraph}}
100108
}
@@ -330,9 +338,58 @@ func (dg Dgraph) UpdateValue(uctx model.UserCtx, vertex string, id, k, v string)
330338
return err
331339
}
332340

333-
//
334-
// Bridge queries
335-
//
341+
/*
342+
* Bridge queries
343+
*/
344+
345+
// GetDirectives return the list of directives to apply to the given query
346+
// by looking for the pressence of special attributes in the payload graph.
347+
func GetDirectives(pg string) string {
348+
directives := []string{}
349+
words := strings.Fields(pg)
350+
for _, word := range words {
351+
if word == "cascade_directive" {
352+
directives = append(directives, "@cascade")
353+
}
354+
}
355+
return strings.Join(directives, " ")
356+
}
357+
358+
// Query codec, to be used in the resolver functions
359+
func (dg Dgraph) QueryExtra(uctx model.UserCtx, vertex string, filter any, order any, first *int, offset *int, qg string, data any) error {
360+
Vertex := strings.Title(vertex)
361+
queryName := "query" + Vertex
362+
filterType := Vertex + "Filter"
363+
orderType := Vertex + "Order"
364+
365+
// Build the string request
366+
var queryInput string
367+
queryInput = `(filter: $filter, order: $order, first: $first, offset: $offset)`
368+
369+
// Marshal the inputs
370+
filter_ := struct {
371+
Filter any `json:"filter"`
372+
Order any `json:"order"`
373+
First *int `json:"first"`
374+
Offset *int `json:"offset"`
375+
}{filter, order, first, offset}
376+
varmap, _ := MarshalWithoutNil(filter_)
377+
378+
// Build the request template map
379+
reqInput := map[string]string{
380+
"QueryName": queryName, // Query name (e.g addUser)
381+
"FilterType": filterType, // input type name (e.g AddUserInput)
382+
"OrderType": orderType, // input type name (e.g AddUserInput)
383+
"QueryInput": QuoteString(queryInput), // inputs data
384+
"QueryGraph": CleanString(qg, true), // output data
385+
"VarMap": string(varmap), // inputs data
386+
"Directives": GetDirectives(qg),
387+
}
388+
389+
// Send request
390+
err := dg.QueryGql(uctx, "queryExtra", reqInput, data)
391+
return err
392+
}
336393

337394
// Add codec, to be used in the resolver functions
338395
func (dg Dgraph) AddExtra(uctx model.UserCtx, vertex string, input interface{}, upsert *bool, qg string, data interface{}) error {

go.mod

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,78 +5,78 @@ go 1.21
55
toolchain go1.22.0
66

77
require (
8-
github.com/99designs/gqlgen v0.17.44
8+
github.com/99designs/gqlgen v0.17.49
99
github.com/dgraph-io/dgo/v200 v200.0.0-20210401091508-95bfd74de60e
1010
github.com/go-chi/chi/v5 v5.0.12
11-
github.com/go-chi/jwtauth/v5 v5.3.0
11+
github.com/go-chi/jwtauth/v5 v5.3.1
1212
github.com/go-redis/redis/v8 v8.11.5
1313
github.com/gofrs/uuid v4.4.0+incompatible
14-
github.com/lestrrat-go/jwx/v2 v2.0.20
14+
github.com/lestrrat-go/jwx/v2 v2.0.21
1515
github.com/microcosm-cc/bluemonday v1.0.26
1616
github.com/mitchellh/mapstructure v1.5.0
17-
github.com/prometheus/client_golang v1.19.0
18-
github.com/rs/cors v1.10.1
19-
github.com/spf13/cobra v1.8.0
20-
github.com/spf13/viper v1.18.2
17+
github.com/prometheus/client_golang v1.19.1
18+
github.com/rs/cors v1.11.0
19+
github.com/spf13/cobra v1.8.1
20+
github.com/spf13/viper v1.19.0
2121
github.com/steambap/captcha v1.4.1
22-
github.com/vektah/gqlparser/v2 v2.5.11
23-
github.com/yuin/goldmark v1.7.0
24-
golang.org/x/crypto v0.20.0
25-
golang.org/x/text v0.14.0
26-
google.golang.org/grpc v1.62.0
22+
github.com/vektah/gqlparser/v2 v2.5.16
23+
github.com/yuin/goldmark v1.7.2
24+
golang.org/x/crypto v0.24.0
25+
golang.org/x/text v0.16.0
26+
google.golang.org/grpc v1.64.0
2727
)
2828

2929
require (
3030
github.com/agnivade/levenshtein v1.1.1 // indirect
3131
github.com/aymerick/douceur v0.2.0 // indirect
3232
github.com/beorn7/perks v1.0.1 // indirect
33-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
34-
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
35-
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
33+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
34+
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
35+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
3636
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
3737
github.com/fsnotify/fsnotify v1.7.0 // indirect
38-
github.com/goccy/go-json v0.10.2 // indirect
38+
github.com/goccy/go-json v0.10.3 // indirect
3939
github.com/gogo/protobuf v1.3.2 // indirect
4040
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
41-
github.com/golang/protobuf v1.5.3 // indirect
4241
github.com/google/uuid v1.6.0 // indirect
4342
github.com/gorilla/css v1.0.1 // indirect
44-
github.com/gorilla/websocket v1.5.1 // indirect
43+
github.com/gorilla/websocket v1.5.3 // indirect
4544
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
4645
github.com/hashicorp/hcl v1.0.0 // indirect
4746
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4847
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
4948
github.com/lestrrat-go/httpcc v1.0.1 // indirect
50-
github.com/lestrrat-go/httprc v1.0.4 // indirect
49+
github.com/lestrrat-go/httprc v1.0.5 // indirect
5150
github.com/lestrrat-go/iter v1.0.2 // indirect
5251
github.com/lestrrat-go/option v1.0.1 // indirect
5352
github.com/magiconair/properties v1.8.7 // indirect
54-
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
53+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
5554
github.com/pkg/errors v0.9.1 // indirect
56-
github.com/prometheus/client_model v0.6.0 // indirect
57-
github.com/prometheus/common v0.48.0 // indirect
58-
github.com/prometheus/procfs v0.12.0 // indirect
55+
github.com/prometheus/client_model v0.6.1 // indirect
56+
github.com/prometheus/common v0.54.0 // indirect
57+
github.com/prometheus/procfs v0.15.1 // indirect
5958
github.com/russross/blackfriday/v2 v2.1.0 // indirect
60-
github.com/sagikazarmark/locafero v0.4.0 // indirect
59+
github.com/sagikazarmark/locafero v0.6.0 // indirect
6160
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
6261
github.com/segmentio/asm v1.2.0 // indirect
63-
github.com/sosodev/duration v1.2.0 // indirect
62+
github.com/sosodev/duration v1.3.1 // indirect
6463
github.com/sourcegraph/conc v0.3.0 // indirect
6564
github.com/spf13/afero v1.11.0 // indirect
6665
github.com/spf13/cast v1.6.0 // indirect
6766
github.com/spf13/pflag v1.0.5 // indirect
6867
github.com/subosito/gotenv v1.6.0 // indirect
69-
github.com/urfave/cli/v2 v2.27.1 // indirect
70-
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect
68+
github.com/urfave/cli/v2 v2.27.2 // indirect
69+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
7170
go.uber.org/multierr v1.11.0 // indirect
72-
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
73-
golang.org/x/image v0.15.0 // indirect
74-
golang.org/x/mod v0.15.0 // indirect
75-
golang.org/x/net v0.21.0 // indirect
76-
golang.org/x/sys v0.17.0 // indirect
77-
golang.org/x/tools v0.18.0 // indirect
78-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240228201840-1f18d85a4ec2 // indirect
79-
google.golang.org/protobuf v1.32.0 // indirect
71+
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
72+
golang.org/x/image v0.17.0 // indirect
73+
golang.org/x/mod v0.18.0 // indirect
74+
golang.org/x/net v0.26.0 // indirect
75+
golang.org/x/sync v0.7.0 // indirect
76+
golang.org/x/sys v0.21.0 // indirect
77+
golang.org/x/tools v0.22.0 // indirect
78+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 // indirect
79+
google.golang.org/protobuf v1.34.2 // indirect
8080
gopkg.in/ini.v1 v1.67.0 // indirect
8181
gopkg.in/yaml.v3 v3.0.1 // indirect
8282
)

0 commit comments

Comments
 (0)