commit 53e657d7aeddb1cccde58930d3ffbc6540af6553 Author: Nithin Kumar B Date: Fri Oct 28 18:12:05 2022 +0530 feat: init diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..a5db1c9 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/.wundergraph/.graphqlconfig b/.wundergraph/.graphqlconfig new file mode 100644 index 0000000..6ebec4c --- /dev/null +++ b/.wundergraph/.graphqlconfig @@ -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" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/.wundergraph/operations/Starters.graphql b/.wundergraph/operations/Starters.graphql new file mode 100644 index 0000000..7d893b5 --- /dev/null +++ b/.wundergraph/operations/Starters.graphql @@ -0,0 +1,8 @@ +query Starters { + pokemon_pokemons(limit: 12) { + results { + id + name + } + } +} diff --git a/.wundergraph/wundergraph.config.ts b/.wundergraph/wundergraph.config.ts new file mode 100755 index 0000000..b5c62b1 --- /dev/null +++ b/.wundergraph/wundergraph.config.ts @@ -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, + }, +}); diff --git a/.wundergraph/wundergraph.operations.ts b/.wundergraph/wundergraph.operations.ts new file mode 100755 index 0000000..47ccae4 --- /dev/null +++ b/.wundergraph/wundergraph.operations.ts @@ -0,0 +1,32 @@ +import { configureWunderGraphOperations } from '@wundergraph/sdk'; +import type { OperationsConfiguration } from './generated/wundergraph.operations'; + +export default configureWunderGraphOperations({ + 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: {}, + }, +}); diff --git a/.wundergraph/wundergraph.server.ts b/.wundergraph/wundergraph.server.ts new file mode 100755 index 0000000..1015fa7 --- /dev/null +++ b/.wundergraph/wundergraph.server.ts @@ -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(() => ({ + hooks: { + queries: {}, + mutations: {}, + }, + graphqlServers: [] +})); diff --git a/README.md b/README.md new file mode 100644 index 0000000..223eaf8 --- /dev/null +++ b/README.md @@ -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). + diff --git a/package.json b/package.json new file mode 100755 index 0000000..b9ade56 --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100755 index 0000000..fedc80f --- /dev/null +++ b/tsconfig.json @@ -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"] +}