Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(graphql): upgrade gqlparser to v2.2.2
Browse files Browse the repository at this point in the history
CLOSES DGRAPHCORE-329
Seems like there was a race condition that was fixed in v2.2.2
from v2.2.1. This change upgrades gqlparser to the fixed version.
mangalaman93 committed Aug 1, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fd6c0be commit 04f27d3
Showing 5 changed files with 87 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dgraphtest/config.go
Original file line number Diff line number Diff line change
@@ -94,6 +94,7 @@ type ClusterConfig struct {
// exposed port offset for grpc/http port for both alpha/zero
portOffset int
bulkOutDir string
lambdaURL string
}

func NewClusterConfig() ClusterConfig {
@@ -180,3 +181,8 @@ func (cc ClusterConfig) WithBulkLoadOutDir(dir string) ClusterConfig {
cc.bulkOutDir = dir
return cc
}

func (cc ClusterConfig) WithGraphqlLambdaURL(url string) ClusterConfig {
cc.lambdaURL = url
return cc
}
4 changes: 4 additions & 0 deletions dgraphtest/dgraph.go
Original file line number Diff line number Diff line change
@@ -243,6 +243,10 @@ func (a *alpha) cmd(c *LocalCluster) []string {
}
acmd = append(acmd, zeroAddrsArg)

if c.conf.lambdaURL != "" {
acmd = append(acmd, fmt.Sprintf(`--graphql=lambda-url=%s`, c.conf.lambdaURL))
}

return acmd
}

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ require (
github.com/dgraph-io/badger/v4 v4.1.0
github.com/dgraph-io/dgo/v230 v230.0.1
github.com/dgraph-io/gqlgen v0.13.2
github.com/dgraph-io/gqlparser/v2 v2.2.1
github.com/dgraph-io/gqlparser/v2 v2.2.2
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15
github.com/dgraph-io/ristretto v0.1.1
github.com/dgraph-io/simdjson-go v0.3.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -152,8 +152,8 @@ github.com/dgraph-io/dgo/v230 v230.0.1/go.mod h1:5FerO2h4LPOxR2XTkOAtqUUPaFdQ+5a
github.com/dgraph-io/gqlgen v0.13.2 h1:TNhndk+eHKj5qE7BenKKSYdSIdOGhLqxR1rCiMso9KM=
github.com/dgraph-io/gqlgen v0.13.2/go.mod h1:iCOrOv9lngN7KAo+jMgvUPVDlYHdf7qDwsTkQby2Sis=
github.com/dgraph-io/gqlparser/v2 v2.1.1/go.mod h1:MYS4jppjyx8b9tuUtjV7jU1UFZK6P9fvO8TsIsQtRKU=
github.com/dgraph-io/gqlparser/v2 v2.2.1 h1:15msK9XEHOSrRqQO48UU+2ZTf1R1U8+tfL9H5D5/eQQ=
github.com/dgraph-io/gqlparser/v2 v2.2.1/go.mod h1:MYS4jppjyx8b9tuUtjV7jU1UFZK6P9fvO8TsIsQtRKU=
github.com/dgraph-io/gqlparser/v2 v2.2.2 h1:CnxXOKL4EPguKqcGV/z4u4VoW5izUkOTIsNM6xF+0f4=
github.com/dgraph-io/gqlparser/v2 v2.2.2/go.mod h1:MYS4jppjyx8b9tuUtjV7jU1UFZK6P9fvO8TsIsQtRKU=
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15 h1:X2NRsgAtVUAp2nmTPCq+x+wTcRRrj74CEpy7E0Unsl4=
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15/go.mod h1:7z3c/5w0sMYYZF5bHsrh8IH4fKwG5O5Y70cPH1ZLLRQ=
github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8=
74 changes: 74 additions & 0 deletions systest/integration2/graphql_schema_auth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//go:build integration2

/*
* Copyright 2023 Dgraph Labs, Inc. and Contributors *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package main

import (
"testing"
"time"

"github.com/dgraph-io/dgraph/dgraphtest"
"github.com/dgraph-io/dgraph/x"
"github.com/stretchr/testify/require"
)

func TestGraphqlSchema(t *testing.T) {
conf := dgraphtest.NewClusterConfig().WithNumAlphas(2).WithNumZeros(1).
WithACL(time.Hour).WithReplicas(1).WithGraphqlLambdaURL("http://127.0.0.1/temp")
c, err := dgraphtest.NewLocalCluster(conf)
require.NoError(t, err)
defer func() { c.Cleanup(t.Failed()) }()
require.NoError(t, c.Start())

hc, err := c.HTTPClient()
require.NoError(t, err)
require.NoError(t, hc.LoginIntoNamespace(dgraphtest.DefaultUser,
dgraphtest.DefaultPassword, x.GalaxyNamespace))

//nolint:lll
sch := `type City @auth(
query: { or: [
{ rule: "{$Role: { eq: \"ADMIN\" }}"},
{ rule: """
query($CITYID: String!) {
queryCity (filter: {
id: { eq: $CITYID }
}){
name
}
}"""
}]
},
add: { rule: "{$Role: { eq: \"ADMIN\" }}"},
update: { rule: "{$Role: { eq: \"ADMIN\" }}"},
){
id: ID!
name: String! @search(by: [hash, trigram])
state: String!
country: String! @search(by: [hash, trigram])
current_weather: String! @lambda
desc: String! @lambda
}
type Query {
citiesByName(name: String!): [City] @lambda
}
# Dgraph.Authorization {"VerificationKey":"secretkey","Header":"X-Test-Auth","Namespace":"https://xyz.io/jwt/claims","Algo":"HS256","Audience":["aud"]}`
require.NoError(t, hc.UpdateGQLSchema(sch))
}

0 comments on commit 04f27d3

Please sign in to comment.