Skip to content

Commit 3b60df6

Browse files
authored
Configure warning handler for edgeql-go (#367)
fixes #364
1 parent 9feb157 commit 3b60df6

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT _warn_on_call()
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Code generated by github.com/geldata/gel-go/cmd/edgeql-go DO NOT EDIT.
2+
3+
package main
4+
5+
import (
6+
"context"
7+
_ "embed"
8+
9+
gel "github.com/geldata/gel-go"
10+
)
11+
12+
//go:embed warn_on_call.edgeql
13+
var warnOnCallCmd string
14+
15+
// warnOnCall
16+
// runs the query found in
17+
// warn_on_call.edgeql
18+
func warnOnCall(
19+
ctx context.Context,
20+
client *gel.Client,
21+
) (int64, error) {
22+
var result int64
23+
24+
err := client.QuerySingle(
25+
ctx,
26+
warnOnCallCmd,
27+
&result,
28+
)
29+
30+
return result, err
31+
}
32+
33+
// warnOnCallJSON
34+
// runs the query found in
35+
// warn_on_call.edgeql
36+
// returning the results as json encoded bytes
37+
func warnOnCallJSON(
38+
ctx context.Context,
39+
client *gel.Client,
40+
) ([]byte, error) {
41+
var result []byte
42+
43+
err := client.QuerySingleJSON(
44+
ctx,
45+
warnOnCallCmd,
46+
&result,
47+
)
48+
if err != nil {
49+
return nil, err
50+
}
51+
52+
return result, nil
53+
}

internal/client/introspect.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package gel
1919
import (
2020
"context"
2121

22+
"github.com/geldata/gel-go/gelcfg"
2223
"github.com/geldata/gel-go/internal"
2324
"github.com/geldata/gel-go/internal/descriptor"
2425
)
@@ -56,6 +57,9 @@ func Describe(
5657
fmt: Binary,
5758
expCard: Many,
5859
capabilities: userCapabilities,
60+
cfg: QueryConfig{
61+
WarningHandler: gelcfg.LogWarnings,
62+
},
5963
}
6064

6165
r, err := conn.conn.acquireReader(ctx)
@@ -96,6 +100,9 @@ func DescribeV2(
96100
expCard: Many,
97101
capabilities: userCapabilities,
98102
parse: true,
103+
cfg: QueryConfig{
104+
WarningHandler: gelcfg.LogWarnings,
105+
},
99106
}
100107

101108
r, err := conn.conn.acquireReader(ctx)

0 commit comments

Comments
 (0)