2022-10-28 12:42:05 +00:00
|
|
|
import {
|
2022-11-03 08:54:01 +00:00
|
|
|
Application,
|
|
|
|
configureWunderGraphApplication,
|
|
|
|
cors,
|
|
|
|
EnvironmentVariable,
|
|
|
|
introspect,
|
|
|
|
templates,
|
|
|
|
} from "@wundergraph/sdk";
|
|
|
|
import server from "./wundergraph.server";
|
|
|
|
import operations from "./wundergraph.operations";
|
2022-10-28 12:42:05 +00:00
|
|
|
|
2022-11-02 17:49:31 +00:00
|
|
|
const weather = introspect.graphql({
|
2022-11-03 08:54:01 +00:00
|
|
|
apiNamespace: "weather",
|
|
|
|
url: "https://graphql-weather-api.herokuapp.com/",
|
2022-10-28 12:42:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const myApplication = new Application({
|
2022-11-03 08:54:01 +00:00
|
|
|
name: "app",
|
|
|
|
apis: [weather],
|
2022-10-28 12:42:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// configureWunderGraph emits the configuration
|
|
|
|
configureWunderGraphApplication({
|
2022-11-03 08:54:01 +00:00
|
|
|
application: myApplication,
|
|
|
|
server,
|
|
|
|
operations,
|
|
|
|
codeGenerators: [
|
|
|
|
{
|
|
|
|
templates: [
|
|
|
|
...templates.typescript.all,
|
|
|
|
templates.typescript.operations,
|
|
|
|
templates.typescript.linkBuilder,
|
|
|
|
],
|
2022-10-28 12:42:05 +00:00
|
|
|
},
|
2022-11-03 08:54:01 +00:00
|
|
|
],
|
|
|
|
cors: {
|
|
|
|
...cors.allowAll,
|
|
|
|
allowedOrigins:
|
|
|
|
process.env.NODE_ENV === "production"
|
|
|
|
? [
|
|
|
|
// change this before deploying to production to the actual domain where you're deploying your app
|
|
|
|
"http://localhost:3000",
|
|
|
|
]
|
|
|
|
: [
|
|
|
|
"http://localhost:3000",
|
|
|
|
new EnvironmentVariable("WG_ALLOWED_ORIGIN"),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
dotGraphQLConfig: {
|
|
|
|
hasDotWunderGraphDirectory: false,
|
|
|
|
},
|
2022-10-28 12:42:05 +00:00
|
|
|
});
|