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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ For example, if the host cwd looks like:
Then the docker command to run a container mounting the `/res` directory might look like this:
```sh
docker run -it --rm -v $(pwd)/res:/data -e 'SPARQL_ENDPOINT=http://localhost:7200/repositories/${org}-${repo}' graphql
docker run -v ./data:/data -e 'SPARQL_ENDPOINT=http://localhost:8080/orgs/${org}/repos/${repo}/${branchesLocks}/${branch}/query' -p 3001:3001 flexo-graphql
```

### Without docker
Expand All @@ -55,6 +56,7 @@ vr install
Define 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 target `orgId` the user is querying
- `${repo}` -- replaced with the target `repoId` the user is querying
- `${branchesLocks}` -- replaced with 'branches' or 'locks'
- `${branch}` -- replaced with the target `branchId` the user is querying

For example:
Expand Down Expand Up @@ -85,9 +87,9 @@ vr serve -c context.json -s schema.graphql

By 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`
The GraphQL endpoint will be available (via POST requests) at: `/orgs/${org}/repos/${repo}/${branchesLocks}/${branch}/graphql`

Additionally, a GraphiQL interface is exposed at: `/orgs/${org}/repos/${repo}/branches/${branch}/`
Additionally, a GraphiQL interface is exposed at: `/orgs/${org}/repos/${repo}/${branchesLocks}/${branch}/`


## Documentation
Expand Down
7 changes: 7 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ <h1>Flexo GraphQL Service</h1>
<span>Repo:</span>
<input type="text" name="repo">
</label>
<label>
<span>Branch or Lock:</span>
<select name="branchesLocks">
<option value="branches" selected>Branch</option>
<option value="locks">Lock</option>
</select>
</label>
<label>
<span>Branch:</span>
<input type="text" name="branch" placeholder="master">
Expand Down
6 changes: 3 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const sx_graphql_schema_transformed = print(y_doc_schema_transformed) as string;
const y_apollo = new SchemaHandler(sx_graphql_schema_transformed);

// route pattern
const sx_pattern = `/orgs/:org/repos/:repo/branches/:branch`;
const sx_pattern = `/orgs/:org/repos/:repo/:branchesLocks/:branch`;

async function graphiql(y_ctx: RouterContext<string>) {
await send(y_ctx, './', {
Expand All @@ -122,7 +122,7 @@ const y_router = new Router()
.get('/', async(y_ctx) => {
const d_params = y_ctx.request.url.searchParams;
if(d_params.has('org') && d_params.has('repo')) {
return await y_ctx.response.redirect(`/orgs/${d_params.get('org')}/repos/${d_params.get('repo')}/branches/${d_params.get('branch') || 'master'}/`);
return await y_ctx.response.redirect(`/orgs/${d_params.get('org')}/repos/${d_params.get('repo')}/${d_params.get('branchesLocks')}/${d_params.get('branch') || 'master'}/`);
}

await send(y_ctx, './', {
Expand Down Expand Up @@ -247,7 +247,7 @@ const y_router = new Router()

// materialize endpoint URL
const p_endpoint: string = P_ENDPOINT.replace(/\$\{([^}]+)\}/g, (s_0, s_var: keyof typeof h_params) => h_params[s_var]!);

console.log('sending to ' + p_endpoint);
// collect all other headers
const h_headers = scrub_headers(d_req);

Expand Down