wundergraph.andert.me/.wundergraph/wundergraph.config.ts
2022-11-03 14:24:01 +05:30

53 lines
1.2 KiB
TypeScript
Executable File

import {
Application,
configureWunderGraphApplication,
cors,
EnvironmentVariable,
introspect,
templates,
} from "@wundergraph/sdk";
import server from "./wundergraph.server";
import operations from "./wundergraph.operations";
const weather = introspect.graphql({
apiNamespace: "weather",
url: "https://graphql-weather-api.herokuapp.com/",
});
const myApplication = new Application({
name: "app",
apis: [weather],
});
// configureWunderGraph emits the configuration
configureWunderGraphApplication({
application: myApplication,
server,
operations,
codeGenerators: [
{
templates: [
...templates.typescript.all,
templates.typescript.operations,
templates.typescript.linkBuilder,
],
},
],
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,
},
});