Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ^1.23.6
go-version: ^1.26.1

- name: Check out code into the Go module directory
uses: actions/checkout@v4
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ^1.23.6
go-version: ^1.26.1
- name: Check out code
uses: actions/checkout@v4
- name: run unit tests
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Properties of an GRIP graph:
GRIP also provides a query API for the traversing, analyzing and manipulating your graphs. Its syntax is inspired by
[Apache TinkerPop](http://tinkerpop.apache.org/). Learn more [here](https://bmeg.github.io/grip/).

## GQL Compiler

The repository includes a GQL-to-GripQL compiler module. See `gql/GQL_TO_GRIPQL.md` for currently supported syntax and mapping behavior.



## Pathway Commons
Expand Down
68 changes: 68 additions & 0 deletions cmd/gql/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package gql

import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"time"

"github.com/bmeg/grip/log"
"github.com/spf13/cobra"
)

var host = "localhost:8201"
var verbose bool

// Cmd is the declaration of the command line
var Cmd = &cobra.Command{
Use: "gql <graph> <GQL query>",
Short: "Query a graph using GQL",
Long: `Query a graph using GQL.
Example:
grip query example-graph 'match (n:Person {name: "Bob"}) return n'`,

Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
graph := args[0]
queryString := args[1]

if verbose {
c := log.DefaultLoggerConfig()
c.Level = "debug"
log.ConfigureLogger(c)
}

queryMap := map[string]string{"query": queryString}
payload, err := json.Marshal(queryMap)
if err != nil {
return fmt.Errorf("marshaling query: %v", err)
}
url := fmt.Sprintf("http://%s/gql/%s", host, graph)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload))
if err != nil {
return fmt.Errorf("building request: %v", err)
}
req.Header.Set("Content-Type", "application/json")

resp, err := (&http.Client{Timeout: 5 * time.Second}).Do(req)
if err != nil {
return fmt.Errorf("making request: %v", err)
}
defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("reading response body: %v", err)
}

fmt.Printf("%s\n", body)
return nil
},
}

func init() {
Cmd.Flags().StringVarP(&host, "host", "H", host, "Grip server host:port")
Cmd.Flags().BoolVarP(&verbose, "verbose", "v", verbose, "Enable verbose logging")
}
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/bmeg/grip/cmd/drop"
"github.com/bmeg/grip/cmd/dump"
"github.com/bmeg/grip/cmd/erclient"
"github.com/bmeg/grip/cmd/gql"
"github.com/bmeg/grip/cmd/info"
"github.com/bmeg/grip/cmd/job"
"github.com/bmeg/grip/cmd/jsonload"
Expand Down Expand Up @@ -63,6 +64,7 @@ func init() {
RootCmd.AddCommand(mongoload.Cmd)
RootCmd.AddCommand(jsonload.Cmd)
RootCmd.AddCommand(query.Cmd)
RootCmd.AddCommand(gql.Cmd)
RootCmd.AddCommand(erclient.Cmd)
RootCmd.AddCommand(rdf.Cmd)
RootCmd.AddCommand(schema.Cmd)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
<head>
<meta name="generator" content="Hugo 0.139.0">
<meta name="generator" content="Hugo 0.149.0">
<link href="http://gmpg.org/xfn/11" rel="profile">
<meta http-equiv="content-type" content="text/html; charset=utf-8">

Expand Down
19 changes: 0 additions & 19 deletions endpoints/cypher/README.md

This file was deleted.

60 changes: 0 additions & 60 deletions endpoints/cypher/handle.go

This file was deleted.

Loading
Loading