Skip to content

Commit

Permalink
Implement generic filters
Browse files Browse the repository at this point in the history
Added new query API implementing a first version of generic filters.

Some things are missing:

- No subscriptions yet, almost there
- No filters for multi type fields like messages, still thinking about
  how to implement the API to make it user friendly.

Please, any feedback is welcome!

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
  • Loading branch information
ajnavarro committed Sep 10, 2024
1 parent 9921720 commit 81e31e3
Show file tree
Hide file tree
Showing 13 changed files with 6,064 additions and 585 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module github.com/gnolang/tx-indexer

go 1.22
go 1.22.7

require (
github.com/99designs/gqlgen v0.17.49
github.com/ajnavarro/gqlfiltergen v0.0.0-20240910174730-98492f66692d
github.com/cockroachdb/pebble v1.1.2
github.com/gnolang/gno v0.1.1
github.com/go-chi/chi/v5 v5.1.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRP
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/ajnavarro/gqlfiltergen v0.0.0-20240910174730-98492f66692d h1:+f629awnLtFHMIPN7Eqwzr5aX738brTJ7tnckUJszsw=
github.com/ajnavarro/gqlfiltergen v0.0.0-20240910174730-98492f66692d/go.mod h1:uHvKxvSISkr7QFZnYlrXfpnEDI/UPpodVM/a/XkOjtU=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
Expand Down
277 changes: 277 additions & 0 deletions serve/graph/all.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions serve/graph/gen/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// go:build ignore

Check failure on line 1 in serve/graph/gen/generate.go

View workflow job for this annotation

GitHub Actions / Go Linter / lint

compiler directive contains space: // go:build (gocheckcompilerdirectives)

package main

import (
"fmt"
"os"

"github.com/99designs/gqlgen/api"
"github.com/99designs/gqlgen/codegen/config"
"github.com/ajnavarro/gqlfiltergen"
)

func main() {
cfg, err := config.LoadConfigFromDefaultLocations()
if err != nil {
fmt.Fprintln(os.Stderr, "failed to load config", err.Error())
os.Exit(2)
}

err = api.Generate(cfg,
api.AddPlugin(gqlfiltergen.NewPlugin(&gqlfiltergen.Options{
Queries: []string{
`
"""
Fetches Blocks matching the specified where criteria. Incomplete results due to errors return both the partial Blocks and the associated errors.
"""
getBlocks(where: FilterBlock!): [Block!]
`, `
"""
Retrieves a list of Transactions that match the given where criteria. If the result is incomplete due to errors, both partial results and errors are returned.
"""
getTransactions(where: FilterTransaction!): [Transaction!]
`,
},
})),
)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(3)
}
}
Loading

0 comments on commit 81e31e3

Please sign in to comment.