From bf1e8afccd5cfc3b41c38bbb19d0384976731789 Mon Sep 17 00:00:00 2001 From: Nithin Kumar B Date: Fri, 2 Dec 2022 16:54:48 +0530 Subject: [PATCH] migrate to spacex api --- .wundergraph/operations/Dragons.graphql | 11 +++++++++++ .wundergraph/operations/Weather.graphql | 23 ----------------------- .wundergraph/wundergraph.config.ts | 8 ++++---- .wundergraph/wundergraph.server.ts | 4 ++-- README.md | 16 ++++++++-------- 5 files changed, 25 insertions(+), 37 deletions(-) create mode 100644 .wundergraph/operations/Dragons.graphql delete mode 100644 .wundergraph/operations/Weather.graphql diff --git a/.wundergraph/operations/Dragons.graphql b/.wundergraph/operations/Dragons.graphql new file mode 100644 index 0000000..5e8d9cf --- /dev/null +++ b/.wundergraph/operations/Dragons.graphql @@ -0,0 +1,11 @@ +query Dragons { + spacex_dragons { + name + active + # remove the comments to add thrusters to the query + # thrusters { + # amount + # pods + # } + } +} diff --git a/.wundergraph/operations/Weather.graphql b/.wundergraph/operations/Weather.graphql deleted file mode 100644 index 7e77faf..0000000 --- a/.wundergraph/operations/Weather.graphql +++ /dev/null @@ -1,23 +0,0 @@ -query ($city: String!) { - weather_getCityByName(name: $city, config: { units: metric }) { - # remove the comments to add the coordinates to the query - # coordinates: coord { - # lat - # lon - # } - country - weather { - temperature { - actual - feelsLike - min - max - } - summary { - title - description - icon - } - } - } -} diff --git a/.wundergraph/wundergraph.config.ts b/.wundergraph/wundergraph.config.ts index fd03701..d5128cc 100755 --- a/.wundergraph/wundergraph.config.ts +++ b/.wundergraph/wundergraph.config.ts @@ -8,14 +8,14 @@ import { import server from "./wundergraph.server"; import operations from "./wundergraph.operations"; -const weather = introspect.graphql({ - apiNamespace: "weather", - url: "https://graphql-weather-api.herokuapp.com/", +const spacex = introspect.graphql({ + apiNamespace: "spacex", + url: "https://spacex-api.fly.dev/graphql", }); // configureWunderGraph emits the configuration configureWunderGraphApplication({ - apis: [weather], + apis: [spacex], server, operations, codeGenerators: [ diff --git a/.wundergraph/wundergraph.server.ts b/.wundergraph/wundergraph.server.ts index d167ec4..a6f1bf3 100755 --- a/.wundergraph/wundergraph.server.ts +++ b/.wundergraph/wundergraph.server.ts @@ -5,9 +5,9 @@ import type { InternalClient } from "./generated/wundergraph.internal.client"; export default configureWunderGraphServer(() => ({ hooks: { queries: { - Weather: { + Dragons: { postResolve: async (hook) => { - hook.log.info("postResolve hook for Weather"); + hook.log.info("postResolve hook for Dragons"); }, }, }, diff --git a/README.md b/README.md index b276a0c..b2e7738 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Simple starter for WunderGraph Cloud -A simple starter that consumes the [GraphQL Weather API](https://graphql-weather-api.herokuapp.com/). +A simple starter that consumes the [GraphQL SpaceX API](https://spacex-api.fly.dev/graphql/). ### Getting started locally @@ -8,15 +8,15 @@ A simple starter that consumes the [GraphQL Weather API](https://graphql-weather npm install && npm start ``` -Get the weather for Berlin. +Get SpaceX Dragons ```shell -curl -X GET http://localhost:9991/operations/Weather?city=Berlin +curl -X GET http://localhost:9991/operations/Dragons ``` --- -### Deploy to WunderGraph Cloud +### Deploy to WunderGraph Cloud 1. Fork this repo 2. Sign in to [WunderGraph Cloud](https://cloud.wundergraph.com) @@ -27,22 +27,22 @@ curl -X GET http://localhost:9991/operations/Weather?city=Berlin Try it out (replace `YOUR_PROJECT_ID` with your project id): ```shell -curl -X GET https://{YOUR_PROJECT_NAME}.wundergraph.dev/operations/Weather?city=Berlin +curl -X GET https://{YOUR_PROJECT_NAME}.wundergraph.dev/operations/Dragons ``` ### Make changes -1. Make changes to the `main` branch, e.g. change the query in `.wundergraph/operations/Weather.graphql` +1. Make changes to the `main` branch, e.g. change the query in `.wundergraph/operations/Dragons.graphql` 2. Commit and push the changes See your changes live in less than 20 seconds. ```shell -curl -X GET https://{YOUR_PROJECT_NAME}.wundergraph.dev/operations/Weather?city=Berlin +curl -X GET https://{YOUR_PROJECT_NAME}.wundergraph.dev/operations/Dragons ``` --- + ### Learn More Read the [Docs](https://wundergraph.com/docs). -