feat: init

This commit is contained in:
Nithin Kumar B
2022-10-28 18:12:05 +05:30
commit 53e657d7ae
9 changed files with 231 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
{
"projects": {
"app": {
"name": "app",
"schemaPath": "generated/wundergraph.app.schema.graphql",
"extensions": {
"endpoints": {
"app": {
"introspect": false,
"url": "http://localhost:9991/app/main/graphql",
"headers": {
"user-agent": "WunderGraph Client"
}
}
}
}
}
}
}

View File

@@ -0,0 +1,8 @@
query Starters {
pokemon_pokemons(limit: 12) {
results {
id
name
}
}
}

View File

@@ -0,0 +1,51 @@
import {
Application,
configureWunderGraphApplication,
cors,
EnvironmentVariable,
introspect,
templates,
} from '@wundergraph/sdk';
import server from './wundergraph.server';
import operations from './wundergraph.operations';
const pokemonAPI = introspect.graphql({
apiNamespace: 'pokemon',
url: 'https://graphql-pokeapi.graphcdn.app/',
});
const myApplication = new Application({
name: 'app',
apis: [
pokemonAPI,
],
});
// 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,
},
});

View File

@@ -0,0 +1,32 @@
import { configureWunderGraphOperations } from '@wundergraph/sdk';
import type { OperationsConfiguration } from './generated/wundergraph.operations';
export default configureWunderGraphOperations<OperationsConfiguration>({
operations: {
defaultConfig: {
authentication: {
required: false,
},
},
queries: (config) => ({
...config,
caching: {
enable: false,
staleWhileRevalidate: 60,
maxAge: 60,
public: true,
},
liveQuery: {
enable: true,
pollingIntervalSeconds: 1,
},
}),
mutations: (config) => ({
...config,
}),
subscriptions: (config) => ({
...config,
}),
custom: {},
},
});

View File

@@ -0,0 +1,11 @@
import {configureWunderGraphServer} from '@wundergraph/sdk';
import type {HooksConfig} from './generated/wundergraph.hooks';
import type {InternalClient} from './generated/wundergraph.internal.client';
export default configureWunderGraphServer<HooksConfig, InternalClient>(() => ({
hooks: {
queries: {},
mutations: {},
},
graphqlServers: []
}));