feat: init
This commit is contained in:
commit
53e657d7ae
41
.gitignore
vendored
Executable file
41
.gitignore
vendored
Executable file
@ -0,0 +1,41 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
# WunderGraph build output
|
||||
.wundergraph/cache
|
||||
.wundergraph/generated
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
19
.wundergraph/.graphqlconfig
Normal file
19
.wundergraph/.graphqlconfig
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
.wundergraph/operations/Starters.graphql
Normal file
8
.wundergraph/operations/Starters.graphql
Normal file
@ -0,0 +1,8 @@
|
||||
query Starters {
|
||||
pokemon_pokemons(limit: 12) {
|
||||
results {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
51
.wundergraph/wundergraph.config.ts
Executable file
51
.wundergraph/wundergraph.config.ts
Executable 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,
|
||||
},
|
||||
});
|
32
.wundergraph/wundergraph.operations.ts
Executable file
32
.wundergraph/wundergraph.operations.ts
Executable 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: {},
|
||||
},
|
||||
});
|
11
.wundergraph/wundergraph.server.ts
Executable file
11
.wundergraph/wundergraph.server.ts
Executable 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: []
|
||||
}));
|
31
README.md
Normal file
31
README.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Simple starter for WunderGraph Cloud
|
||||
|
||||
A simple starter that consumes the [Pokémon GraphQL API](https://graphql-pokeapi.vercel.app).
|
||||
|
||||
### Getting started locally
|
||||
|
||||
```shell
|
||||
npm install && npm start
|
||||
```
|
||||
|
||||
Get first 3 starter Pokémon and their evolutions
|
||||
|
||||
```shell
|
||||
curl -X GET http://localhost:9991/app/main/operations/Starters
|
||||
```
|
||||
|
||||
---
|
||||
### Deploy to WunderGraph Cloud
|
||||
|
||||
|
||||
1. Fork this repo
|
||||
2. Sign in to [WunderGraph Cloud](https://cloud.wundergraph.com)
|
||||
3. Create a new project
|
||||
4. Import the forked repo
|
||||
5. Deploy the project
|
||||
|
||||
---
|
||||
### Learn More
|
||||
|
||||
Read the [Docs](https://wundergraph.com/docs).
|
||||
|
20
package.json
Executable file
20
package.json
Executable file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "wundergraph-simple",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"start": "wunderctl up --debug",
|
||||
"generate": "wunderctl generate up --debug",
|
||||
"check": "tsc --noEmit"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@wundergraph/sdk": "^0.117.0",
|
||||
"graphql": "^16.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.14.37",
|
||||
"typescript": "^4.8.2"
|
||||
}
|
||||
}
|
18
tsconfig.json
Executable file
18
tsconfig.json
Executable file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "commonjs",
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": [".wundergraph/**/*.ts"]
|
||||
}
|
Loading…
Reference in New Issue
Block a user