Skip to content

Commit

Permalink
graphiql fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rrmerugu committed Jun 15, 2022
1 parent 7154137 commit 5821fa8
Showing 7 changed files with 110 additions and 113 deletions.
5 changes: 3 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -7,9 +7,10 @@ name = "pypi"
starlette = "*"
uvicorn = "*"
graphene = "*"
starlette-graphene3 = "*"
websockets = "*"
invana = {ref = "dev", git = "https://github.com/invanalabs/invana-py.git"}
invana = {ref = "dev", git = "https://github.com/invana/invana"}
graphql-core = "*"
starlette-graphene3 = {ref = "6b2c1a4d9cd43e69a08b0dc66d398d41de9a158b", git = "https://github.com/rrmerugu/starlette-graphene3"}

[dev-packages]
pytest = "*"
192 changes: 94 additions & 98 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gremlin-notes.md
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ pipenv install git+https://github.com/invanalabs/invana-py.git@dev#egg=invana

```bash

docker run --name janusgraph-instance-1 -d -p 8182:8182 janusgraph/janusgraph
docker run --name janusgraph-test-instance-1 -d -p 8184:8182 janusgraph/janusgraph
docker run --restart always --name janusgraph-instance-1 -d -p 8182:8182 janusgraph/janusgraph
docker run --restart always --name janusgraph-test-instance-1 -d -p 8184:8182 janusgraph/janusgraph

```

8 changes: 4 additions & 4 deletions invana_engine/graph/query_resolvers.py
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from invana_engine.data_types import NodeOrEdgeType, AnyField
from invana_engine.settings import DEFAULT_QUERY_TIMEOUT
import graphene


@@ -30,10 +31,9 @@


class GremlinGenericQuerySchema:
execute_query = graphene.Field(graphene.List(AnyField), timeout=graphene.Int(), gremlin=graphene.String())
execute_query = graphene.Field(graphene.List(AnyField), timeout=graphene.Int(default_value=DEFAULT_QUERY_TIMEOUT),
gremlin=graphene.String())

def resolve_execute_query(self, info: graphene.ResolveInfo, gremlin: str, timeout: int) -> any:
response = info.context['request'].app.state.graph.execute_query(gremlin, timeout=timeout)
return [d.to_json() for d in response.data]


return [d.to_json() for d in response.data] if response.data else []
8 changes: 4 additions & 4 deletions invana_engine/modeller/query_resolvers.py
Original file line number Diff line number Diff line change
@@ -42,13 +42,13 @@ def resolve_features(self, info):


class GenericClientInfoSchema(graphene.ObjectType):
hello = graphene.String(name=graphene.String(default_value="World"))
get_client_info = graphene.Field(GremlinClientInfo)
_hello = graphene.String(name=graphene.String(default_value="World"))
_get_client_info = graphene.Field(GremlinClientInfo)

def resolve_hello(self, info, name):
def resolve__hello(self, info, name):
return name

def resolve_get_client_info(self, info):
def resolve__get_client_info(self, info):
result = get_client_info()
result['gremlin_host'] = get_host(info.context['request'].app.state.graph.connector.gremlin_url)
result['gremlin_traversal_source'] = info.context['request'].app.state.graph.connector.traversal_source
4 changes: 2 additions & 2 deletions invana_engine/server/app.py
Original file line number Diff line number Diff line change
@@ -29,14 +29,14 @@
from starlette.routing import Route
from invana_engine.server.views import homepage_view
from invana_engine.settings import gremlin_server_url, shall_debug, \
gremlin_traversal_source
gremlin_traversal_source, server_port
from starlette_graphene3 import GraphQLApp, make_graphiql_handler
from invana import InvanaGraph
from .schema import get_schema
from .graph import graph

print(".................................................")
print("Starting Invana Engine server")
print(f"Starting Invana Engine server at port {server_port}")
print(f"Using GREMLIN_SERVER_URL: {gremlin_server_url}")
print(f"Using GREMLIN_TRAVERSAL_SOURCE: {gremlin_traversal_source}")
print(f"Using DEBUG: {shall_debug}")
2 changes: 1 addition & 1 deletion invana_engine/settings.py
Original file line number Diff line number Diff line change
@@ -21,4 +21,4 @@
gremlin_traversal_source = os.environ.get("GREMLIN_TRAVERSAL_SOURCE", "g")
shall_debug = os.environ.get("DEBUG", False)
server_port = os.environ.get("SERVER_PORT", 8200)

DEFAULT_QUERY_TIMEOUT = 180

0 comments on commit 5821fa8

Please # to comment.