Skip to content

Commit

Permalink
Fix: auth0 and function args
Browse files Browse the repository at this point in the history
- Bug in the SetContextValues function within auth0.go. #434
- Count query field is not accepting correct arguments #432
  • Loading branch information
dosco committed May 12, 2023
1 parent 3ec100e commit 10b4196
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion auth/provider/auth0.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (p *Auth0Provider) SetContextValues(ctx context.Context, claims jwt.MapClai
return ctx, errors.New("sub claim not found")
}
sp := strings.SplitN(sub, "|", 2)
if len(sub) == 2 {
if len(sp) == 2 {
ctx = context.WithValue(ctx, core.UserIDRawKey, sub)
ctx = context.WithValue(ctx, core.UserIDProviderKey, sp[0])
ctx = context.WithValue(ctx, core.UserIDKey, sp[1])
Expand Down
4 changes: 2 additions & 2 deletions core/internal/qcode/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@ func (co *Compiler) compileFieldArgs(sel *Select, f *Field, args []graph.Arg, ro
return nil
}

var numArgKeyRe = regexp.MustCompile(`^a\d+`)
var numArgKeyRe = regexp.MustCompile(`^[a_]\d+`)

func (co *Compiler) compileFuncArgArgs(sel *Select, f *Field, arg graph.Arg) (err error) {
if f.Type == FieldTypeFunc && len(f.Func.Inputs) == 0 {
return fmt.Errorf("db function '%s' has no arguments", f.Func.Name)
return fmt.Errorf("db function '%s': has no arguments", f.Func.Name)
}

if err = validateArg(arg, graph.NodeObj); err != nil {
Expand Down
8 changes: 5 additions & 3 deletions core/internal/qcode/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ func newArgs(sel *Select, f sdata.DBFunction, arg graph.Arg) (args []Arg, err er
}

func parseArg(arg *graph.Node, f sdata.DBFunction, index int) (a Arg, err error) {
if numArgKeyRe.MatchString(arg.Name) {
argName := arg.Name
if numArgKeyRe.MatchString(argName) {
var n int
n, err = strconv.Atoi(arg.Name[1:])
argName = argName[1:]
n, err = strconv.Atoi(argName)
if err != nil {
err = fmt.Errorf("db function %s: invalid key: %s", f.Name, arg.Name)
return
Expand All @@ -186,7 +188,7 @@ func parseArg(arg *graph.Node, f sdata.DBFunction, index int) (a Arg, err error)
}

var input sdata.DBFuncParam
input, err = f.GetInput(arg.Name)
input, err = f.GetInput(argName)
if err != nil {
err = fmt.Errorf("db function %s: %w", f.Name, err)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphjin",
"version": "3.0.16",
"version": "3.0.17",
"description": "GraphJin - Build APIs in 5 minutes with GraphQL",
"type": "module",
"main": "./wasm/js/graphjin.js",
Expand Down
Binary file modified wasm/graphjin.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions wasm/js/wasm_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
outputBuf += decoder.decode(buf);
const nl = outputBuf.lastIndexOf("\n");
if (nl != -1) {
console.log(outputBuf.substr(0, nl));
outputBuf = outputBuf.substr(nl + 1);
console.log(outputBuf.substring(0, nl));
outputBuf = outputBuf.substring(nl + 1);
}
return buf.length;
},
Expand Down

1 comment on commit 10b4196

@vercel
Copy link

@vercel vercel bot commented on 10b4196 May 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.