- Deno
- (optional) https://velociraptor.run/ (script runner for Deno projects)
vr installDefine a SPARQL_ENDPOINT environment variable that binds a pattern for the URL. The server will make the following substitutions in the pattern:
${org}-- replaced with the targetorgIdthe user is querying${repo}-- replaced with the targetrepoIdthe user is querying${branch}-- replaced with the targetbranchIdthe user is querying
For example:
# notice the use of single quotes to prevent shell substitution of ${..}
SPARQL_ENDPOINT='http://localhost:7200/repositories/${org}-${repo}'With this configuratino, a request to https://graphql-server/orgs/mms/repos/test/branches/master would forward a SPARQL request to http://localhost:7200/repositories/mms-test.
Usage: vr serve [OPTIONS]
Options:
-c, --context PATH [required] path to JSON-LD context file
-s, --schema PATH [required] path to GraphQL schema file
-p, --port VALUE [optional] port number to bind server
vr serve -c context.json -s schema.graphqlBy default, the server attempts to bind to port 3001.
The GraphQL endpoint will be available (via POST requests) at: /orgs/${org}/repos/${repo}/branches/${branch}/graphql
Additionally, a GraphiQL interface is exposed at: /orgs/${org}/repos/${repo}/branches/${branch}/
The endpoint provides schema introspection to help clients validate their queries.
Can be used to apply a filter on scalar values:
{
item {
# select items where the `name` property is exactly "Batman"
name @filter(is: "Batman")
}
}The sole named argument provided to the @filter directive should be one of the following:
| Keyword | Argument type | Comments |
|---|---|---|
| is | String | exact match |
| not | String | not exact match |
| in | [String] | value appears in list |
| notIn | [String] | value not in list |
| contains | String | value contains substring |
| notContains | String | (negated) |
| startsWith | String | value starts with string |
| notStartsWith | String | (negated) |
| endsWith | String | value ends with string |
| notEndsWith | String | (negated) |
| regex | String | regular expression match |
| notRegex | String | (negated) |
| equals | Float | numeric equals |
| notEquals | Float | (negated) |
| lessThan | Float | numeric less than |
| notLessThan | Float | (negated) |
| greaterThan | Float | numeric greater than |
| notGreaterThan | Float | (negated) |
| lessThanOrEqualTo | Float | ... |
| notLessThanOrEqualTo | Float | (negated) |
| greaterThanOrEqualTo | Float | ... |
| notGreaterThanOrEqualTo | Float | (negated) |
Tells the service where to collate results:
{
pickLists {
# Picklist:PickListOptions is a 1:many relation
options: _inv_pickList @many {
...on PickListOption {
name
}
}
}
}Properties that are prefixed by _inv_ signify an incoming relationship from another object:
{
user {
# select a user by their email
email @filter(is: "jdoe@ex.org")
# find items that were "createdBy" this user
item: _inv_createdBy {
name # the item's name
}
}
}The special _any property can be used to select any predicate (including ones not defined in the schema):
{
item {
# `_any` is a wildcard, assign it the alias "version" in the results
version: _any {
# specify the intended type (i.e. a Version instance) using an inline fragment
...on Version {
id # the version's id
}
}
}
}Development tools/dependencies are managed using yarn and package.json.
To set up the development environment:
yarn installChecking for updates to the development dependencies:
yarn dev-update-checkApplying updates to the development dependencies:
yarn dev-upgrade