Skip to content

Commit

Permalink
qed.gql: the {uri} resolver of {reader} now understands real URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
aivazis committed Oct 3, 2022
1 parent bea4db7 commit 60f22d0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions pkg/gql/Reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@

# externals
import graphene

# support
import qed

# my interface
from .Node import Node

# my parts
from .Dataset import Dataset
from .Selectors import Selectors
Expand All @@ -22,7 +27,7 @@ class Reader(graphene.ObjectType):
# {graphene} metadata
class Meta:
# register my interface
interfaces = Node,
interfaces = (Node,)

# my fields
id = graphene.ID()
Expand All @@ -32,7 +37,6 @@ class Meta:
selectors = graphene.List(Selectors)
datasets = graphene.List(Dataset)


# the resolvers
def resolve_id(reader, *_):
"""
Expand All @@ -41,22 +45,25 @@ def resolve_id(reader, *_):
# splice together the {family} and {name} of the {reader}
return f"{reader.pyre_family()}:{reader.pyre_name}"


def resolve_name(reader, *_):
"""
Get the {reader} name
"""
# return the {pyre_id} of the {reader}
return reader.pyre_name


def resolve_uri(reader, *_):
"""
Get the path to the file
"""
# turn the {uri} into an absolute path and send it off
return reader.uri.resolve()

# get the uri
uri = reader.uri
# if it's a file
if uri.scheme is None or uri.scheme == "file":
# get the address and turn it into an absolute path
return qed.primitives.path(uri.address).resolve()
# otherwise, just return the uri
return str(uri)

def resolve_api(reader, *_):
"""
Expand All @@ -65,14 +72,12 @@ def resolve_api(reader, *_):
# requests are resolved against {data}
return "data"


def resolve_selectors(reader, *_):
"""
Build a list of the selector names and their allowed values
"""
return reader.selectors.items()


def resolve_datasets(reader, *_):
"""
Build a list of the available datasets
Expand Down

0 comments on commit 60f22d0

Please sign in to comment.