1+ /*
2+ * SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
16package modusgraph
27
38import (
@@ -27,7 +32,7 @@ type Client interface {
2732 GetSchema (context.Context ) (string , error )
2833 DropAll (context.Context ) error
2934 DropData (context.Context ) error
30- QueryRaw (context.Context , string ) ([]byte , error )
35+ QueryRaw (context.Context , string , map [ string ] string ) ([]byte , error )
3136
3237 DgraphClient () (* dgo.Dgraph , func (), error )
3338}
@@ -288,7 +293,7 @@ func (c client) Query(ctx context.Context, model any) *dg.Query {
288293 }
289294 defer c .pool .put (client )
290295
291- txn := dg .NewTxn ( client )
296+ txn := dg .NewReadOnlyTxnContext ( ctx , client )
292297 return txn .Get (model )
293298}
294299
@@ -342,11 +347,11 @@ func (c client) DropData(ctx context.Context) error {
342347 return client .Alter (ctx , & api.Operation {DropOp : api .Operation_DATA })
343348}
344349
345- // QueryRaw implements raw querying (DQL syntax).
346- func (c client ) QueryRaw (ctx context.Context , q string ) ([]byte , error ) {
350+ // QueryRaw implements raw querying (DQL syntax) and optional variables .
351+ func (c client ) QueryRaw (ctx context.Context , q string , vars map [ string ] string ) ([]byte , error ) {
347352 if c .engine != nil {
348353 ns := c .engine .GetDefaultNamespace ()
349- resp , err := ns .Query (ctx , q )
354+ resp , err := ns .QueryWithVars (ctx , q , vars )
350355 if err != nil {
351356 return nil , err
352357 }
@@ -361,7 +366,7 @@ func (c client) QueryRaw(ctx context.Context, q string) ([]byte, error) {
361366 defer c .pool .put (client )
362367
363368 txn := dg .NewReadOnlyTxnContext (ctx , client )
364- resp , err := txn .Txn ().Query (ctx , q )
369+ resp , err := txn .Txn ().QueryWithVars (ctx , q , vars )
365370 if err != nil {
366371 return nil , err
367372 }
0 commit comments