Skip to content

Commit

Permalink
JSON Schema artifacts on SDL (#4767)
Browse files Browse the repository at this point in the history
* Go

chore(dependencies): updated changesets for modified dependencies

Go

Go

Fix tests

Go

Cleanup

Go

Update snapshots

Go

Update snapshot

chore(dependencies): updated changesets for modified dependencies

Cleanup yarn.lock

chore(dependencies): updated changesets for modified dependencies

Go

Bring back bundle support

Backwards compat

Go

Trigger again

Try

Examples

More

Go

Cleanup

Go

* Go

* Update pr.yml

* chore(dependencies): updated changesets for modified dependencies

* Changeseta

* Fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
ardatan and github-actions[bot] authored Dec 7, 2022
1 parent 9c14d9c commit 3edaa00
Show file tree
Hide file tree
Showing 180 changed files with 81,887 additions and 824,837 deletions.
5 changes: 5 additions & 0 deletions .changeset/@graphql-mesh_openapi-4767-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-mesh/openapi": patch
---
dependencies updates:
- Added dependency [`@graphql-tools/[email protected]` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/9.1.3) (to `dependencies`)
5 changes: 5 additions & 0 deletions .changeset/@graphql-mesh_raml-4767-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-mesh/raml": patch
---
dependencies updates:
- Added dependency [`@graphql-tools/[email protected]` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/9.1.3) (to `dependencies`)
27 changes: 27 additions & 0 deletions .changeset/smart-balloons-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
'@graphql-mesh/cli': minor
'@graphql-mesh/config': minor
'@graphql-mesh/json-schema': minor
'@graphql-mesh/mongoose': minor
'@graphql-mesh/mysql': minor
'@graphql-mesh/neo4j': minor
'@graphql-mesh/odata': minor
'@graphql-mesh/openapi': minor
'@graphql-mesh/raml': minor
'@graphql-mesh/tuql': minor
'json-machete': minor
'@omnigraph/json-schema': minor
'@omnigraph/openapi': minor
'@omnigraph/raml': minor
'@omnigraph/soap': minor
'@graphql-mesh/runtime': minor
'@graphql-mesh/types': minor
---

*BREAKING* - Neo4J handler's `url` changed to `endpoint` to be consistent with other handlers
*BREAKING* - Neo4J handler's `typeDefs` changed to `source` to be consistent with other handlers
*BREAKING* - OData handler's `url` changed to `endpoint` to be consistent with other handlers
*BREAKING* - OData handler's `metadata` changed to `source` to be consistent with other handlers
*BREAKING* - OpenAPI handler's `baseUrl` changed to `endpoint` to be consistent with other handlers
*BREAKING* - RAML handler's `baseUrl` changed to `endpoint` to be consistent with other handlers
*BREAKING* - RAML handler's `ramlFilePath` changed to `source` to be consistent with other handlers
8 changes: 0 additions & 8 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,3 @@ jobs:
secrets:
githubToken: ${{ secrets.GITHUB_TOKEN }}
npmToken: ${{ secrets.NODE_AUTH_TOKEN }}

# algolia:
# uses: the-guild-org/shared-config/.github/workflows/algolia-integrity.yml@main
# with:
# domain: https://www.the-guild.dev/graphql/mesh/
# source: 'Mesh'
# secrets:
# githubToken: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion examples/auth0/.meshrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sources:
- name: PrivateAPI
handler:
jsonSchema:
baseUrl: http://localhost:3001
endpoint: http://localhost:3001
operations:
- type: Query
field: secret
Expand Down
2 changes: 1 addition & 1 deletion examples/cloudflare-workers/.meshrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sources:
- name: OpenBrewery
handler:
jsonSchema:
baseUrl: https://api.openbrewerydb.org
endpoint: https://api.openbrewerydb.org
operations:
- type: Query
field: breweries
Expand Down
2 changes: 1 addition & 1 deletion examples/hasura-openbrewery-geodb/.meshrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sources:
- name: OpenBrewery
handler:
jsonSchema:
baseUrl: https://api.openbrewerydb.org
endpoint: https://api.openbrewerydb.org
operations:
- type: Query
field: breweries
Expand Down
47 changes: 31 additions & 16 deletions examples/hasura-openbrewery-geodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,29 @@
This example takes two API sources and merges them together:

1. Postgres GeoDB - a seed database of geo locations and their metadata (uses Hasura GraphQL Engine)
2. OpenBrewery API - a free API for public information on breweries, cideries, brewpubs, and bottleshops.
2. OpenBrewery API - a free API for public information on breweries, cideries, brewpubs, and
bottleshops.

The two schemas are connected and let you search for locations, and then fetch breweries that are located in that location.
The two schemas are connected and let you search for locations, and then fetch breweries that are
located in that location.

### Create GeoDB Database

Because a running Postgres DB is required, you need to setup local Postgres running, and load the schema and data seed.
Because a running Postgres DB is required, you need to setup local Postgres running, and load the
schema and data seed.

To do that, run the following:

1. Install and run Postgres using Docker - `docker run --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 postgres`
1. Install and run Postgres using Docker -
`docker run --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 postgres`
2. Install Postgres CLI: `brew upgrade postgresql` (or, you can use any of your favorite tool)
3. Seed the DB with data: `curl https://raw.githubusercontent.com/morenoh149/postgresDBSamples/master/worldDB-1.0/world.sql | psql -h localhost -d postgres -U postgres`
3. Seed the DB with data:
`curl https://raw.githubusercontent.com/morenoh149/postgresDBSamples/master/worldDB-1.0/world.sql | psql -h localhost -d postgres -U postgres`

### Create Hasura Instance

We need to install Hasura using Docker but we will use a special version of Hasura to benefit from Remote Joins;
We need to install Hasura using Docker but we will use a special version of Hasura to benefit from
Remote Joins;

```sh
docker run -d -p 8080:8080 \
Expand All @@ -30,8 +36,8 @@ docker run -d -p 8080:8080 \

### Create GraphQL Mesh Project

We need to have `yarn` and Node.js on our computer to run GraphQL Mesh locally.
Run the following command to create a new project on an empty directory;
We need to have `yarn` and Node.js on our computer to run GraphQL Mesh locally. Run the following
command to create a new project on an empty directory;

```sh
yarn init
Expand All @@ -45,9 +51,11 @@ yarn add graphql @graphql-mesh/cli @graphql-mesh/json-schema

### Create Proxy GraphQL API to OpenBrewery

OpenBrewery doesn't have any kind of recognized schema metadata, so we need to create our own using JSON Schema Handler;
OpenBrewery doesn't have any kind of recognized schema metadata, so we need to create our own using
JSON Schema Handler;

In OpenBrewery's documentation, they have examples for both request and response objects. Let's create files for each inside `/json-schemas` directory;
In OpenBrewery's documentation, they have examples for both request and response objects. Let's
create files for each inside `/json-schemas` directory;

```json filename="breweries.json"
// breweries.json
Expand Down Expand Up @@ -94,7 +102,7 @@ sources:
- name: OpenBrewery
handler:
jsonSchema:
baseUrl: https://api.openbrewerydb.org
endpoint: https://api.openbrewerydb.org
operations:
- type: Query
field: breweries
Expand All @@ -114,23 +122,30 @@ yarn mesh dev

### Connect new OpenBrewery API to Hasura

Go to [Remote Schemas](http://localhost:8080/console/remote-schemas/manage/schemas) tab in Hasura and add our OpenBrewery GraphQL API which has `http://host.docker.internal:4000/graphql`.
Go to [Remote Schemas](http://localhost:8080/console/remote-schemas/manage/schemas) tab in Hasura
and add our OpenBrewery GraphQL API which has `http://host.docker.internal:4000/graphql`.

> `host.docker.internal` is used because Docker accesses your host machine `localhost` under this alias.
> `host.docker.internal` is used because Docker accesses your host machine `localhost` under this
> alias.
### Create GraphQL fields for GeoDB

Go to [Data](http://localhost:8080/console/data/schema/public) tab in Hasura and track all the tables to see how complex relationships work with Mesh.
Go to [Data](http://localhost:8080/console/data/schema/public) tab in Hasura and track all the
tables to see how complex relationships work with Mesh.

### Create Remote Join between GeoDB and OpenBrewery

Let's say we would like to see breweries in a specific city. Go to [Data](http://localhost:8080/console/data/schema/public) tab in Hasura and scroll down to **Remote Relationships** section. Add `breweries` field to `City` by connecting `breweries.by_city` argument and `City.name` parent field like below;
Let's say we would like to see breweries in a specific city. Go to
[Data](http://localhost:8080/console/data/schema/public) tab in Hasura and scroll down to **Remote
Relationships** section. Add `breweries` field to `City` by connecting `breweries.by_city` argument
and `City.name` parent field like below;

![image](https://user-images.githubusercontent.com/20847995/83945179-a71fa200-a811-11ea-81fc-e641e68bc9ce.png)

### Make a query to see how it works

Go to [GraphiQL](http://localhost:8080/console/api-explorer) and make a query like below to see how the integration works;
Go to [GraphiQL](http://localhost:8080/console/api-explorer) and make a query like below to see how
the integration works;

```graphql
{
Expand Down
Loading

0 comments on commit 3edaa00

Please sign in to comment.