@@ -246,6 +246,7 @@ func validateAlterOperation(ctx context.Context, op *api.Operation) error {
246
246
if ! isMutationAllowed (ctx ) {
247
247
return errors .Errorf ("No mutations allowed by server." )
248
248
}
249
+
249
250
if _ , err := hasAdminAuth (ctx , "Alter" ); err != nil {
250
251
glog .Warningf ("Alter denied with error: %v\n " , err )
251
252
return err
@@ -1579,7 +1580,7 @@ func parseRequest(ctx context.Context, qc *queryContext) error {
1579
1580
// parsing mutations
1580
1581
qc .gmuList = make ([]* dql.Mutation , 0 , len (qc .req .Mutations ))
1581
1582
for _ , mu := range qc .req .Mutations {
1582
- gmu , err := parseMutationObject (mu , qc )
1583
+ gmu , err := ParseMutationObject (mu , qc . graphql )
1583
1584
if err != nil {
1584
1585
return err
1585
1586
}
@@ -1930,12 +1931,12 @@ func hasPoormansAuth(ctx context.Context) error {
1930
1931
return nil
1931
1932
}
1932
1933
1933
- // parseMutationObject tries to consolidate fields of the api.Mutation into the
1934
+ // ParseMutationObject tries to consolidate fields of the api.Mutation into the
1934
1935
// corresponding field of the returned dql.Mutation. For example, the 3 fields,
1935
1936
// api.Mutation#SetJson, api.Mutation#SetNquads and api.Mutation#Set are consolidated into the
1936
1937
// dql.Mutation.Set field. Similarly the 3 fields api.Mutation#DeleteJson, api.Mutation#DelNquads
1937
1938
// and api.Mutation#Del are merged into the dql.Mutation#Del field.
1938
- func parseMutationObject (mu * api.Mutation , qc * queryContext ) (* dql.Mutation , error ) {
1939
+ func ParseMutationObject (mu * api.Mutation , isGraphql bool ) (* dql.Mutation , error ) {
1939
1940
res := & dql.Mutation {Cond : mu .Cond }
1940
1941
1941
1942
if len (mu .SetJson ) > 0 {
@@ -1979,7 +1980,7 @@ func parseMutationObject(mu *api.Mutation, qc *queryContext) (*dql.Mutation, err
1979
1980
return nil , err
1980
1981
}
1981
1982
1982
- if err := validateNQuads (res .Set , res .Del , qc ); err != nil {
1983
+ if err := validateNQuads (res .Set , res .Del , isGraphql ); err != nil {
1983
1984
return nil , err
1984
1985
}
1985
1986
return res , nil
@@ -2015,8 +2016,7 @@ func validateForGraphql(nq *api.NQuad, isGraphql bool) error {
2015
2016
return nil
2016
2017
}
2017
2018
2018
- func validateNQuads (set , del []* api.NQuad , qc * queryContext ) error {
2019
-
2019
+ func validateNQuads (set , del []* api.NQuad , isGraphql bool ) error {
2020
2020
for _ , nq := range set {
2021
2021
if err := validatePredName (nq .Predicate ); err != nil {
2022
2022
return err
@@ -2031,7 +2031,7 @@ func validateNQuads(set, del []*api.NQuad, qc *queryContext) error {
2031
2031
if err := validateKeys (nq ); err != nil {
2032
2032
return errors .Wrapf (err , "key error: %+v" , nq )
2033
2033
}
2034
- if err := validateForGraphql (nq , qc . graphql ); err != nil {
2034
+ if err := validateForGraphql (nq , isGraphql ); err != nil {
2035
2035
return err
2036
2036
}
2037
2037
}
@@ -2046,7 +2046,7 @@ func validateNQuads(set, del []*api.NQuad, qc *queryContext) error {
2046
2046
if nq .Subject == x .Star || (nq .Predicate == x .Star && ! ostar ) {
2047
2047
return errors .Errorf ("Only valid wildcard delete patterns are 'S * *' and 'S P *': %v" , nq )
2048
2048
}
2049
- if err := validateForGraphql (nq , qc . graphql ); err != nil {
2049
+ if err := validateForGraphql (nq , isGraphql ); err != nil {
2050
2050
return err
2051
2051
}
2052
2052
// NOTE: we dont validateKeys() with delete to let users fix existing mistakes
0 commit comments