Showing preview only (268K chars total). Download the full file or copy to clipboard to get everything.
Repository: graphcool/graphql-cli
Branch: master
Commit: aa709566b74a
Files: 145
Total size: 234.9 KB
Directory structure:
gitextract_ex53v_nb/
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ └── workflows/
│ ├── algolia-integrity.yml
│ ├── algolia-publish.yml
│ ├── main.yml
│ └── website.yml
├── .gitignore
├── .npmrc
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── docs/
│ ├── CUSTOM_EXTENSION.md
│ └── MIGRATION.md
├── integration/
│ ├── package.json
│ ├── test-project/
│ │ ├── .dockerignore
│ │ ├── .gitignore
│ │ ├── .graphqlrc.yml
│ │ ├── package.json
│ │ ├── renovate.json
│ │ ├── schema/
│ │ │ └── schema.graphql
│ │ ├── tsconfig.json
│ │ └── tslint.json
│ ├── tests/
│ │ └── workflow.ts
│ └── tsconfig.json
├── lerna.json
├── package.json
├── packages/
│ ├── cli/
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── CONTRIBUTING.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src/
│ │ │ ├── bin.ts
│ │ │ ├── discover.ts
│ │ │ └── index.ts
│ │ └── tsconfig.json
│ ├── commands/
│ │ ├── generate/
│ │ │ ├── .gitignore
│ │ │ ├── README.md
│ │ │ ├── package.json
│ │ │ ├── src/
│ │ │ │ └── index.ts
│ │ │ └── tsconfig.json
│ │ ├── init/
│ │ │ ├── .gitignore
│ │ │ ├── .npmignore
│ │ │ ├── README.md
│ │ │ ├── package.json
│ │ │ ├── src/
│ │ │ │ ├── common.ts
│ │ │ │ ├── features/
│ │ │ │ │ ├── codegen.ts
│ │ │ │ │ └── inspector.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── search-codegen-config.ts
│ │ │ │ └── sources/
│ │ │ │ ├── from-existing.ts
│ │ │ │ ├── from-open-api.ts
│ │ │ │ └── from-scratch.ts
│ │ │ └── tsconfig.json
│ │ └── serve/
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src/
│ │ │ └── index.ts
│ │ └── tsconfig.json
│ ├── common/
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── package.json
│ │ ├── src/
│ │ │ ├── command.ts
│ │ │ ├── index.ts
│ │ │ └── types.ts
│ │ └── tsconfig.json
│ └── loaders/
│ ├── .gitignore
│ ├── .npmignore
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── renovate.json
├── scripts/
│ ├── introspect-config.js
│ └── release.js
├── templates/
│ └── fullstack/
│ ├── .dockerignore
│ ├── .gitignore
│ ├── .graphqlrc.yml
│ ├── Dockerfile
│ ├── README.md
│ ├── client/
│ │ ├── .gitignore
│ │ ├── generated-types.tsx
│ │ ├── package.json
│ │ ├── public/
│ │ │ ├── index.html
│ │ │ ├── manifest.json
│ │ │ └── robots.txt
│ │ ├── src/
│ │ │ ├── App.css
│ │ │ ├── App.test.tsx
│ │ │ ├── App.tsx
│ │ │ ├── components/
│ │ │ │ ├── comment/
│ │ │ │ │ ├── Comment.css
│ │ │ │ │ ├── CreateComment.tsx
│ │ │ │ │ └── OneComment.tsx
│ │ │ │ └── notes/
│ │ │ │ ├── CreateNote.tsx
│ │ │ │ ├── EditNote.tsx
│ │ │ │ ├── Note.css
│ │ │ │ └── OneNote.tsx
│ │ │ ├── generated-types.tsx
│ │ │ ├── graphql/
│ │ │ │ └── graphback.graphql
│ │ │ ├── index.css
│ │ │ ├── index.tsx
│ │ │ ├── react-app-env.d.ts
│ │ │ └── serviceWorker.ts
│ │ └── tsconfig.json
│ ├── docker-compose.yml
│ ├── model/
│ │ └── datamodel.graphql
│ ├── package.json
│ ├── renovate.json
│ ├── schemats.json
│ ├── server/
│ │ ├── package.json
│ │ ├── src/
│ │ │ ├── db.ts
│ │ │ ├── generated-db-types.ts
│ │ │ ├── generated-types.ts
│ │ │ ├── graphql.ts
│ │ │ ├── index.ts
│ │ │ └── schema/
│ │ │ └── schema.graphql
│ │ └── tsconfig.json
│ └── tslint.json
├── templates.json
└── website/
├── .gitignore
├── README.md
├── algolia-lockfile.json
├── babel.config.js
├── docs/
│ ├── codegen.md
│ ├── coverage.md
│ ├── custom-commands.md
│ ├── diff.md
│ ├── discover.md
│ ├── generate.md
│ ├── init.md
│ ├── introduction.md
│ ├── introspect.md
│ ├── migration.md
│ ├── serve.md
│ ├── similar.md
│ └── validate.md
├── docusaurus.config.js
├── package.json
├── scripts/
│ └── algolia-ci.ts
├── sidebars.js
├── src/
│ ├── css/
│ │ └── custom.css
│ ├── pages/
│ │ ├── index.js
│ │ └── styles.module.css
│ └── theme/
│ └── Root.js
└── static/
├── CNAME
└── js/
└── light-mode-by-default.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Versions (please complete the following information):**
- OS: [e.g. `Windows 10`, `OS X High Sierra`, `Ubuntu 16.04`]
- `graphql-cli`: [e.g. `2.16.5`]
- other packages if applicable
**Additional context**
Add any other context about the problem here.
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
================================================
FILE: .github/workflows/algolia-integrity.yml
================================================
name: Algolia Integrity
on:
pull_request:
paths:
- 'website/**'
jobs:
algolia-records-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node 18
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: Install Dependencies
run: yarn --ignore-engines
working-directory: ./website
- name: Build Packages
run: yarn build
working-directory: ./website
- name: Algolia generate
run: yarn algolia-sync
working-directory: ./website
env:
ALGOLIA_DRY_RUN: true
SITE_URL: https://www.graphql-cli.com/
- name: Yarn build at root
run: yarn
- name: Prettier
run: yarn prettier -w website/algolia-lockfile.json
- name: Compare
run: git diff origin/${{ github.base_ref }}.. -- website/algolia-lockfile.json
- name: Diff to file
if: always()
id: diff_result
run: |
OUTPUT=$(git diff origin/${{ github.base_ref }}.. -- website/algolia-lockfile.json)
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "::set-output name=result::$OUTPUT"
- name: Publish a message
if: always() && contains(steps.diff_result.outputs.result, 'diff')
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
```diff
${{ steps.diff_result.outputs.result }}
```
================================================
FILE: .github/workflows/algolia-publish.yml
================================================
name: Algolia Publish
on:
push:
branches:
- master
jobs:
algolia-push-records:
name: Push new records if changes
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Use Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: Install Dependencies
run: yarn
working-directory: ./website
- name: Build Packages
run: yarn build
working-directory: ./website
- name: Algolia push
run: yarn algolia-sync
working-directory: ./website
env:
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_ADMIN_API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }}
ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }}
SITE_URL: https://www.graphql-cli.com/
- name: Yarn build at root
run: yarn
- name: Prettier
run: yarn prettier -w website/algolia-lockfile.json
- name: Compare
run: git diff website/algolia-lockfile.json
- name: Diff to file
if: always()
id: diff_result
run: |
OUTPUT=$(git diff website/algolia-lockfile.json)
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "::set-output name=result::$OUTPUT"
- name: Commit algolia-lockfile.json
if: always() && contains(steps.diff_result.outputs.result, 'diff')
uses: EndBug/add-and-commit@v9
with:
commit: website/algolia-lockfile.json
message: Update algolia-lockfile.json
default_author: github_actions
================================================
FILE: .github/workflows/main.yml
================================================
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
release:
types: [released, prereleased]
jobs:
test:
name: Testing on ${{matrix.os}} and Node ${{matrix.node_version}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node_version: [12, 14, 16]
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node ${{matrix.node_version}}
uses: actions/setup-node@master
with:
version: ${{ matrix.node_version }}
- name: Install Dependencies using Yarn
run: yarn --ignore-engines
- name: Build
run: yarn build
- name: Test
run: yarn test
publish-canary:
name: Publish Canary
runs-on: ubuntu-latest
if: ${{ github.event_name != 'release' }}
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install Dependencies using Yarn
run: yarn --ignore-engines
- name: Build
run: yarn build
- name: Release Canary
run: |
echo "Fork PR: ${{github.repository}}"
if [ "${{github.repository}}" == "Urigo/graphql-cli" ] && [ "${{ secrets.NODE_AUTH_TOKEN }}" != "" ]
then
echo "//registry.npmjs.org/:_authToken=${{ secrets.NODE_AUTH_TOKEN }}" > .npmrc
npm run release:canary
else
echo "Skipping canary publish due to a fork/PR..."
fi
publish:
# publish to npm only when doing the release
if: ${{ github.event_name == 'release' }}
name: Publish Release
runs-on: ubuntu-latest
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install Dependencies using Yarn
run: yarn --ignore-engines
- name: Build
run: yarn build
- name: Release
run: echo "//registry.npmjs.org/:_authToken=${{secrets.NODE_AUTH_TOKEN}}" > ~/.npmrc && TAG=${GITHUB_REF#"refs/tags/"} npm run release
================================================
FILE: .github/workflows/website.yml
================================================
name: Website Deployment
on:
push:
branches:
- master
jobs:
deploy-website:
name: Deploy Website
timeout-minutes: 60
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '[deploy_website]') || contains(github.ref, 'refs/tags/')
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Configure Git Credientials
run: |
git config --global user.email "${{github.actor}}@users.noreply.github.com"
git config --global user.name "${{github.actor}}"
echo "machine github.com login ${{github.actor}} password ${{secrets.GITHUB_TOKEN}}" > ~/.netrc
- name: Add origin remote and refetch master
run: |
git remote rm origin
git remote add origin "https://github.com/${{github.repository}}"
git fetch
git checkout master
git reset --hard
- name: Use Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines --frozen-lockfile
- name: Deploy 🚀
run: yarn deploy:website
env:
GIT_USER: ${{github.actor}}
NEXT_PUBLIC_ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY: a5522203ca95675199cc21edf09e6d75
NEXT_PUBLIC_ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }}
================================================
FILE: .gitignore
================================================
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next
package-lock.json
================================================
FILE: .npmrc
================================================
save-exact=true
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing guide
We are using Yarn workspaces, so make sure you have the latest version of Yarn installed.
## Building project
To build the entire monorepo, start by installing the dependencies by running `yarn` in the root directory, and then:
```sh
yarn build
```
## Using command line tool from source
```sh
cd packages/cli
npm link .
```
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2019 Dotan Simha
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# GraphQL CLI


[](https://npmjs.org/package/graphql-cli "View this project on npm") [](https://the-guild.dev/discord)
Help us to improve new GraphQL CLI. Check out the new structure and commands below!
Feel free to contact us in Discord channel. We would love to hear your feedback.
## Features
- Helpful commands to improve your workflows
- Compatible with editors and IDEs based on [`graphql-config`](https://github.com/kamilkisiela/graphql-config)
- Powerful plugin system to extend `graphql-cli` with custom commands
## Install
You can install the CLI using `yarn` by running the following command. This will add the `graphql` binary to your path.
```sh
yarn global add graphql-cli
```
The equivalent npm global install will also work.
## Migration from 3.x.x to 4.x.x
**Important: many aspects of GraphQL CLI syntax and structure have changed in 4.x.x.** Please check out the [Migration Guide](./docs/MIGRATION.md) to learn more.
## Usage / Initialization
At the heart of a project created using GraphQL CLI is the GraphQL Config configuration file. For starters, this configuration lets the cd CLI tools know where all of the GraphQL documents and operations are. For more information about GraphQL Config, [you can click here to learn more](https://graphql-config.com/docs/introduction).
The most straightforward way to launch a GraphQL CLI-capable project with a working GraphQL Config setup is to use the `init` command from your desired workspace:
```sh
npx graphql-cli init
```
After a series of questions from the command-prompt, the system will use the inputs and selected project templates to generate a working project complete with a GraphQL Config setup. The GraphQL Config file is generated referencing the necessary files and ecosystem plugins.
You can also get started with GraphQL CLI by creating your own GraphQL Config file using an editor of your choice. Starting with a filename `.graphqlrc.yml`, for instance, we could add:
```yml
schema: "server/src/schema/**/*.graphql"
documents: "client/src/documents/**/*.graphql"
```
This is now a valid YAML-syntax GraphQL Config file. Using `init` from the GraphQL CLI will generate a project based on the instructions in your YAML.
Finally, one of the options with `graphql init` is to access schema using an OpenAPI or Swagger endpoint. Choose this option at the start of the Init question tree, and then follow the instructions to navigate to the URL of your choice.
## Plugin System
Each command in GraphQL CLI is a seperate package, so you can have your own plugins or use the ones we maintain. You can have those commands by installing them like `@graphql-cli/[COMMAND-NAME]`.
To configure a command/plugin, you need to update the `extensions` field in your GraphQL Config file (`.graphqlrc.yml`). See `extensions:` in the example below.
```yml
schema:
./server/src/schema/**/*.ts:
require: ts-node/register
documents: ./client/src/graphql/**/*.ts
extensions:
codegen:
generates:
./server/src/generated-types.d.ts:
plugins:
- typescript
- typescript-resolvers
./client/src/generated-types.tsx:
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
config:
withHooks: true
graphback:
model: './model/*.graphql'
plugins:
graphback-schema:
outputPath: './src/schema/schema.graphql'
...
```
[For a detailed example check out a template file here.](https://github.com/Urigo/graphql-cli/blob/master/templates/fullstack/.graphqlrc.yml)
Some of the available Plugins are:
- [`init`](https://github.com/Urigo/graphql-cli/tree/focs/packages/commands/init) - Creates a GraphQL project using a template or GraphQL Config file for your existing project.
- [`codegen`](https://github.com/dotansimha/graphql-code-generator/tree/master/packages/graphql-cli-codegen-plugin) - GraphQL Code Generator's GraphQL CLI plugin. GraphQL Code Generator is a tool that generates code from your GraphQL schema and documents for your backend or frontend with flexible support for custom plugins and templates. [Learn More](https://graphql-code-generator.com)
- [`generate`](https://github.com/Urigo/graphql-cli/tree/master/packages/commands/generate) - Generate schema and client-side documents for your GraphQL project by using [Graphback](https://graphback.dev).
- [`coverage`](https://github.com/kamilkisiela/graphql-inspector/tree/master/packages/graphql-cli/coverage) - Schema coverage based on documents. Find out how many times types and fields are used in your application using [GraphQL Inspector](https://graphql-inspector.com/docs/essentials/coverage).
- [`diff`](https://github.com/kamilkisiela/graphql-inspector/tree/master/packages/graphql-cli/diff) - Compares schemas and finds breaking or dangerous changes using [GraphQL Inspector](https://graphql-inspector.com/docs/essentials/diff).
- You can also compare your current schema against a base schema using URL, Git link and local file. You can give this pointer in the command line after `graphql diff` or in GraphQL Config file:
```yml
# ...
extensions:
diff:
baseSchema: git:origin/master:schema.graphql
```
- [`similar`]((https://github.com/kamilkisiela/graphql-inspector/tree/master/packages/graphql-cli/similar)) - Get a list of similar types in order to find duplicates using [GraphQL Inspector](https://graphql-inspector.com/docs/essentials/similar).
- [`validate`]((https://github.com/kamilkisiela/graphql-inspector/tree/master/packages/graphql-cli/validate)) - Validates documents against a schema and looks for deprecated usage using [GraphQL Inspector](https://graphql-inspector.com/docs/essentials/validate).
- [`serve`](https://github.com/Urigo/graphql-cli/tree/master/packages/commands/serve) - Serves a GraphQL server, using an in memory database and a defined GraphQL schema. Please read through [serve documentation](./website/docs/command-serve.md) to learn more about this command.
More plugins are definitely welcome! Please check the existing ones to see how to use GraphQL Config and GraphQL CLI API.
## Contributing
Please read through the [contributing guidelines](./CONTRIBUTING.md)
## Writing your own plugin
GraphQL CLI supports custom plugins, [you can find a tutorial and example here](./docs/CUSTOM_EXTENSION.md)
## Help & Community [](https://the-guild.dev/discord)
Join our [Discord chat](https://the-guild.dev/discord) if you run into issues or have questions. We're excited to welcome you to the community!
================================================
FILE: docs/CUSTOM_EXTENSION.md
================================================
## Writing your own GraphQL-CLI Extension
`graphql-cli` allow you to write your own plugin/extenion, and intergrate external tools and configuration, and run it from a single CLI.
The current implementation of `graphql-cli` is using [Yargs](https://yargs.js.org/) to manage it's CLI commands.
Plugins and extension are treated as NodeJS module by the `graphql-cli`, so it means you can use JavaScript/TypeScript/Any other super-set of JavaScript to write your extension. It means that you plugin will be loaded by it's name under `node_modules` - for example `graphql-cli my-custom-plugin ...`.
`graphql-cli` also supports `graphql-config`, so it can help you easily load your GraphQL schema, operations and configuration from a unified config file.
> If you are wrapping an existing tool that has it's own CLI already, consider to expose a programatic API so it will be easier to consume.
### TL;DR
We have a ready-to-use boilerplate for that purpose, [you can find it here](https://github.com/dotansimha/graphql-cli-plugin-example).
Also, inside this repo, under `packages/commands` you can find a set of plugins implementation you can use as reference.
### Getting Started
Start by creating a simple JavaScript/TypeScript project, according to your preference. Install `@graphql-cli/common` package and use `defineCommand` utility in your entry point (usually `index` file):
```ts
import { defineCommand } from '@graphql-cli/common';
export default defineCommand((api) => {
return {};
});
```
To register your CLI command, give it a name first. Use the `command` property:
```ts
export default defineCommand((api) => {
return {
command: 'my-plugin',
async handler() {
// code here
},
};
});
```
Now, your plugin will be avaiable to use with the following command: `graphql my-plugin`.
You can also add custom validations, flags, default values and much more with Yargs. [You can read the documentation here](https://yargs.js.org/docs/#api-commandcmd-desc-module).
## Testing your plugin locally
To test your plugin locally, install `graphql-cli` in your project as a `devDependency`, and run the following command:
```
graphql ./src/index.js
```
If you registerd sub-commands, you should be able to run those this way:
```
graphql ./src/index.js do-something
```
> The path should point to the entry point of your script, and if you are using TypeScript - point to the compile file.
## Loading GraphQL Schema
To easily load GraphQL schema, you can use `graphql-config`:
```ts
import { defineCommand } from '@graphql-cli/common';
export default defineCommand((api) => {
return {
command: 'my-plugin',
builder(build) {
return build.options({
project: {
type: 'string',
describe: 'Name of your project',
},
});
},
async handler(args) {
// use graphql-config and find configuration
const config = await api.useConfig();
// pick project
const project = args.project ? config.getProject(args.project) : config.getDefault();
// get schema
const schema = await config.getSchema();
},
};
});
```
If you are using `graphql-config` to define your configuration, and you wish to load your extenion config from it, do:
```ts
type MyConfig = { ... };
const extensionConfig = await config.extension<MyConfig>('my-plugin');
```
## Error Handling
If you wish to fail the execution of your plugin and report it back to GraphQL CLI host, simply throw an error:
```ts
import { defineCommand } from '@graphql-cli/common';
export default defineCommand(() => {
return {
command: 'check-if-missing',
handler() {
if (somethingIsMissing) {
throw new Error(`Ooops, something is missing`);
}
},
};
});
```
================================================
FILE: docs/MIGRATION.md
================================================
# Migration from GraphQL CLI 3.x or older
Starting with GraphQL CLI 4.0 and higher, the way projects are set up is significantly restructured.
## Install the new version
To get started, install the new version:
```sh
yarn global add graphql-cli
```
You can also globally install using npm.
> NOTE: If you have previous version of the GraphQL-CLI installed make sure to uninstall it first
```bash
npm uninstall graphql-cli
```
## Update your configuration file
If you are working from an existing project, the GraphQL Config file that is used by GraphQL CLI is now called `.graphqlrc.yml` (by default) instead of `.graphqlconfig`. [Other options exist](https://graphql-config.com/usage) for naming the config files supported by GraphQL CLI, but this guide will assume you're using YAML syntax.
To migrate, you will first need to update your GraphQL Configuration file to match GraphQL Config's updated syntax and structure.
You can [check here](https://graphql-config.com/usage) for more information about the new structure.
###Specifying schema(s):
```yml
schema: ./src/schema/**/*.graphql #You can have URL endpoint, Git URL and local files using globs here.
```
`schemaPath` is replaced by `schema`, which is now more flexible then the previous approach. This field is used by all commands and plugins of GraphQL CLI.
## Comparison of old commands
### `get-schema` is no longer available
In previous versions, you were able to download the schema to the given path in `schemaPath` from the URL given inside `endpoint`. In the new version, `schema` refers to the endpoint of the schema.
If you use Prisma or any other tool that provides your schema under URL endpoint, you must specify it using the following syntax in your configuration YAML:
```yaml
schema: http://localhost:4000/graphql #This is the schema path
```
If you want to download the schema from this URL to your local file system, you will also need to install `codegen` plugin and its `schema-ast` plugin using the following command or its npm equivalent:
```bash
yarn add @graphql-cli/codegen @graphql-codegen/schema-ast --dev
```
After that, you can specify the output path of the local schema file:
```yaml
schema: http://localhost:4000/graphql
extensions:
codegen:
generates:
./schema.graphql:
plugins:
- schema-ast
```
By running `graphql codegen`, the `schema.graphql` file is generated in the root path of your project.
#### For JSON Output
If you want to download the schema as a `json` introspection file, you will need to install `@graphql-codegen/introspection` instead, and add `introspection` instead of `schema-ast`.
```yaml
schema: http://localhost:4000/graphql
extensions:
codegen:
generates:
./schema.json:
plugins:
- introspection
```
### `create` is no longer available: it is replaced by the `init` command.
If you want to create a GraphQL Config file on an existing project or create a project using a template from scratch, you can use `graphql init` command.
This command will ask some questions about your new or existing project to update your dependencies and create a new configuration file for GraphQL CLI.
### `diff` has been changed
If you want to see the differences between your schema and another schema, use the `diff` command as follows:
```yaml
graphql diff git:origin/master:schema.graphql
```
For example, `diff` will show the differences between the version in `schema` field of GraphQL Configuration file and the `schema.graphql` file in the remote master branch.
Alternatively, you can compare `schema` with a URL endpoint:
```yaml
graphql diff http://my-dev-instance.com/graphql
```
### `add-endpoint`, `add-project`, `schema-status`, `ping`, `query`, `prepare`, `lint` and `playground` commands are no longer available.
GraphQL CLI (as well as GraphQL Config) no longer separates `endpoints` and `schemaPath`. The new `schema` field refers to the single endpoint of your GraphQL schema, so it can be a URL endpoint or a local file. If your project uses a remote schema, you can directly define this URL in `schema` path without downloading it or defining it as an extra `endpoint` etc.
Instead of using these legacy commands, you can create a faked server to test your schema using the `yarn serve` command.
### `codegen` now uses GraphQL Code Generator
GraphQL CLI now uses GraphQL Code Generator which has a lot of plugins and templates for various environments, platforms and use cases. You can generate resolver signatures, TypeScript representations of your GraphQL Schema and more. [Check it out](https://graphql-code-generator.com/)
The usage is slightly different from the old one:
```yaml
schema: src/schema/**/*.graphql
extensions:
codegen:
src/generated-types.ts: # Output file name
- typescript # Plugin names to be used
- typescript-resolvers
```
For instance, consider a hypothetical case where you need to generate TypeScript resolvers signatures for your GraphQL project. To do this, you would install the `codegen` plugin and the additional plugins and templates for GraphQL Code Generator. For this case, you would need `typescript` and `typescript-resolvers` plugins:
```bash
yarn add @graphql-cli/codegen @graphql-codegen/typescript @graphql-codegen/typescript-resolvers --dev
```
Now, using a single command, you can run GraphQL Code Generator using GraphQL CLI:
```bash
graphql codegen
```
## Special Notes for Prisma users
Prisma users will need to download a schema from a URL endpoint. For example, here is a *legacy GraphQL Config file* doing this:
`.graphqlconfig`
```yaml
projects:
app:
schemaPath: src/schema.graphql
extensions:
endpoints:
default: http://localhost:4000
database:
schemaPath: src/generated/prisma-client/prisma.graphql
extensions:
prisma: prisma/prisma.yml
```
**To update the configuration for the new GraphQL CLI** you need to rename the file to `.graphqlrc.yml`, and then update the file as follows:
`.graphqlrc.yml`
```yaml
projects:
app:
schema: src/schema.graphql
database:
schema: prisma/prisma.yml
extensions:
codegen:
generates:
./src/generated/prisma-client/prisma.graphql:
plugins:
- schema-ast
```
You can directly point to your `prisma.yml` file instead of the URL endpoint.
Before running the GraphQL CLI command to use this new configuration, make sure you have installed the `@graphql-cli/codegen` and `@graphql-codegen/schema-ast` plugins using:
```sh
yarn add @graphql-cli/codegen @graphql-codegen/schema-ast --dev
```
Now you can run `graphql codegen --project database` for generating your `prisma.graphql` file.
You will also need to update your `prisma.yml` file if you're using `graphql get-schema` with Prisma:
```yaml
...
# Ensures Prisma client is re-generated after a datamodel change.
hooks:
post-deploy:
- graphql codegen --project database # instead of graphql get-schema
- prisma generate
```
================================================
FILE: integration/package.json
================================================
{
"name": "graphql-cli-integration-test",
"version": "4.1.0",
"license": "MIT",
"private": true,
"main": "dist/index.js",
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "ava"
},
"dependencies": {
"log-symbols": "4.1.0",
"tslib": "2.3.1"
},
"devDependencies": {
"ava": "3.15.0",
"execa": "5.1.1"
},
"ava": {
"files": [
"tests/**/*"
],
"extensions": [
"ts"
],
"require": [
"ts-node/register"
]
}
}
================================================
FILE: integration/test-project/.dockerignore
================================================
node_modules
npm-debug.log
================================================
FILE: integration/test-project/.gitignore
================================================
node_modules
dist
types
yarn.lock
yarn-error.log
================================================
FILE: integration/test-project/.graphqlrc.yml
================================================
schema: schema/schema.graphql
extensions:
codegen:
generates:
./src/generated-types.ts:
config:
mappers:
Comment: './generated-db-types#comment'
Note: './generated-db-types#note'
useIndexSignature: true
skipDocumentsValidation: true
plugins:
- add: '/* tslint:disable */'
- typescript
- typescript-resolvers
================================================
FILE: integration/test-project/package.json
================================================
{
"private": true,
"name": "test-project",
"version": "4.1.0",
"dependencies": {
"@graphql-tools/load-files": "6.5.2",
"@types/node": "13.13.45",
"graphql": "15.7.2",
"graphql-config": "3.4.1",
"graphql-tag": "2.12.6"
},
"devDependencies": {
"@graphql-codegen/add": "2.0.2",
"@graphql-codegen/typescript": "1.23.0",
"@graphql-codegen/typescript-operations": "1.18.4",
"@graphql-codegen/typescript-react-apollo": "2.3.1",
"@graphql-codegen/typescript-resolvers": "1.20.0",
"@graphql-cli/codegen": "1.17.27",
"@graphql-cli/coverage": "2.1.0",
"@graphql-cli/diff": "2.1.0",
"@graphql-cli/generate": "4.1.0",
"@graphql-cli/serve": "4.1.0",
"@graphql-cli/similar": "2.1.0",
"@graphql-cli/validate": "2.1.0",
"graphql": "15.7.2",
"graphql-cli": "4.1.0",
"tslint": "6.1.3",
"typescript": "4.4.4"
},
"license": "MIT"
}
================================================
FILE: integration/test-project/renovate.json
================================================
{
"extends": [
"config:base"
],
"automerge": true,
"major": {
"automerge": false
}
}
================================================
FILE: integration/test-project/schema/schema.graphql
================================================
## NOTE: This schema was generated by Graphback and should not be changed manually
"""Exposes a URL that specifies the behaviour of this scalar."""
directive @specifiedBy(
"""The URL that specifies the behaviour of this scalar."""
url: String!
) on SCALAR
""" @model """
type Comment {
id: ID!
text: String
description: String
"""@manyToOne(field: 'comments', key: 'noteId')"""
note: Note
}
input CommentFilter {
id: IDInput
text: StringInput
description: StringInput
noteId: IDInput
and: [CommentFilter!]
or: [CommentFilter!]
not: CommentFilter
}
type CommentResultList {
items: [Comment]!
offset: Int
limit: Int
count: Int
}
input CommentSubscriptionFilter {
id: ID
text: String
description: String
}
input CreateCommentInput {
id: ID
text: String
description: String
noteId: ID
}
input CreateNoteInput {
id: ID
title: String!
description: String
}
input IDInput {
ne: ID
eq: ID
le: ID
lt: ID
ge: ID
gt: ID
in: [ID!]
}
input MutateCommentInput {
id: ID!
text: String
description: String
noteId: ID
}
input MutateNoteInput {
id: ID!
title: String
description: String
}
type Mutation {
createNote(input: CreateNoteInput!): Note
updateNote(input: MutateNoteInput!): Note
deleteNote(input: MutateNoteInput!): Note
createComment(input: CreateCommentInput!): Comment
updateComment(input: MutateCommentInput!): Comment
deleteComment(input: MutateCommentInput!): Comment
}
""" @model """
type Note {
id: ID!
title: String!
description: String
"""@oneToMany(field: 'note', key: 'noteId')"""
comments(filter: CommentFilter): [Comment]!
}
input NoteFilter {
id: IDInput
title: StringInput
description: StringInput
and: [NoteFilter!]
or: [NoteFilter!]
not: NoteFilter
}
type NoteResultList {
items: [Note]!
offset: Int
limit: Int
count: Int
}
input NoteSubscriptionFilter {
id: ID
title: String
description: String
}
input OrderByInput {
field: String!
order: SortDirectionEnum = ASC
}
input PageRequest {
limit: Int
offset: Int
}
type Query {
getNote(id: ID!): Note
findNotes(filter: NoteFilter, page: PageRequest, orderBy: OrderByInput): NoteResultList!
getComment(id: ID!): Comment
findComments(filter: CommentFilter, page: PageRequest, orderBy: OrderByInput): CommentResultList!
}
enum SortDirectionEnum {
DESC
ASC
}
input StringInput {
ne: String
eq: String
le: String
lt: String
ge: String
gt: String
in: [String!]
contains: String
startsWith: String
endsWith: String
}
type Subscription {
newNote(filter: NoteSubscriptionFilter): Note!
updatedNote(filter: NoteSubscriptionFilter): Note!
deletedNote(filter: NoteSubscriptionFilter): Note!
newComment(filter: CommentSubscriptionFilter): Comment!
updatedComment(filter: CommentSubscriptionFilter): Comment!
deletedComment(filter: CommentSubscriptionFilter): Comment!
}
================================================
FILE: integration/test-project/tsconfig.json
================================================
{
"compilerOptions": {
"outDir": "./dist/",
"declarationDir": "./types",
"lib": [
"esnext",
"dom"
],
"resolveJsonModule": true,
"noImplicitAny": false,
"preserveConstEnums": true,
"strict": false,
"strictNullChecks": true,
"esModuleInterop": true,
"target": "esnext",
"module": "commonjs",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"importHelpers": true,
"alwaysStrict": false,
"sourceMap": true,
"declaration": true,
"noImplicitReturns": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitThis": false
},
}
================================================
FILE: integration/test-project/tslint.json
================================================
{
"extends": "tslint:recommended",
"rules": {
"max-line-length": {
"options": [120]
},
"semicolon": false,
"quotemark": false,
"new-parens": true,
"no-arg": true,
"no-bitwise": true,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"object-literal-sort-keys": false,
"trailing-comma": false,
"object-literal-shorthand": false,
"no-console": false,
"interface-name": false
},
"jsRules": {
"max-line-length": {
"options": [120]
}
}
}
================================================
FILE: integration/tests/workflow.ts
================================================
// tslint:disable-next-line: match-default-export-name no-implicit-dependencies
import ava, { ExecutionContext } from 'ava';
import { resolve } from 'path';
import { execSync } from 'child_process';
ava('Test cli workflow', (t: ExecutionContext) => {
const basePath = resolve(`${__dirname}/../test-project`);
process.chdir(basePath);
// Workaround for github actions symlinking issue
const graphQLCmd = 'node ../../packages/cli/dist/index.js';
console.log(`Running commands in ${basePath}`);
try {
let generate = execSync(`${graphQLCmd} generate --backend`, { encoding: 'utf8', cwd: basePath });
const codegen = execSync(`${graphQLCmd} codegen`, { encoding: 'utf8', cwd: basePath });
console.log(`
Generate: ${generate}\n
Codegen: ${codegen}\n
`);
t.true(codegen.indexOf('error') === -1);
t.true(generate.indexOf('failed') === -1);
} catch (error) {
t.fail(`build failed with ${error}`);
}
});
================================================
FILE: integration/tsconfig.json
================================================
{
"compilerOptions": {
"skipLibCheck": true,
"esModuleInterop": true,
"importHelpers": true,
"experimentalDecorators": true,
"module": "commonjs",
"target": "es2018",
"lib": ["es6", "esnext", "es2015", "dom"],
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"sourceMap": true,
"declaration": true,
"outDir": "./dist",
"rootDir": "./tests",
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": false
},
"files": ["src/index.ts"],
"exclude": ["node_modules"]
}
================================================
FILE: lerna.json
================================================
{
"version": "4.1.0",
"npmClient": "yarn",
"useWorkspaces": true
}
================================================
FILE: package.json
================================================
{
"name": "graphql-cli-monorepo",
"version": "4.1.0",
"private": true,
"author": "dotansimha <dotansimha@gmail.com>",
"license": "MIT",
"workspaces": {
"packages": [
"packages/*",
"packages/commands/*",
"website",
"integration"
]
},
"scripts": {
"release": "node scripts/release.js",
"release:next": "node scripts/release.js --tag=next",
"release:canary": "node scripts/release.js --canary",
"test": "lerna run test",
"build": "lerna run build",
"format": "prettier --write \"**/*.{ts,tsx}\"",
"deploy:website": "cd website && yarn deploy"
},
"devDependencies": {
"@graphql-tools/load": "6.2.8",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",
"@types/fullname": "2.1.29",
"@types/inquirer": "7.3.3",
"@types/js-yaml": "3.12.7",
"@types/node": "14.17.33",
"@types/rimraf": "3.0.2",
"@types/tmp": "0.2.2",
"graphql": "15.7.2",
"husky": "4.3.8",
"lerna": "3.22.1",
"lint-staged": "10.5.4",
"prettier": "2.4.1",
"rimraf": "3.0.2",
"ts-node": "9.1.1",
"typescript": "4.4.4"
},
"publishConfig": {
"access": "public"
},
"lint-staged": {
"*.{ts,tsx}": [
"tslint --fix",
"prettier --write",
"git add"
]
},
"prettier": {
"printWidth": 120,
"singleQuote": true
},
"resolutions": {
"graphql": "15.7.2"
},
"dependencies": {
"@types/yargs": "15.0.14"
}
}
================================================
FILE: packages/cli/.gitignore
================================================
node_modules
npm-debug.log
dist
temp
yarn-error.log
tests/coverage/
================================================
FILE: packages/cli/.npmignore
================================================
src/
================================================
FILE: packages/cli/CONTRIBUTING.md
================================================
# Contributing guide
Please see the project root at https://github.com/Urigo/graphql-cli/CONTRIBUTING.md for more information about contributing to GraphQL CLI and the greater GraphQL ecosystem.
================================================
FILE: packages/cli/LICENSE
================================================
MIT License
Copyright (c) 2019 Dotan Simha
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: packages/cli/README.md
================================================
# GraphQL CLI

Repo and documentation at: https://github.com/Urigo/graphql-cli
================================================
FILE: packages/cli/package.json
================================================
{
"name": "graphql-cli",
"description": "Command line tool for common GraphQL development workflows",
"keywords": [
"graphql",
"graphql-cli",
"cli"
],
"repository": {
"type": "git",
"url": "https://github.com/Urigo/graphql-cli"
},
"author": {
"name": "Uri Goldshtein",
"email": "uri.goldshtein@gmail.com",
"url": "https://github.com/Urigo"
},
"version": "5.0.0",
"license": "MIT",
"main": "dist/index.js",
"publishConfig": {
"access": "public"
},
"bin": {
"graphql": "dist/bin.js"
},
"scripts": {
"start": "ts-node src/bin.ts",
"build": "tsc"
},
"dependencies": {
"@graphql-cli/common": "^5.0.0",
"@graphql-cli/init": "^5.0.0",
"globby": "^11.0.2",
"graphql-config": "^3.2.0",
"open": "^7.4.2",
"yargs": "^16.2.0"
}
}
================================================
FILE: packages/cli/src/bin.ts
================================================
#!/usr/bin/env node
import { cli } from './index';
cli();
================================================
FILE: packages/cli/src/discover.ts
================================================
import { defineCommand } from '@graphql-cli/common';
import open from 'open';
export default defineCommand(() => {
return {
command: 'discover',
describe: 'Opens a list of all GraphQL CLI Plugins',
handler() {
return open('https://www.npmjs.com/search?q=keywords:graphql-cli-plugin');
},
};
});
================================================
FILE: packages/cli/src/index.ts
================================================
import yargs from 'yargs';
import globby from 'globby';
import { join } from 'path';
import { CommandFactory, useConfig, useLoaders } from '@graphql-cli/common';
import discover from './discover';
export async function cli(): Promise<void> {
const program = yargs
.scriptName('graphql')
.detectLocale(false)
.epilog('Visit https://github.com/Urigo/graphql-cli for more information')
.version();
const commandPackageNames = await discoverCommands();
const commandFactories = await Promise.all(commandPackageNames.map(loadCommand));
[discover, ...commandFactories].forEach((cmd) => {
program.command(
cmd({
useConfig,
useLoaders,
})
);
});
program.demandCommand().recommendCommands().help().showHelpOnFail(false).argv;
}
async function discoverCommands() {
const commandNames: string[] = [];
const paths = require.resolve.paths('graphql-cli');
await Promise.all(paths.map(findInDirectory));
async function findInDirectory(directory: string) {
const results = await globby('*', {
cwd: join(directory, '@graphql-cli'),
onlyDirectories: true,
deep: 1,
ignore: ['common', 'loaders'],
});
if (results.length) {
commandNames.push(...results);
}
}
// unique names
return commandNames.filter((val, i, list) => list.indexOf(val) === i);
}
function loadCommand(name: string): CommandFactory {
const mod = require(`@graphql-cli/${name}`);
return mod.default || mod;
}
================================================
FILE: packages/cli/tsconfig.json
================================================
{
"compilerOptions": {
"skipLibCheck": true,
"esModuleInterop": true,
"importHelpers": true,
"experimentalDecorators": true,
"module": "commonjs",
"target": "es2018",
"lib": ["es6", "esnext", "es2015", "dom"],
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"sourceMap": true,
"declaration": true,
"outDir": "./dist",
"rootDir": "./src",
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": false
},
"include": ["src"],
"exclude": ["node_modules"]
}
================================================
FILE: packages/commands/generate/.gitignore
================================================
node_modules
npm-debug.log
dist
temp
yarn-error.log
tests/coverage/
================================================
FILE: packages/commands/generate/README.md
================================================
## GraphQL CLI Generate command
This package is part of the GraphQL CLI ecosystem and it is not designed to be consumed separately.
Go to: https://github.com/Urigo/graphql-cli for more information
================================================
FILE: packages/commands/generate/package.json
================================================
{
"name": "@graphql-cli/generate",
"description": "Generate schema and client-side documents for your GraphQL project by using Graphback.",
"version": "5.0.0",
"license": "MIT",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "https://github.com/Urigo/graphql-cli",
"directory": "packages/commands/generate"
},
"publishConfig": {
"access": "public"
},
"keywords": [
"graphql-cli",
"graphql-cli-plugin"
],
"scripts": {
"build": "tsc"
},
"peerDependencies": {
"graphql": "15.7.2"
},
"dependencies": {
"@graphql-cli/common": "^5.0.0",
"graphback-cli": "1.1.2",
"tslib": "2.3.1"
}
}
================================================
FILE: packages/commands/generate/src/index.ts
================================================
import { defineCommand } from '@graphql-cli/common';
import { command, builder as builderConfig, handler } from 'graphback-cli';
export default defineCommand(() => {
return {
command,
builder(builder: any) {
return builder.options(builderConfig);
},
handler,
};
});
================================================
FILE: packages/commands/generate/tsconfig.json
================================================
{
"compilerOptions": {
"skipLibCheck": true,
"esModuleInterop": true,
"importHelpers": true,
"experimentalDecorators": true,
"module": "commonjs",
"target": "es2018",
"lib": ["es6", "esnext", "es2015", "dom"],
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"sourceMap": true,
"declaration": true,
"outDir": "./dist",
"rootDir": "./src",
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": false
},
"files": ["src/index.ts"],
"exclude": ["node_modules"]
}
================================================
FILE: packages/commands/init/.gitignore
================================================
node_modules
npm-debug.log
dist
temp
yarn-error.log
tests/coverage/
================================================
FILE: packages/commands/init/.npmignore
================================================
src/
================================================
FILE: packages/commands/init/README.md
================================================
## GraphQL CLI Init command
This package is part of the GraphQL CLI ecosystem and it is not designed to be consumed separately.
Go to: https://github.com/Urigo/graphql-cli for more information
================================================
FILE: packages/commands/init/package.json
================================================
{
"name": "@graphql-cli/init",
"description": "Creates a GraphQL project using a template or GraphQL Config file for your existing project.",
"version": "5.0.0",
"license": "MIT",
"main": "dist/index.js",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/Urigo/graphql-cli",
"directory": "packages/commands/init"
},
"keywords": [
"graphql-cli",
"graphql-cli-plugin"
],
"scripts": {
"build": "tsc"
},
"dependencies": {
"@graphql-cli/common": "^5.0.0",
"chalk": "^4.1.0",
"cosmiconfig": "^7.0.0",
"create-graphback": "^1.1.2",
"cross-fetch": "^3.0.6",
"fs-extra": "^9.1.0",
"fullname": "^4.0.1",
"graphql": "^15.5.0",
"inquirer": "7.3.3",
"js-yaml": "^3.14.1",
"latest-version": "^5.1.0",
"openapi-to-graphql": "^2.2.6",
"ora": "^5.3.0",
"rimraf": "^3.0.2",
"simple-git": "^2.36.1",
"string-env-interpolation": "^1.0.1",
"tmp": "^0.2.1",
"tslib": "~2.3.0"
}
}
================================================
FILE: packages/commands/init/src/common.ts
================================================
import { join } from 'path';
import { ensureFile, writeFileSync } from 'fs-extra';
import { prompt } from 'inquirer';
import fullName from 'fullname';
import latestVersion from 'latest-version';
type StandardEnum<T> = {
[id: string]: T | string;
[nu: number]: string;
};
export async function askForEnum<T, Enum extends StandardEnum<T>>(options: {
enum: Enum;
message: string;
defaultValue?: T;
ignoreList?: (T | string)[];
}): Promise<T> {
let choices: (T | string)[];
const enumValues = Object.values(options.enum);
if (options.ignoreList) {
choices = enumValues.filter((enumValue) => !options.ignoreList.includes(enumValue));
} else {
choices = enumValues;
}
const { answer } = await prompt<{ answer: T }>([
{
type: 'list',
name: 'answer',
message: options.message,
choices,
default: options.defaultValue,
},
]);
return answer;
}
export interface Context {
name: string;
path: string;
type?: ProjectType;
graphqlConfig: any;
}
export enum InitializationType {
FromScratch = 'I want to create a new project from a GraphQL CLI Project Template.',
ExistingOpenAPI = 'I have an existing project using OpenAPI/Swagger Schema Definition.',
ExistingGraphQL = 'I have an existing project using GraphQL and want to add GraphQL CLI (run from project root).',
}
export enum ProjectType {
FullStack = 'Full Stack',
FrontendOnly = 'Frontend only',
BackendOnly = 'Backend only',
}
export enum FrontendType {
TSReactApollo = 'TypeScript React Apollo',
ApolloAngular = 'Apollo Angular',
StencilApollo = 'Stencil Apollo',
TSUrql = 'TypeScript Urql',
GraphQLRequest = 'GraphQL Request',
ApolloAndroid = 'Apollo Android',
Other = 'Other',
}
export enum BackendType {
TS = 'TypeScript',
Java = 'Java',
Kotlin = 'Kotlin',
Other = 'Other',
}
export type PackageManifest = ReturnType<typeof managePackageManifest>;
export function managePackageManifest() {
const packages = new Set<string>();
const scripts = new Map<string, string>();
return {
addDependency(name: string) {
packages.add(name);
},
addScript(name: string, script: string) {
scripts.set(name, script);
},
async writePackage({
path,
name,
initializationType,
}: {
path: string;
name: string;
initializationType: InitializationType;
}) {
let packageJson: any = {};
const packageJsonPath = join(path, 'package.json');
// Try to load existing package.json
try {
const importedPackageJson = require(packageJsonPath);
packageJson = importedPackageJson || {};
} catch (err) {}
if (initializationType === InitializationType.FromScratch) {
packageJson.private = true;
packageJson.name = name;
const author = await fullName();
if (author) {
packageJson.author = {
name: author,
};
}
}
for (const [scriptName, scriptValue] of scripts) {
if (!packageJson.scripts) {
packageJson.scripts = {};
}
if (!packageJson.scripts[scriptName]) {
packageJson.scripts[scriptName] = scriptValue;
}
}
// Add dev dependencies
packageJson.devDependencies = packageJson.devDependencies || {};
for await (const npmDependency of packages) {
if (!(npmDependency in packageJson.devDependencies)) {
packageJson.devDependencies[npmDependency] = await latestVersion(npmDependency);
}
}
await ensureFile(packageJsonPath);
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
},
};
}
================================================
FILE: packages/commands/init/src/features/codegen.ts
================================================
import { prompt } from 'inquirer';
import { Context, PackageManifest, ProjectType, FrontendType, BackendType, askForEnum } from '../common';
export async function askForCodegen({ context, project }: { context: Context; project: PackageManifest }) {
if (!context.graphqlConfig.extensions.codegen) {
const { isCodegenAsked } = await prompt([
{
type: 'confirm',
name: 'isCodegenAsked',
message: 'Do you want to use GraphQL Code Generator?',
default: true,
},
]);
if (isCodegenAsked) {
project.addDependency('@graphql-cli/codegen');
project.addScript('graphql:codegen', 'graphql codegen');
context.graphqlConfig.extensions.codegen = {
generates: {},
};
let codegenPlugins = new Set<string>();
if (context.type === ProjectType.FullStack || context.type === ProjectType.BackendOnly) {
const backendType = await askForEnum({
enum: BackendType,
message: 'What type of backend do you use?',
defaultValue: BackendType.TS,
});
switch (backendType) {
case BackendType.TS:
codegenPlugins.add('typescript');
codegenPlugins.add('typescript-resolvers');
break;
case BackendType.Java:
codegenPlugins.add('java');
codegenPlugins.add('java-resolvers');
break;
case BackendType.Kotlin:
codegenPlugins.add('java');
codegenPlugins.add('java-kotlin');
break;
}
const { backendGeneratedFile } = await prompt([
{
type: 'input',
name: 'backendGeneratedFile',
message: 'Where do you want to have generated backend code?',
default: './generated-backend.ts',
},
]);
context.graphqlConfig.extensions.codegen.generates[backendGeneratedFile] = {
plugins: [...codegenPlugins],
};
}
if (context.type === ProjectType.FullStack || context.type === ProjectType.FrontendOnly) {
const frontendType = await askForEnum({
enum: FrontendType,
message: 'What type of frontend do you use?',
defaultValue: FrontendType.TSReactApollo,
});
switch (frontendType) {
case FrontendType.TSReactApollo:
codegenPlugins.add('typescript');
codegenPlugins.add('typescript-react-apollo');
break;
case FrontendType.ApolloAngular:
codegenPlugins.add('typescript');
codegenPlugins.add('typescript-apollo-angular');
break;
case FrontendType.StencilApollo:
codegenPlugins.add('typescript');
codegenPlugins.add('typescript-stencil-apollo');
break;
case FrontendType.TSUrql:
codegenPlugins.add('typescript');
codegenPlugins.add('typescript-urql');
break;
case FrontendType.GraphQLRequest:
codegenPlugins.add('typescript');
codegenPlugins.add('typescript-graphql-request');
break;
case FrontendType.ApolloAndroid:
codegenPlugins.add('java-apollo-android');
break;
}
const { frontendGeneratedFile } = await prompt([
{
type: 'input',
name: 'frontendGeneratedFile',
message: 'Where do you want to have generated frontend code?',
default: './generated-frontend.ts',
},
]);
context.graphqlConfig.extensions.codegen.generates[frontendGeneratedFile] = {
plugins: [...codegenPlugins],
};
}
for (const codegenPlugin of codegenPlugins) {
project.addDependency('@graphql-codegen/' + codegenPlugin);
}
}
}
}
================================================
FILE: packages/commands/init/src/features/inspector.ts
================================================
import { prompt } from 'inquirer';
import { Context, PackageManifest, ProjectType } from '../common';
export async function askForInspector({ context, project }: { context: Context; project: PackageManifest }) {
if (context.type === ProjectType.FullStack || context.type === ProjectType.FrontendOnly) {
const { isFrontendInspectorAsked } = await prompt([
{
type: 'confirm',
name: 'isFrontendInspectorAsked',
message: 'Do you want to have GraphQL Inspector tools for your frontend?',
default: true,
},
]);
if (isFrontendInspectorAsked) {
project.addDependency('@graphql-cli/coverage');
project.addDependency('@graphql-cli/validate');
project.addScript('graphql:coverage', 'graphql coverage');
project.addScript('graphql:validate', 'graphql validate');
}
}
if (context.type === ProjectType.FullStack || context.type === ProjectType.BackendOnly) {
const { isBackendInspectorAsked } = await prompt([
{
type: 'confirm',
name: 'isBackendInspectorAsked',
message: 'Do you want to have GraphQL Inspector tools for your backend?',
default: true,
},
]);
if (isBackendInspectorAsked) {
project.addDependency('@graphql-cli/diff');
project.addDependency('@graphql-cli/similar');
project.addScript('graphql:diff', 'graphql diff');
project.addScript('graphql:similar', 'graphql similar');
if (!context.graphqlConfig.extensions.diff) {
context.graphqlConfig.extensions.diff = {
baseSchema: 'your-base-schema-here',
};
}
}
}
}
================================================
FILE: packages/commands/init/src/index.ts
================================================
import { defineCommand } from '@graphql-cli/common';
import { prompt } from 'inquirer';
import { join } from 'path';
import chalk from 'chalk';
import { ensureFile, writeFileSync, readFileSync, existsSync } from 'fs-extra';
import { safeLoad as YAMLParse, safeDump as YAMLStringify } from 'js-yaml';
import { Context, InitializationType, ProjectType, askForEnum, managePackageManifest } from './common';
import { askForInspector } from './features/inspector';
import { askForCodegen } from './features/codegen';
import { fromExisting } from './sources/from-existing';
import { fromScratch } from './sources/from-scratch';
import { fromExistingOpenAPI } from './sources/from-open-api';
export default defineCommand<
{},
{
projectName?: string;
templateName?: string;
templateUrl?: string;
}
>(() => {
return {
command: 'init',
builder(yargs) {
return yargs.options({
projectName: {
describe: 'Project name',
type: 'string',
},
templateName: {
describe: 'Name of the predefined template',
type: 'string',
},
templateUrl: {
describe: 'GitHub URL of the template. For example (http://github.com/example/graphql-cli-example-template)',
type: 'string',
},
});
},
async handler(args) {
let { projectName, templateName, templateUrl } = args;
const initializationType = await askForInitializationType();
const context: Context = {
name: projectName,
path: process.cwd(),
graphqlConfig: {
extensions: {},
},
};
const project = managePackageManifest();
project.addDependency('graphql-cli');
if (initializationType === InitializationType.ExistingGraphQL) {
await fromExisting({
context,
project,
});
} else if (initializationType === InitializationType.FromScratch) {
await fromScratch({
context,
templateName,
templateUrl,
});
}
if (initializationType !== InitializationType.FromScratch) {
context.type = await askForProject();
}
loadGraphQLConfig(context);
if (initializationType === InitializationType.ExistingOpenAPI) {
await fromExistingOpenAPI(context);
}
await askForSchema(context);
await askForDocuments(context);
await askForCodegen({ context, project });
await askForInspector({ context, project });
await Promise.all([
writeGraphQLConfig(context),
project.writePackage({
path: context.path,
name: projectName,
initializationType,
})]);
const successMessages = [
`🚀 GraphQL CLI project successfully initialized:`,
context.name,
'Next Steps:',
`- Change directory to the project folder - ${chalk.cyan(`cd ${context.path}`)}`,
`- Run ${chalk.cyan(`yarn install`)} to install dependencies`,
];
if (initializationType !== InitializationType.ExistingGraphQL) {
successMessages.push(
`- ${chalk.cyan(`(Optional)`)} Initialize your git repo. ${chalk.cyan(`git init`)}.`,
`- Follow the instructions in README.md to continue...`
);
}
console.info(successMessages.join('\n'));
process.exit(0);
},
};
});
function askForProject() {
return askForEnum({
enum: ProjectType,
message: 'What is the type of the project?',
defaultValue: ProjectType.FullStack,
});
}
function askForInitializationType() {
return askForEnum({
enum: InitializationType,
message: 'Select the best option for you',
defaultValue: InitializationType.FromScratch,
ignoreList: [],
});
}
function loadGraphQLConfig(context: Context) {
const graphqlConfigPath = join(context.path, '.graphqlrc.yml');
try {
if (existsSync(graphqlConfigPath)) {
context.graphqlConfig = YAMLParse(readFileSync(graphqlConfigPath, 'utf8'));
}
} catch (e) {
console.warn(`Existing GraphQL Config file looks broken! Skipping...`);
}
}
async function askForSchema(context: Context) {
if (!context.graphqlConfig.schema) {
const { schema } = await prompt([
{
type: 'input',
name: 'schema',
message: 'Where is your schema?',
default: './schema.graphql',
},
]);
context.graphqlConfig.schema = schema.endsWith('.ts')
? {
[schema]: {
require: 'ts-node/register',
},
}
: schema;
}
}
async function askForDocuments(context: Context) {
if (
!context.graphqlConfig.documents &&
(context.type === ProjectType.FullStack || context.type === ProjectType.FrontendOnly)
) {
const { documents } = await prompt([
{
type: 'input',
name: 'documents',
message: 'Where are your operation documents?',
},
]);
context.graphqlConfig.documents = documents;
}
}
async function writeGraphQLConfig(context: Context) {
const configPath = join(context.path, '.graphqlrc.yml');
await ensureFile(configPath);
const keys = ['schema', 'documents', 'extensions'];
function sortKeys(a: string, b: string) {
const ai = keys.indexOf(a);
const bi = keys.indexOf(b);
if (ai === -1 && bi === -1) {
return a.localeCompare(b);
}
return ai <= bi ? -1 : 1;
}
writeFileSync(
configPath,
YAMLStringify(context.graphqlConfig, {
sortKeys,
})
);
}
================================================
FILE: packages/commands/init/src/search-codegen-config.ts
================================================
import { cosmiconfig, defaultLoaders } from 'cosmiconfig';
import { env } from 'string-env-interpolation';
function generateSearchPlaces(moduleName: string) {
const extensions = ['json', 'yaml', 'yml', 'js', 'config.js'];
// gives codegen.json...
const regular = extensions.map((ext) => `${moduleName}.${ext}`);
// gives .codegenrc.json... but no .codegenrc.config.js
const dot = extensions.filter((ext) => ext !== 'config.js').map((ext) => `.${moduleName}rc.${ext}`);
return regular.concat(dot);
}
function customLoader(ext: 'json' | 'yaml' | 'js') {
function loader(filepath: string, content: string) {
if (typeof process !== 'undefined' && 'env' in process) {
content = env(content);
}
if (ext === 'json') {
return defaultLoaders['.json'](filepath, content);
}
if (ext === 'yaml') {
return defaultLoaders['.yaml'](filepath, content);
}
if (ext === 'js') {
return defaultLoaders['.js'](filepath, content);
}
}
return loader;
}
export async function searchCodegenConfig(cwd: string) {
const moduleName = 'codegen';
const cosmi = cosmiconfig(moduleName, {
searchPlaces: generateSearchPlaces(moduleName),
loaders: {
'.json': customLoader('json'),
'.yaml': customLoader('yaml'),
'.yml': customLoader('yaml'),
'.js': customLoader('js'),
noExt: customLoader('yaml'),
},
});
return cosmi.search(cwd);
}
================================================
FILE: packages/commands/init/src/sources/from-existing.ts
================================================
import rimraf from 'rimraf';
import { join } from 'path';
import { existsSync } from 'fs-extra';
import { prompt } from 'inquirer';
import { Context, PackageManifest } from '../common';
import { searchCodegenConfig } from '../search-codegen-config';
export async function fromExisting({ context, project }: { context: Context; project: PackageManifest }) {
const manifestPath = join(context.path, 'package.json');
if (existsSync(manifestPath)) {
const { name: projectName } = require(manifestPath);
context.name = projectName;
}
const result = await searchCodegenConfig(context.path);
if (result && !result.isEmpty) {
const codegenFilePath = result.filepath;
const { willBeMerged } = await prompt([
{
type: 'confirm',
name: 'willBeMerged',
message: `GraphQL Code Generator configuration has been detected in ${codegenFilePath}.\n Do you want to use the same configuration with GraphQL CLI?`,
default: true,
},
]);
if (willBeMerged) {
project.addDependency('@graphql-cli/codegen');
const codegenConfig = result.config;
context.graphqlConfig.extensions.codegen = {
generates: {},
};
for (const key in codegenConfig) {
if (key === 'schema') {
context.graphqlConfig.schema = codegenConfig.schema;
} else if (key === 'documents') {
context.graphqlConfig.documents = codegenConfig.documents;
} else {
context.graphqlConfig.extensions.codegen[key] = codegenConfig[key];
}
}
rimraf.sync(result.filepath);
}
}
}
================================================
FILE: packages/commands/init/src/sources/from-open-api.ts
================================================
import ora from 'ora';
import { safeLoad as YAMLParse } from 'js-yaml';
import { readFileSync, writeFileSync, ensureFile } from 'fs-extra';
import { prompt } from 'inquirer';
import { Context } from '../common';
export async function fromExistingOpenAPI(context: Context) {
const { openApiPath } = await prompt<{ openApiPath: string }>([
{
type: 'input',
name: 'openApiPath',
message: 'Enter your OpenAPI schema path',
default: './swagger.json',
},
]);
const processingOpenAPISpinner = ora(`Processing OpenAPI definition: ${openApiPath}`).start();
const schemaText: string = readFileSync(`${openApiPath}`, 'utf8');
const parsedObject =
openApiPath.endsWith('yaml') || openApiPath.endsWith('yml') ? YAMLParse(schemaText) : JSON.parse(schemaText);
const datamodelPath = `${context.graphqlConfig.extensions.graphback.model}/datamodel.graphql`;
try {
const { createGraphQLSchema } = await import('openapi-to-graphql');
const { schema } = await createGraphQLSchema(parsedObject, {
strict: true,
fillEmptyResponses: true,
equivalentToMessages: false,
});
const { printSchema } = await import('graphql');
const schemaString = printSchema(schema);
await ensureFile(datamodelPath);
writeFileSync(datamodelPath, schemaString);
processingOpenAPISpinner.succeed();
} catch (err) {
processingOpenAPISpinner.fail(`Failed to process OpenAPI definition: ${datamodelPath}. Error: ${err}`);
}
}
================================================
FILE: packages/commands/init/src/sources/from-scratch.ts
================================================
import { join } from 'path';
import { prompt } from 'inquirer';
import { Context } from '../common';
import { handler } from 'create-graphback';
export async function fromScratch({
context,
templateName,
templateUrl,
}: {
context: Context;
templateName: string;
templateUrl: string;
}) {
if (!context.name) {
const { projectName: enteredName } = await prompt([
{
type: 'input',
name: 'projectName',
message: 'What is the name of the project?',
default: 'my-graphql-project',
},
]);
context.name = enteredName;
context.path = join(process.cwd(), context.name);
}
await handler({ name: context.name, templateName, templateUrl });
}
================================================
FILE: packages/commands/init/tsconfig.json
================================================
{
"compilerOptions": {
"skipLibCheck": true,
"esModuleInterop": true,
"importHelpers": true,
"experimentalDecorators": true,
"module": "commonjs",
"target": "es2018",
"lib": ["es6", "esnext", "es2015", "dom"],
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"sourceMap": true,
"declaration": true,
"outDir": "./dist",
"rootDir": "./src",
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": false,
"resolveJsonModule": true
},
"files": ["src/index.ts"],
"exclude": ["node_modules"]
}
================================================
FILE: packages/commands/serve/.gitignore
================================================
node_modules
npm-debug.log
dist
temp
yarn-error.log
tests/coverage/
================================================
FILE: packages/commands/serve/.npmignore
================================================
src/
================================================
FILE: packages/commands/serve/README.md
================================================
## GraphQL CLI Serve command
This package is part of the GraphQL CLI ecosystem and it is not designed to be consumed separately.
Go to: https://github.com/Urigo/graphql-cli for more information
================================================
FILE: packages/commands/serve/package.json
================================================
{
"name": "@graphql-cli/serve",
"description": "Serves a GraphQL server using an in memory MongoDB",
"version": "5.0.0",
"license": "MIT",
"main": "dist/index.js",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/Urigo/graphql-cli",
"directory": "packages/commands/serve"
},
"keywords": [
"graphql-cli",
"graphql-cli-plugin"
],
"scripts": {
"build": "tsc"
},
"peerDependencies": {
"graphql": "15.7.2"
},
"dependencies": {
"@graphql-cli/common": "^5.0.0",
"graphql-serve": "^1.1.2",
"tslib": "~2.3.0"
}
}
================================================
FILE: packages/commands/serve/src/index.ts
================================================
import { defineCommand } from '@graphql-cli/common';
import { serve } from 'graphql-serve';
export default defineCommand(() => {
return {
builder: (builder: any) => {
serve.builder(builder);
return builder;
},
command: serve.command,
handler: serve.handler,
};
});
================================================
FILE: packages/commands/serve/tsconfig.json
================================================
{
"compilerOptions": {
"skipLibCheck": true,
"esModuleInterop": true,
"importHelpers": true,
"experimentalDecorators": true,
"module": "commonjs",
"target": "es2018",
"lib": ["es6", "esnext", "es2015", "dom"],
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"sourceMap": true,
"declaration": true,
"outDir": "./dist",
"rootDir": "./src",
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": false
},
"files": ["src/index.ts"],
"exclude": ["node_modules"]
}
================================================
FILE: packages/common/.gitignore
================================================
node_modules
npm-debug.log
dist
temp
yarn-error.log
tests/coverage/
================================================
FILE: packages/common/.npmignore
================================================
src/
================================================
FILE: packages/common/package.json
================================================
{
"name": "@graphql-cli/common",
"version": "5.0.0",
"license": "MIT",
"main": "dist/index.js",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc"
},
"peerDependencies": {
"graphql-config": "3.4.1",
"yargs": "16.2.0"
},
"dependencies": {
"@graphql-tools/load": "^7.1.6",
"tslib": "^2.3.1"
}
}
================================================
FILE: packages/common/src/command.ts
================================================
import { CommandModule } from 'yargs';
import { loadConfig, GraphQLConfig } from 'graphql-config';
import { loadDocuments, loadSchema } from '@graphql-tools/load';
import { Loader } from '@graphql-tools/utils';
import { LoadConfigOptions } from './types';
export type CommandFactory<T = {}, U = {}> = (api: {
useConfig: (options?: LoadConfigOptions) => Promise<GraphQLConfig>;
useLoaders: typeof useLoaders;
}) => CommandModule<T, U>;
export function defineCommand<T = {}, U = {}>(factory: CommandFactory<T, U>) {
return factory;
}
export function useConfig(options: LoadConfigOptions = {}) {
return loadConfig({
rootDir: process.cwd(),
throwOnEmpty: true,
throwOnMissing: true,
...options,
});
}
type PointerOf<T extends (...args: any) => any> = Parameters<T>[0];
type OptionsOf<T extends (...args: any) => any> = Omit<Parameters<T>[1], 'loaders'>;
export function useLoaders({ loaders }: { loaders: Loader[] }) {
return {
loadDocuments(pointer: PointerOf<typeof loadDocuments>, options: OptionsOf<typeof loadDocuments>) {
return loadDocuments(pointer, { loaders, ...options });
},
loadSchema(pointer: PointerOf<typeof loadSchema>, options: OptionsOf<typeof loadSchema>) {
return loadSchema(pointer, { loaders, ...options });
},
};
}
================================================
FILE: packages/common/src/index.ts
================================================
export * from './types';
export * from './command';
================================================
FILE: packages/common/src/types.ts
================================================
import { loadConfig } from 'graphql-config';
export type LoadConfigOptions = Partial<Parameters<typeof loadConfig>[0]>;
================================================
FILE: packages/common/tsconfig.json
================================================
{
"compilerOptions": {
"skipLibCheck": true,
"importHelpers": true,
"experimentalDecorators": true,
"module": "commonjs",
"target": "es2018",
"lib": ["es6", "esnext", "es2015", "dom"],
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"sourceMap": true,
"declaration": true,
"outDir": "./dist",
"rootDir": "./src",
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": false
},
"files": ["src/index.ts"],
"exclude": ["node_modules"]
}
================================================
FILE: packages/loaders/.gitignore
================================================
node_modules
npm-debug.log
dist
temp
yarn-error.log
tests/coverage/
================================================
FILE: packages/loaders/.npmignore
================================================
src/
================================================
FILE: packages/loaders/package.json
================================================
{
"name": "@graphql-cli/loaders",
"description": "Internal usage",
"version": "5.0.0",
"license": "MIT",
"main": "dist/index.js",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc"
},
"peerDependencies": {
"graphql": "15.7.2"
},
"dependencies": {
"@graphql-tools/apollo-engine-loader": "^7.0.4",
"@graphql-tools/code-file-loader": "^7.0.4",
"@graphql-tools/git-loader": "^7.0.4",
"@graphql-tools/github-loader": "^7.0.4",
"@graphql-tools/prisma-loader": "^7.0.5",
"@graphql-tools/url-loader": "^7.0.10",
"@graphql-tools/utils": "^8.1.1"
}
}
================================================
FILE: packages/loaders/src/index.ts
================================================
import { Loader } from '@graphql-tools/utils';
import { ApolloEngineLoader } from '@graphql-tools/apollo-engine-loader';
import { CodeFileLoader } from '@graphql-tools/code-file-loader';
import { GitLoader } from '@graphql-tools/git-loader';
import { GithubLoader } from '@graphql-tools/github-loader';
import { PrismaLoader } from '@graphql-tools/prisma-loader';
import { UrlLoader } from '@graphql-tools/url-loader';
export const loaders: Loader[] = [
new ApolloEngineLoader(),
new CodeFileLoader(),
new GitLoader(),
new GithubLoader(),
new PrismaLoader(),
new UrlLoader(),
];
================================================
FILE: packages/loaders/tsconfig.json
================================================
{
"compilerOptions": {
"skipLibCheck": true,
"importHelpers": true,
"experimentalDecorators": true,
"module": "commonjs",
"target": "es2018",
"lib": ["es6", "esnext", "es2015", "dom"],
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"sourceMap": true,
"declaration": true,
"outDir": "./dist",
"rootDir": "./src",
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": false
},
"files": ["src/index.ts"],
"exclude": ["node_modules"]
}
================================================
FILE: renovate.json
================================================
{
"extends": [
"config:base"
],
"automerge": true,
"major": {
"automerge": false
},
"rangeStrategy": "replace"
}
================================================
FILE: scripts/introspect-config.js
================================================
const { loadSchema } = require('@graphql-tools/load');
const { GraphQLFileLoader } = require('@graphql-tools/graphql-file-loader');
const { printSchemaWithDirectives } = require('@graphql-tools/utils');
const { writeFileSync } = require('fs');
const { resolve } = require('path');
const { DIRECTIVES } = require('graphql-to-config-schema');
async function main() {
const schema = await loadSchema([DIRECTIVES, './**/yaml-config.graphql'], {
loaders: [new GraphQLFileLoader()],
assumeValidSDL: true,
});
writeFileSync(resolve(__dirname, '../schema.graphql'), printSchemaWithDirectives(schema));
}
main().catch(console.error);
================================================
FILE: scripts/release.js
================================================
const { argv } = require('yargs');
const { sync: glob } = require('globby');
const { writeFile } = require('fs-extra');
const { resolve, dirname, join } = require('path');
const semver = require('semver');
const cp = require('child_process');
const rootPackageJson = require('../package.json');
async function release() {
let version = process.env.RELEASE_VERSION || rootPackageJson.version;
if (version.startsWith('v')) {
version = version.replace('v', '');
}
let tag = argv.tag || 'latest';
if (argv.canary) {
const gitHash = cp.spawnSync('git', ['rev-parse', '--short', 'HEAD']).stdout.toString().trim();
version = semver.inc(version, 'prerelease', true, 'alpha-' + gitHash);
tag = 'canary';
}
const workspaceGlobs = (rootPackageJson.workspaces.packages || rootPackageJson.workspaces).map(
(workspace) => workspace + '/package.json'
);
const packageJsonPaths = glob(workspaceGlobs).map((packageJsonPath) => resolve(process.cwd(), packageJsonPath));
const packageNames = packageJsonPaths.map((packageJsonPath) => require(packageJsonPath).name);
rootPackageJson.version = version;
await writeFile(resolve(__dirname, '../package.json'), JSON.stringify(rootPackageJson, null, 2));
await Promise.all(
packageJsonPaths.map(async (packageJsonPath) => {
const packageJson = require(packageJsonPath);
packageJson.version = version;
for (const dependency in packageJson.dependencies) {
if (packageNames.includes(dependency)) {
packageJson.dependencies[dependency] = version;
}
}
for (const dependency in packageJson.devDependencies) {
if (packageNames.includes(dependency)) {
packageJson.devDependencies[dependency] = version;
}
}
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
if (!packageJson.private) {
const distDirName = (packageJson.publishConfig && packageJson.publishConfig.directory) || '';
const distPath = join(dirname(packageJsonPath), distDirName);
//Fix package.json in dist directory
const distPackageJsonPath = join(distPath, 'package.json');
const distPackageJson = require(distPackageJsonPath);
distPackageJson.name = packageJson.name;
distPackageJson.version = packageJson.version;
distPackageJson.dependencies = packageJson.dependencies;
distPackageJson.devDependencies = packageJson.devDependencies;
distPackageJson.publishConfig = {
access: (packageJson.publishConfig && packageJson.publishConfig.access) || 'public',
};
await writeFile(distPackageJsonPath, JSON.stringify(distPackageJson, null, 2));
return new Promise((resolve, reject) => {
const publishSpawn = cp.spawn('npm', [
'publish',
distPath,
'--tag',
tag,
'--access',
distPackageJson.publishConfig.access,
]);
publishSpawn.stdout.on('data', (data) => {
console.info(data.toString('utf8'));
});
publishSpawn.stderr.on('data', function (data) {
console.error(data.toString('utf8'));
});
publishSpawn.on('exit', function (code, signal) {
if (code !== 0) {
reject(new Error(`npm publish exited with code: ${code} and signal: ${signal}`));
} else {
resolve();
}
});
});
}
})
);
console.info(`${tag} => ${version}`);
}
release().catch((err) => {
console.error(err);
process.exit(1);
});
================================================
FILE: templates/fullstack/.dockerignore
================================================
node_modules
npm-debug.log
================================================
FILE: templates/fullstack/.gitignore
================================================
node_modules
dist
types
yarn.lock
yarn-error.log
================================================
FILE: templates/fullstack/.graphqlrc.yml
================================================
schema: ./server/src/schema/**/*.graphql
documents: ./client/src/graphql/**/*.graphql
extensions:
codegen:
generates:
./client/src/generated-types.tsx:
config:
withComponent: false
withHOC: false
withHooks: true
skipDocumentsValidation: true
plugins:
- add: '/* tslint:disable */'
- typescript
- typescript-operations
- typescript-react-apollo
./server/src/generated-types.ts:
config:
contextType: '@graphback/core#GraphbackContext'
mappers:
Comment: './generated-db-types#comment'
Note: './generated-db-types#note'
useIndexSignature: true
skipDocumentsValidation: true
plugins:
- add: '/* tslint:disable */'
- typescript
- typescript-resolvers
# Graphback configuration
graphback:
## Input schema
model: ./model
## Global configuration for CRUD generator
crud:
create: true
update: true
find: true
findOne: true
delete: true
subCreate: true
subUpdate: true
subDelete: true
## Codegen plugins
plugins:
graphback-schema:
outputPath: ./server/src/schema/schema.graphql
graphback-client:
outputFile: ./client/src/graphql/graphback.graphql
================================================
FILE: templates/fullstack/Dockerfile
================================================
# Stage 1 - the build process
FROM node:10 as compile-server
WORKDIR /usr/src/app
COPY . .
RUN npm install
RUN npm run build
CMD [ "npm", "start" ]
================================================
FILE: templates/fullstack/README.md
================================================
# GraphQL CLI Basic Full Stack Template
Starter Full Stack template using GraphQL CLI.
## Usage
This project has been created using GraphQL CLI. Run the project using the following steps:
### Install
yarn install
### Database
Start the database
docker-compose up -d
Generate resources(schema and resolvers) and create database
yarn graphql generate --backend
yarn graphql generate --db
Generate typings for Database Schema and Resolvers
yarn schemats generate
yarn graphql codegen
### Server
Start the server
yarn start:server
### Client
Generate queries, mutations and subscriptions for client-side project
yarn graphql generate --client
Generate React components
yarn graphql codegen
Start React App
yarn start:client
================================================
FILE: templates/fullstack/client/.gitignore
================================================
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
================================================
FILE: templates/fullstack/client/generated-types.tsx
================================================
/* tslint:disable */
import gql from 'graphql-tag';
import * as ApolloReactCommon from '@apollo/react-common';
import * as ApolloReactHooks from '@apollo/react-hooks';
export type Maybe<T> = T | null;
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
};
/** @model */
export type Comment = {
__typename?: 'Comment';
id: Scalars['ID'];
text?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
/** @manyToOne field: 'comments', key: 'noteId' */
note?: Maybe<Note>;
};
export type CommentInput = {
id?: Maybe<Scalars['ID']>;
text?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
noteId?: Maybe<Scalars['String']>;
};
export type Mutation = {
__typename?: 'Mutation';
createNote: Note;
updateNote: Note;
deleteNote: Note;
createComment: Comment;
updateComment: Comment;
deleteComment: Comment;
};
export type MutationCreateNoteArgs = {
input?: Maybe<NoteInput>;
};
export type MutationUpdateNoteArgs = {
input?: Maybe<NoteInput>;
};
export type MutationDeleteNoteArgs = {
input?: Maybe<NoteInput>;
};
export type MutationCreateCommentArgs = {
input?: Maybe<CommentInput>;
};
export type MutationUpdateCommentArgs = {
input?: Maybe<CommentInput>;
};
export type MutationDeleteCommentArgs = {
input?: Maybe<CommentInput>;
};
/** @model */
export type Note = {
__typename?: 'Note';
id: Scalars['ID'];
title: Scalars['String'];
description?: Maybe<Scalars['String']>;
/** @oneToMany field: 'note', key: 'noteId' */
comments: Array<Maybe<Comment>>;
};
export type NoteInput = {
id?: Maybe<Scalars['ID']>;
title?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
};
export type Query = {
__typename?: 'Query';
findAllNotes: Array<Maybe<Note>>;
findNotes: Array<Maybe<Note>>;
findAllComments: Array<Maybe<Comment>>;
findComments: Array<Maybe<Comment>>;
};
export type QueryFindAllNotesArgs = {
limit?: Maybe<Scalars['Int']>;
offset?: Maybe<Scalars['Int']>;
};
export type QueryFindNotesArgs = {
fields?: Maybe<NoteInput>;
limit?: Maybe<Scalars['Int']>;
offset?: Maybe<Scalars['Int']>;
};
export type QueryFindAllCommentsArgs = {
limit?: Maybe<Scalars['Int']>;
offset?: Maybe<Scalars['Int']>;
};
export type QueryFindCommentsArgs = {
fields?: Maybe<CommentInput>;
limit?: Maybe<Scalars['Int']>;
offset?: Maybe<Scalars['Int']>;
};
export type Subscription = {
__typename?: 'Subscription';
newNote: Note;
updatedNote: Note;
deletedNote: Note;
newComment: Comment;
updatedComment: Comment;
deletedComment: Comment;
};
export type SubscriptionNewNoteArgs = {
input?: Maybe<NoteInput>;
};
export type SubscriptionUpdatedNoteArgs = {
input?: Maybe<NoteInput>;
};
export type SubscriptionDeletedNoteArgs = {
input?: Maybe<NoteInput>;
};
export type SubscriptionNewCommentArgs = {
input?: Maybe<CommentInput>;
};
export type SubscriptionUpdatedCommentArgs = {
input?: Maybe<CommentInput>;
};
export type SubscriptionDeletedCommentArgs = {
input?: Maybe<CommentInput>;
};
export type CommentFieldsFragment = { __typename?: 'Comment' } & Pick<Comment, 'id' | 'text' | 'description'>;
export type CommentExpandedFieldsFragment = { __typename?: 'Comment' } & Pick<
Comment,
'id' | 'text' | 'description'
> & { note: Maybe<{ __typename?: 'Note' } & Pick<Note, 'id' | 'title' | 'description'>> };
export type NoteFieldsFragment = { __typename?: 'Note' } & Pick<Note, 'id' | 'title' | 'description'>;
export type NoteExpandedFieldsFragment = { __typename?: 'Note' } & Pick<Note, 'id' | 'title' | 'description'> & {
comments: Array<Maybe<{ __typename?: 'Comment' } & Pick<Comment, 'id' | 'text' | 'description'>>>;
};
export type CreateCommentMutationVariables = {
input: CommentInput;
};
export type CreateCommentMutation = { __typename?: 'Mutation' } & {
createComment: { __typename?: 'Comment' } & CommentFieldsFragment;
};
export type CreateNoteMutationVariables = {
input: NoteInput;
};
export type CreateNoteMutation = { __typename?: 'Mutation' } & {
createNote: { __typename?: 'Note' } & NoteFieldsFragment;
};
export type DeleteCommentMutationVariables = {
input: CommentInput;
};
export type DeleteCommentMutation = { __typename?: 'Mutation' } & {
deleteComment: { __typename?: 'Comment' } & CommentFieldsFragment;
};
export type DeleteNoteMutationVariables = {
input: NoteInput;
};
export type DeleteNoteMutation = { __typename?: 'Mutation' } & {
deleteNote: { __typename?: 'Note' } & NoteFieldsFragment;
};
export type UpdateCommentMutationVariables = {
input: CommentInput;
};
export type UpdateCommentMutation = { __typename?: 'Mutation' } & {
updateComment: { __typename?: 'Comment' } & CommentFieldsFragment;
};
export type UpdateNoteMutationVariables = {
input: NoteInput;
};
export type UpdateNoteMutation = { __typename?: 'Mutation' } & {
updateNote: { __typename?: 'Note' } & NoteFieldsFragment;
};
export type FindAllCommentsQueryVariables = {
limit?: Maybe<Scalars['Int']>;
offset?: Maybe<Scalars['Int']>;
};
export type FindAllCommentsQuery = { __typename?: 'Query' } & {
findAllComments: Array<Maybe<{ __typename?: 'Comment' } & CommentExpandedFieldsFragment>>;
};
export type FindAllNotesQueryVariables = {
limit?: Maybe<Scalars['Int']>;
offset?: Maybe<Scalars['Int']>;
};
export type FindAllNotesQuery = { __typename?: 'Query' } & {
findAllNotes: Array<Maybe<{ __typename?: 'Note' } & NoteExpandedFieldsFragment>>;
};
export type FindCommentsQueryVariables = {
fields: CommentInput;
limit?: Maybe<Scalars['Int']>;
offset?: Maybe<Scalars['Int']>;
};
export type FindCommentsQuery = { __typename?: 'Query' } & {
findComments: Array<Maybe<{ __typename?: 'Comment' } & CommentExpandedFieldsFragment>>;
};
export type FindNotesQueryVariables = {
fields: NoteInput;
limit?: Maybe<Scalars['Int']>;
offset?: Maybe<Scalars['Int']>;
};
export type FindNotesQuery = { __typename?: 'Query' } & {
findNotes: Array<Maybe<{ __typename?: 'Note' } & NoteExpandedFieldsFragment>>;
};
export type DeletedCommentSubscriptionVariables = {};
export type DeletedCommentSubscription = { __typename?: 'Subscription' } & {
deletedComment: { __typename?: 'Comment' } & CommentFieldsFragment;
};
export type DeletedNoteSubscriptionVariables = {};
export type DeletedNoteSubscription = { __typename?: 'Subscription' } & {
deletedNote: { __typename?: 'Note' } & NoteFieldsFragment;
};
export type NewCommentSubscriptionVariables = {};
export type NewCommentSubscription = { __typename?: 'Subscription' } & {
newComment: { __typename?: 'Comment' } & CommentFieldsFragment;
};
export type NewNoteSubscriptionVariables = {};
export type NewNoteSubscription = { __typename?: 'Subscription' } & {
newNote: { __typename?: 'Note' } & NoteFieldsFragment;
};
export type UpdatedCommentSubscriptionVariables = {};
export type UpdatedCommentSubscription = { __typename?: 'Subscription' } & {
updatedComment: { __typename?: 'Comment' } & CommentFieldsFragment;
};
export type UpdatedNoteSubscriptionVariables = {};
export type UpdatedNoteSubscription = { __typename?: 'Subscription' } & {
updatedNote: { __typename?: 'Note' } & NoteFieldsFragment;
};
export const CommentFieldsFragmentDoc = gql`
fragment CommentFields on Comment {
id
text
description
}
`;
export const CommentExpandedFieldsFragmentDoc = gql`
fragment CommentExpandedFields on Comment {
id
text
description
note {
id
title
description
}
}
`;
export const NoteFieldsFragmentDoc = gql`
fragment NoteFields on Note {
id
title
description
}
`;
export const NoteExpandedFieldsFragmentDoc = gql`
fragment NoteExpandedFields on Note {
id
title
description
comments {
id
text
description
}
}
`;
export const CreateCommentDocument = gql`
mutation createComment($input: CommentInput!) {
createComment(input: $input) {
...CommentFields
}
}
${CommentFieldsFragmentDoc}
`;
export type CreateCommentMutationFn = ApolloReactCommon.MutationFunction<
CreateCommentMutation,
CreateCommentMutationVariables
>;
/**
* __useCreateCommentMutation__
*
* To run a mutation, you first call `useCreateCommentMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useCreateCommentMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [createCommentMutation, { data, loading, error }] = useCreateCommentMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useCreateCommentMutation(
baseOptions?: ApolloReactHooks.MutationHookOptions<CreateCommentMutation, CreateCommentMutationVariables>
) {
return ApolloReactHooks.useMutation<CreateCommentMutation, CreateCommentMutationVariables>(
CreateCommentDocument,
baseOptions
);
}
export type CreateCommentMutationHookResult = ReturnType<typeof useCreateCommentMutation>;
export type CreateCommentMutationResult = ApolloReactCommon.MutationResult<CreateCommentMutation>;
export type CreateCommentMutationOptions = ApolloReactCommon.BaseMutationOptions<
CreateCommentMutation,
CreateCommentMutationVariables
>;
export const CreateNoteDocument = gql`
mutation createNote($input: NoteInput!) {
createNote(input: $input) {
...NoteFields
}
}
${NoteFieldsFragmentDoc}
`;
export type CreateNoteMutationFn = ApolloReactCommon.MutationFunction<CreateNoteMutation, CreateNoteMutationVariables>;
/**
* __useCreateNoteMutation__
*
* To run a mutation, you first call `useCreateNoteMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useCreateNoteMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [createNoteMutation, { data, loading, error }] = useCreateNoteMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useCreateNoteMutation(
baseOptions?: ApolloReactHooks.MutationHookOptions<CreateNoteMutation, CreateNoteMutationVariables>
) {
return ApolloReactHooks.useMutation<CreateNoteMutation, CreateNoteMutationVariables>(CreateNoteDocument, baseOptions);
}
export type CreateNoteMutationHookResult = ReturnType<typeof useCreateNoteMutation>;
export type CreateNoteMutationResult = ApolloReactCommon.MutationResult<CreateNoteMutation>;
export type CreateNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<
CreateNoteMutation,
CreateNoteMutationVariables
>;
export const DeleteCommentDocument = gql`
mutation deleteComment($input: CommentInput!) {
deleteComment(input: $input) {
...CommentFields
}
}
${CommentFieldsFragmentDoc}
`;
export type DeleteCommentMutationFn = ApolloReactCommon.MutationFunction<
DeleteCommentMutation,
DeleteCommentMutationVariables
>;
/**
* __useDeleteCommentMutation__
*
* To run a mutation, you first call `useDeleteCommentMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useDeleteCommentMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [deleteCommentMutation, { data, loading, error }] = useDeleteCommentMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useDeleteCommentMutation(
baseOptions?: ApolloReactHooks.MutationHookOptions<DeleteCommentMutation, DeleteCommentMutationVariables>
) {
return ApolloReactHooks.useMutation<DeleteCommentMutation, DeleteCommentMutationVariables>(
DeleteCommentDocument,
baseOptions
);
}
export type DeleteCommentMutationHookResult = ReturnType<typeof useDeleteCommentMutation>;
export type DeleteCommentMutationResult = ApolloReactCommon.MutationResult<DeleteCommentMutation>;
export type DeleteCommentMutationOptions = ApolloReactCommon.BaseMutationOptions<
DeleteCommentMutation,
DeleteCommentMutationVariables
>;
export const DeleteNoteDocument = gql`
mutation deleteNote($input: NoteInput!) {
deleteNote(input: $input) {
...NoteFields
}
}
${NoteFieldsFragmentDoc}
`;
export type DeleteNoteMutationFn = ApolloReactCommon.MutationFunction<DeleteNoteMutation, DeleteNoteMutationVariables>;
/**
* __useDeleteNoteMutation__
*
* To run a mutation, you first call `useDeleteNoteMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useDeleteNoteMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [deleteNoteMutation, { data, loading, error }] = useDeleteNoteMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useDeleteNoteMutation(
baseOptions?: ApolloReactHooks.MutationHookOptions<DeleteNoteMutation, DeleteNoteMutationVariables>
) {
return ApolloReactHooks.useMutation<DeleteNoteMutation, DeleteNoteMutationVariables>(DeleteNoteDocument, baseOptions);
}
export type DeleteNoteMutationHookResult = ReturnType<typeof useDeleteNoteMutation>;
export type DeleteNoteMutationResult = ApolloReactCommon.MutationResult<DeleteNoteMutation>;
export type DeleteNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<
DeleteNoteMutation,
DeleteNoteMutationVariables
>;
export const UpdateCommentDocument = gql`
mutation updateComment($input: CommentInput!) {
updateComment(input: $input) {
...CommentFields
}
}
${CommentFieldsFragmentDoc}
`;
export type UpdateCommentMutationFn = ApolloReactCommon.MutationFunction<
UpdateCommentMutation,
UpdateCommentMutationVariables
>;
/**
* __useUpdateCommentMutation__
*
* To run a mutation, you first call `useUpdateCommentMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useUpdateCommentMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [updateCommentMutation, { data, loading, error }] = useUpdateCommentMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useUpdateCommentMutation(
baseOptions?: ApolloReactHooks.MutationHookOptions<UpdateCommentMutation, UpdateCommentMutationVariables>
) {
return ApolloReactHooks.useMutation<UpdateCommentMutation, UpdateCommentMutationVariables>(
UpdateCommentDocument,
baseOptions
);
}
export type UpdateCommentMutationHookResult = ReturnType<typeof useUpdateCommentMutation>;
export type UpdateCommentMutationResult = ApolloReactCommon.MutationResult<UpdateCommentMutation>;
export type UpdateCommentMutationOptions = ApolloReactCommon.BaseMutationOptions<
UpdateCommentMutation,
UpdateCommentMutationVariables
>;
export const UpdateNoteDocument = gql`
mutation updateNote($input: NoteInput!) {
updateNote(input: $input) {
...NoteFields
}
}
${NoteFieldsFragmentDoc}
`;
export type UpdateNoteMutationFn = ApolloReactCommon.MutationFunction<UpdateNoteMutation, UpdateNoteMutationVariables>;
/**
* __useUpdateNoteMutation__
*
* To run a mutation, you first call `useUpdateNoteMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useUpdateNoteMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [updateNoteMutation, { data, loading, error }] = useUpdateNoteMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useUpdateNoteMutation(
baseOptions?: ApolloReactHooks.MutationHookOptions<UpdateNoteMutation, UpdateNoteMutationVariables>
) {
return ApolloReactHooks.useMutation<UpdateNoteMutation, UpdateNoteMutationVariables>(UpdateNoteDocument, baseOptions);
}
export type UpdateNoteMutationHookResult = ReturnType<typeof useUpdateNoteMutation>;
export type UpdateNoteMutationResult = ApolloReactCommon.MutationResult<UpdateNoteMutation>;
export type UpdateNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<
UpdateNoteMutation,
UpdateNoteMutationVariables
>;
export const FindAllCommentsDocument = gql`
query findAllComments($limit: Int, $offset: Int) {
findAllComments(limit: $limit, offset: $offset) {
...CommentExpandedFields
}
}
${CommentExpandedFieldsFragmentDoc}
`;
/**
* __useFindAllCommentsQuery__
*
* To run a query within a React component, call `useFindAllCommentsQuery` and pass it any options that fit your needs.
* When your component renders, `useFindAllCommentsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useFindAllCommentsQuery({
* variables: {
* limit: // value for 'limit'
* offset: // value for 'offset'
* },
* });
*/
export function useFindAllCommentsQuery(
baseOptions?: ApolloReactHooks.QueryHookOptions<FindAllCommentsQuery, FindAllCommentsQueryVariables>
) {
return ApolloReactHooks.useQuery<FindAllCommentsQuery, FindAllCommentsQueryVariables>(
FindAllCommentsDocument,
baseOptions
);
}
export function useFindAllCommentsLazyQuery(
baseOptions?: ApolloReactHooks.LazyQueryHookOptions<FindAllCommentsQuery, FindAllCommentsQueryVariables>
) {
return ApolloReactHooks.useLazyQuery<FindAllCommentsQuery, FindAllCommentsQueryVariables>(
FindAllCommentsDocument,
baseOptions
);
}
export type FindAllCommentsQueryHookResult = ReturnType<typeof useFindAllCommentsQuery>;
export type FindAllCommentsLazyQueryHookResult = ReturnType<typeof useFindAllCommentsLazyQuery>;
export type FindAllCommentsQueryResult = ApolloReactCommon.QueryResult<
FindAllCommentsQuery,
FindAllCommentsQueryVariables
>;
export const FindAllNotesDocument = gql`
query findAllNotes($limit: Int, $offset: Int) {
findAllNotes(limit: $limit, offset: $offset) {
...NoteExpandedFields
}
}
${NoteExpandedFieldsFragmentDoc}
`;
/**
* __useFindAllNotesQuery__
*
* To run a query within a React component, call `useFindAllNotesQuery` and pass it any options that fit your needs.
* When your component renders, `useFindAllNotesQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useFindAllNotesQuery({
* variables: {
* limit: // value for 'limit'
* offset: // value for 'offset'
* },
* });
*/
export function useFindAllNotesQuery(
baseOptions?: ApolloReactHooks.QueryHookOptions<FindAllNotesQuery, FindAllNotesQueryVariables>
) {
return ApolloReactHooks.useQuery<FindAllNotesQuery, FindAllNotesQueryVariables>(FindAllNotesDocument, baseOptions);
}
export function useFindAllNotesLazyQuery(
baseOptions?: ApolloReactHooks.LazyQueryHookOptions<FindAllNotesQuery, FindAllNotesQueryVariables>
) {
return ApolloReactHooks.useLazyQuery<FindAllNotesQuery, FindAllNotesQueryVariables>(
FindAllNotesDocument,
baseOptions
);
}
export type FindAllNotesQueryHookResult = ReturnType<typeof useFindAllNotesQuery>;
export type FindAllNotesLazyQueryHookResult = ReturnType<typeof useFindAllNotesLazyQuery>;
export type FindAllNotesQueryResult = ApolloReactCommon.QueryResult<FindAllNotesQuery, FindAllNotesQueryVariables>;
export const FindCommentsDocument = gql`
query findComments($fields: CommentInput!, $limit: Int, $offset: Int) {
findComments(fields: $fields, limit: $limit, offset: $offset) {
...CommentExpandedFields
}
}
${CommentExpandedFieldsFragmentDoc}
`;
/**
* __useFindCommentsQuery__
*
* To run a query within a React component, call `useFindCommentsQuery` and pass it any options that fit your needs.
* When your component renders, `useFindCommentsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useFindCommentsQuery({
* variables: {
* fields: // value for 'fields'
* limit: // value for 'limit'
* offset: // value for 'offset'
* },
* });
*/
export function useFindCommentsQuery(
baseOptions?: ApolloReactHooks.QueryHookOptions<FindCommentsQuery, FindCommentsQueryVariables>
) {
return ApolloReactHooks.useQuery<FindCommentsQuery, FindCommentsQueryVariables>(FindCommentsDocument, baseOptions);
}
export function useFindCommentsLazyQuery(
baseOptions?: ApolloReactHooks.LazyQueryHookOptions<FindCommentsQuery, FindCommentsQueryVariables>
) {
return ApolloReactHooks.useLazyQuery<FindCommentsQuery, FindCommentsQueryVariables>(
FindCommentsDocument,
baseOptions
);
}
export type FindCommentsQueryHookResult = ReturnType<typeof useFindCommentsQuery>;
export type FindCommentsLazyQueryHookResult = ReturnType<typeof useFindCommentsLazyQuery>;
export type FindCommentsQueryResult = ApolloReactCommon.QueryResult<FindCommentsQuery, FindCommentsQueryVariables>;
export const FindNotesDocument = gql`
query findNotes($fields: NoteInput!, $limit: Int, $offset: Int) {
findNotes(fields: $fields, limit: $limit, offset: $offset) {
...NoteExpandedFields
}
}
${NoteExpandedFieldsFragmentDoc}
`;
/**
* __useFindNotesQuery__
*
* To run a query within a React component, call `useFindNotesQuery` and pass it any options that fit your needs.
* When your component renders, `useFindNotesQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useFindNotesQuery({
* variables: {
* fields: // value for 'fields'
* limit: // value for 'limit'
* offset: // value for 'offset'
* },
* });
*/
export function useFindNotesQuery(
baseOptions?: ApolloReactHooks.QueryHookOptions<FindNotesQuery, FindNotesQueryVariables>
) {
return ApolloReactHooks.useQuery<FindNotesQuery, FindNotesQueryVariables>(FindNotesDocument, baseOptions);
}
export function useFindNotesLazyQuery(
baseOptions?: ApolloReactHooks.LazyQueryHookOptions<FindNotesQuery, FindNotesQueryVariables>
) {
return ApolloReactHooks.useLazyQuery<FindNotesQuery, FindNotesQueryVariables>(FindNotesDocument, baseOptions);
}
export type FindNotesQueryHookResult = ReturnType<typeof useFindNotesQuery>;
export type FindNotesLazyQueryHookResult = ReturnType<typeof useFindNotesLazyQuery>;
export type FindNotesQueryResult = ApolloReactCommon.QueryResult<FindNotesQuery, FindNotesQueryVariables>;
export const DeletedCommentDocument = gql`
subscription deletedComment {
deletedComment {
...CommentFields
}
}
${CommentFieldsFragmentDoc}
`;
/**
* __useDeletedCommentSubscription__
*
* To run a query within a React component, call `useDeletedCommentSubscription` and pass it any options that fit your needs.
* When your component renders, `useDeletedCommentSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useDeletedCommentSubscription({
* variables: {
* },
* });
*/
export function useDeletedCommentSubscription(
baseOptions?: ApolloReactHooks.SubscriptionHookOptions<
DeletedCommentSubscription,
DeletedCommentSubscriptionVariables
>
) {
return ApolloReactHooks.useSubscription<DeletedCommentSubscription, DeletedCommentSubscriptionVariables>(
DeletedCommentDocument,
baseOptions
);
}
export type DeletedCommentSubscriptionHookResult = ReturnType<typeof useDeletedCommentSubscription>;
export type DeletedCommentSubscriptionResult = ApolloReactCommon.SubscriptionResult<DeletedCommentSubscription>;
export const DeletedNoteDocument = gql`
subscription deletedNote {
deletedNote {
...NoteFields
}
}
${NoteFieldsFragmentDoc}
`;
/**
* __useDeletedNoteSubscription__
*
* To run a query within a React component, call `useDeletedNoteSubscription` and pass it any options that fit your needs.
* When your component renders, `useDeletedNoteSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useDeletedNoteSubscription({
* variables: {
* },
* });
*/
export function useDeletedNoteSubscription(
baseOptions?: ApolloReactHooks.SubscriptionHookOptions<DeletedNoteSubscription, DeletedNoteSubscriptionVariables>
) {
return ApolloReactHooks.useSubscription<DeletedNoteSubscription, DeletedNoteSubscriptionVariables>(
DeletedNoteDocument,
baseOptions
);
}
export type DeletedNoteSubscriptionHookResult = ReturnType<typeof useDeletedNoteSubscription>;
export type DeletedNoteSubscriptionResult = ApolloReactCommon.SubscriptionResult<DeletedNoteSubscription>;
export const NewCommentDocument = gql`
subscription newComment {
newComment {
...CommentFields
}
}
${CommentFieldsFragmentDoc}
`;
/**
* __useNewCommentSubscription__
*
* To run a query within a React component, call `useNewCommentSubscription` and pass it any options that fit your needs.
* When your component renders, `useNewCommentSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useNewCommentSubscription({
* variables: {
* },
* });
*/
export function useNewCommentSubscription(
baseOptions?: ApolloReactHooks.SubscriptionHookOptions<NewCommentSubscription, NewCommentSubscriptionVariables>
) {
return ApolloReactHooks.useSubscription<NewCommentSubscription, NewCommentSubscriptionVariables>(
NewCommentDocument,
baseOptions
);
}
export type NewCommentSubscriptionHookResult = ReturnType<typeof useNewCommentSubscription>;
export type NewCommentSubscriptionResult = ApolloReactCommon.SubscriptionResult<NewCommentSubscription>;
export const NewNoteDocument = gql`
subscription newNote {
newNote {
...NoteFields
}
}
${NoteFieldsFragmentDoc}
`;
/**
* __useNewNoteSubscription__
*
* To run a query within a React component, call `useNewNoteSubscription` and pass it any options that fit your needs.
* When your component renders, `useNewNoteSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useNewNoteSubscription({
* variables: {
* },
* });
*/
export function useNewNoteSubscription(
baseOptions?: ApolloReactHooks.SubscriptionHookOptions<NewNoteSubscription, NewNoteSubscriptionVariables>
) {
return ApolloReactHooks.useSubscription<NewNoteSubscription, NewNoteSubscriptionVariables>(
NewNoteDocument,
baseOptions
);
}
export type NewNoteSubscriptionHookResult = ReturnType<typeof useNewNoteSubscription>;
export type NewNoteSubscriptionResult = ApolloReactCommon.SubscriptionResult<NewNoteSubscription>;
export const UpdatedCommentDocument = gql`
subscription updatedComment {
updatedComment {
...CommentFields
}
}
${CommentFieldsFragmentDoc}
`;
/**
* __useUpdatedCommentSubscription__
*
* To run a query within a React component, call `useUpdatedCommentSubscription` and pass it any options that fit your needs.
* When your component renders, `useUpdatedCommentSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useUpdatedCommentSubscription({
* variables: {
* },
* });
*/
export function useUpdatedCommentSubscription(
baseOptions?: ApolloReactHooks.SubscriptionHookOptions<
UpdatedCommentSubscription,
UpdatedCommentSubscriptionVariables
>
) {
return ApolloReactHooks.useSubscription<UpdatedCommentSubscription, UpdatedCommentSubscriptionVariables>(
UpdatedCommentDocument,
baseOptions
);
}
export type UpdatedCommentSubscriptionHookResult = ReturnType<typeof useUpdatedCommentSubscription>;
export type UpdatedCommentSubscriptionResult = ApolloReactCommon.SubscriptionResult<UpdatedCommentSubscription>;
export const UpdatedNoteDocument = gql`
subscription updatedNote {
updatedNote {
...NoteFields
}
}
${NoteFieldsFragmentDoc}
`;
/**
* __useUpdatedNoteSubscription__
*
* To run a query within a React component, call `useUpdatedNoteSubscription` and pass it any options that fit your needs.
* When your component renders, `useUpdatedNoteSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useUpdatedNoteSubscription({
* variables: {
* },
* });
*/
export function useUpdatedNoteSubscription(
baseOptions?: ApolloReactHooks.SubscriptionHookOptions<UpdatedNoteSubscription, UpdatedNoteSubscriptionVariables>
) {
return ApolloReactHooks.useSubscription<UpdatedNoteSubscription, UpdatedNoteSubscriptionVariables>(
UpdatedNoteDocument,
baseOptions
);
}
export type UpdatedNoteSubscriptionHookResult = ReturnType<typeof useUpdatedNoteSubscription>;
export type UpdatedNoteSubscriptionResult = ApolloReactCommon.SubscriptionResult<UpdatedNoteSubscription>;
================================================
FILE: templates/fullstack/client/package.json
================================================
{
"name": "full-stack-template-client",
"version": "4.1.0",
"private": true,
"devDependencies": {
"@types/jest": "26.0.24",
"@types/node": "13.13.45",
"@types/react": "17.0.34",
"@types/react-dom": "17.0.11",
"react-scripts": "4.0.3",
"typescript": "4.4.4"
},
"dependencies": {
"@apollo/react-common": "3.1.4",
"@apollo/react-hooks": "3.1.5",
"@material-ui/core": "4.12.3",
"apollo-boost": "0.4.9",
"graphql": "15.7.2",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
================================================
FILE: templates/fullstack/client/public/index.html
================================================
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
================================================
FILE: templates/fullstack/client/public/manifest.json
================================================
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
================================================
FILE: templates/fullstack/client/public/robots.txt
================================================
# https://www.robotstxt.org/robotstxt.html
User-agent: *
================================================
FILE: templates/fullstack/client/src/App.css
================================================
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #09d3ac;
}
================================================
FILE: templates/fullstack/client/src/App.test.tsx
================================================
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
================================================
FILE: templates/fullstack/client/src/App.tsx
================================================
import React from 'react';
import './App.css';
import { useFindNotesQuery } from './generated-types';
import CreateNote from './components/notes/CreateNote';
import OneNote from './components/notes/OneNote';
const App: React.FC = () => {
const allNotes = useFindNotesQuery();
allNotes.startPolling(2000);
console.log(allNotes.data?.findNotes);
return (
<div>
<CreateNote></CreateNote>
<ul>
{
// TODO fix typings
allNotes.data &&
allNotes.data.findNotes.items.map((note: any) => (
<OneNote
key={note.id}
id={note.id}
title={note.title}
description={note.description}
comments={note.comments}
></OneNote>
))
}
</ul>
</div>
);
};
export default App;
================================================
FILE: templates/fullstack/client/src/components/comment/Comment.css
================================================
.comment{
color:grey;
}
================================================
FILE: templates/fullstack/client/src/components/comment/CreateComment.tsx
================================================
import React, { useState } from 'react';
import { useCreateCommentMutation } from '../../generated-types';
import { Card, TextField, Button } from '@material-ui/core';
import './../notes/Note.css';
type createCommentProps = {
noteId: string;
addCommentState: any;
};
const CreateComment = ({ noteId, addCommentState }: createCommentProps) => {
const [createComment] = useCreateCommentMutation();
const [newCommentTitle, setNewCommentTitle] = useState('');
const [newCommentDescription, setNewCommentDescription] = useState('');
return (
<div>
<Card className="inputCard">
<form noValidate autoComplete="off" className="inputForm">
<h3>Create Comment</h3>
<TextField
label="Title"
variant="outlined"
onChange={(e) => setNewCommentTitle(e.target.value)}
value={newCommentTitle}
/>
<TextField
label="Description"
variant="outlined"
onChange={(e) => setNewCommentDescription(e.target.value)}
value={newCommentDescription}
/>
<Button
variant="outlined"
color="primary"
onClick={() => {
createComment({
variables: { input: { text: newCommentTitle, description: newCommentDescription, noteId: noteId } },
});
addCommentState(false);
}}
>
Add Comment
</Button>
</form>
</Card>
</div>
);
};
export default CreateComment;
================================================
FILE: templates/fullstack/client/src/components/comment/OneComment.tsx
================================================
import React from 'react';
import { useDeleteCommentMutation, Comment } from '../../generated-types';
import { Button } from '@material-ui/core';
import './Comment.css';
const OneComment = ({ id, text, description }: Comment) => {
const [deleteComment] = useDeleteCommentMutation();
return (
<div>
<li className="comment">
<strong>{text}</strong>:
{description}
<Button
variant="outlined"
color="secondary"
onClick={() => deleteComment({ variables: { input: { id: id } } })}
>
Delete Comment
</Button>
</li>
</div>
);
};
export default OneComment;
================================================
FILE: templates/fullstack/client/src/components/notes/CreateNote.tsx
================================================
import React, { useState } from 'react';
import { useCreateNoteMutation } from '../../generated-types';
import { Button, TextField, Card } from '@material-ui/core';
import './Note.css';
const CreateNote: React.FC = () => {
const [createNote] = useCreateNoteMutation();
const [newNoteTitle, setNewNoteTitle] = useState('');
const [newNoteDescription, setNewNoteDescription] = useState('');
return (
<div>
<Card className="inputCard">
<form noValidate autoComplete="off" className="inputForm">
<h3>Create Note</h3>
<p>This application works only with sample Node/Comment model</p>
<TextField
label="Title"
variant="outlined"
onChange={(e) => setNewNoteTitle(e.target.value)}
value={newNoteTitle}
/>
<TextField
label="Description"
variant="outlined"
onChange={(e) => setNewNoteDescription(e.target.value)}
value={newNoteDescription}
/>
<Button
variant="outlined"
color="primary"
onClick={() => {
createNote({ variables: { input: { title: newNoteTitle, description: newNoteDescription } } });
}}
>
Add Note
</Button>
</form>
</Card>
</div>
);
};
export default CreateNote;
================================================
FILE: templates/fullstack/client/src/components/notes/EditNote.tsx
================================================
import React, { useState } from 'react';
import { useUpdateNoteMutation } from '../../generated-types';
import { Button, TextField, Card } from '@material-ui/core';
import './Note.css';
type noteProps = {
id: string;
title: string;
description: string | undefined;
editState: any;
};
const EditNote = ({ id, title, description, editState }: noteProps) => {
const [updateNote] = useUpdateNoteMutation();
const [NoteTitle, setNoteTitle] = useState(title);
const [NoteDescription, setNoteDescription] = useState(description);
return (
<div>
<Card className="inputCard">
<form noValidate autoComplete="off" className="inputForm">
<h3>Edit Note</h3>
<TextField
label="Title"
variant="outlined"
onChange={(e) => setNoteTitle(e.target.value)}
value={NoteTitle}
/>
<TextField
label="Description"
variant="outlined"
onChange={(e) => setNoteDescription(e.target.value)}
value={NoteDescription}
/>
<Button
variant="outlined"
color="primary"
onClick={() => {
updateNote({ variables: { input: { id: id, title: NoteTitle, description: NoteDescription } } });
editState(false);
}}
>
Update Note
</Button>
</form>
</Card>
</div>
);
};
export default EditNote;
================================================
FILE: templates/fullstack/client/src/components/notes/Note.css
================================================
.inputForm{
display:grid;
margin: 15%;
width: 70%;
}
.inputCard{
width: 50%;
margin-left: 25%;
}
.OneNote{
margin:5%;
}
================================================
FILE: templates/fullstack/client/src/components/notes/OneNote.tsx
================================================
import React, { useState } from 'react';
import EditNote from './EditNote';
import { Note } from '../../generated-types';
import CreateComment from '../comment/CreateComment';
import OneComment from '../comment/OneComment';
import { Button, Card } from '@material-ui/core';
const OneNote = ({ id, title, description, comments }: Note) => {
const [noteEdit, setNoteEdit] = useState(false);
const [addComment, setAddComment] = useState(false);
return (
<div>
<Card className="inputCard">
<li className="OneNote">
<strong>{title}</strong>:
{description}
<Button onClick={() => setNoteEdit(!noteEdit)} variant="outlined" color="primary">
Edit
</Button>
<Button onClick={() => setAddComment(!addComment)} variant="outlined" color="primary">
Add Comment
</Button>
{noteEdit ? (
<EditNote id={id} title={title} description={description || ''} editState={setNoteEdit}></EditNote>
) : (
<div></div>
)}
{addComment ? <CreateComment noteId={id} addCommentState={setAddComment}></CreateComment> : <div></div>}
<ul>
{comments && comments.length > 0 ? (
comments.map((com) => {
if (!com) {
return;
}
return <OneComment id={com.id} text={com.text} description={com.description} key={com.id}></OneComment>;
})
) : (
<div></div>
)}
</ul>
</li>
</Card>
</div>
);
};
export default OneNote;
================================================
FILE: templates/fullstack/client/src/generated-types.tsx
================================================
/* tslint:disable */
import gql from 'graphql-tag';
import * as ApolloReactCommon from '@apollo/react-common';
import * as ApolloReactHooks from '@apollo/react-hooks';
export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: any }> = { [K in keyof T]: T[K] };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
};
/** @model */
export type Comment = {
__typename?: 'Comment';
id: Scalars['ID'];
text?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
/** @manyToOne(field: 'comments', key: 'noteId') */
note?: Maybe<Note>;
};
export type CommentFilter = {
id?: Maybe<IdInput>;
text?: Maybe<StringInput>;
description?: Maybe<StringInput>;
noteId?: Maybe<IdInput>;
and?: Maybe<Array<CommentFilter>>;
or?: Maybe<Array<CommentFilter>>;
not?: Maybe<CommentFilter>;
};
export type CommentResultList = {
__typename?: 'CommentResultList';
items: Array<Maybe<Comment>>;
offset?: Maybe<Scalars['Int']>;
limit?: Maybe<Scalars['Int']>;
count?: Maybe<Scalars['Int']>;
};
export type CommentSubscriptionFilter = {
id?: Maybe<Scalars['ID']>;
text?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
};
export type CreateCommentInput = {
id?: Maybe<Scalars['ID']>;
text?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
noteId?: Maybe<Scalars['ID']>;
};
export type CreateNoteInput = {
id?: Maybe<Scalars['ID']>;
title: Scalars['String'];
description?: Maybe<Scalars['String']>;
};
export type IdInput = {
ne?: Maybe<Scalars['ID']>;
eq?: Maybe<Scalars['ID']>;
le?: Maybe<Scalars['ID']>;
lt?: Maybe<Scalars['ID']>;
ge?: Maybe<Scalars['ID']>;
gt?: Maybe<Scalars['ID']>;
in?: Maybe<Array<Scalars['ID']>>;
};
export type MutateCommentInput = {
id: Scalars['ID'];
text?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
noteId?: Maybe<Scalars['ID']>;
};
export type MutateNoteInput = {
id: Scalars['ID'];
title?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
};
export type Mutation = {
__typename?: 'Mutation';
createNote?: Maybe<Note>;
updateNote?: Maybe<Note>;
deleteNote?: Maybe<Note>;
createComment?: Maybe<Comment>;
updateComment?: Maybe<Comment>;
deleteComment?: Maybe<Comment>;
};
export type MutationCreateNoteArgs = {
input: CreateNoteInput;
};
export type MutationUpdateNoteArgs = {
input: MutateNoteInput;
};
export type MutationDeleteNoteArgs = {
input: MutateNoteInput;
};
export type MutationCreateCommentArgs = {
input: CreateCommentInput;
};
export type MutationUpdateCommentArgs = {
input: MutateCommentInput;
};
export type MutationDeleteCommentArgs = {
input: MutateCommentInput;
};
/** @model */
export type Note = {
__typename?: 'Note';
id: Scalars['ID'];
title: Scalars['String'];
description?: Maybe<Scalars['String']>;
/** @oneToMany(field: 'note', key: 'noteId') */
comments: Array<Maybe<Comment>>;
};
/** @model */
export type NoteCommentsArgs = {
filter?: Maybe<CommentFilter>;
};
export type NoteFilter = {
id?: Maybe<IdInput>;
title?: Maybe<StringInput>;
description?: Maybe<StringInput>;
and?: Maybe<Array<NoteFilter>>;
or?: Maybe<Array<NoteFilter>>;
not?: Maybe<NoteFilter>;
};
export type NoteResultList = {
__typename?: 'NoteResultList';
items: Array<Maybe<Note>>;
offset?: Maybe<Scalars['Int']>;
limit?: Maybe<Scalars['Int']>;
count?: Maybe<Scalars['Int']>;
};
export type NoteSubscriptionFilter = {
id?: Maybe<Scalars['ID']>;
title?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
};
export type OrderByInput = {
field: Scalars['String'];
order?: Maybe<SortDirectionEnum>;
};
export type PageRequest = {
limit?: Maybe<Scalars['Int']>;
offset?: Maybe<Scalars['Int']>;
};
export type Query = {
__typename?: 'Query';
getNote?: Maybe<Note>;
findNotes: NoteResultList;
getComment?: Maybe<Comment>;
findComments: CommentResultList;
};
export type QueryGetNoteArgs = {
id: Scalars['ID'];
};
export type QueryFindNotesArgs = {
filter?: Maybe<NoteFilter>;
page?: Maybe<PageRequest>;
orderBy?: Maybe<OrderByInput>;
};
export type QueryGetCommentArgs = {
id: Scalars['ID'];
};
export type QueryFindCommentsArgs = {
filter?: Maybe<CommentFilter>;
page?: Maybe<PageRequest>;
orderBy?: Maybe<OrderByInput>;
};
export enum SortDirectionEnum {
Desc = 'DESC',
Asc = 'ASC'
}
export type StringInput = {
ne?: Maybe<Scalars['String']>;
eq?: Maybe<Scalars['String']>;
le?: Maybe<Scalars['String']>;
lt?: Maybe<Scalars['String']>;
ge?: Maybe<Scalars['String']>;
gt?: Maybe<Scalars['String']>;
in?: Maybe<Array<Scalars['String']>>;
contains?: Maybe<Scalars['String']>;
startsWith?: Maybe<Scalars['String']>;
endsWith?: Maybe<Scalars['String']>;
};
export type Subscription = {
__typename?: 'Subscription';
newNote: Note;
updatedNote: Note;
deletedNote: Note;
newComment: Comment;
updatedComment: Comment;
deletedComment: Comment;
};
export type SubscriptionNewNoteArgs = {
filter?: Maybe<NoteSubscriptionFilter>;
};
export type SubscriptionUpdatedNoteArgs = {
filter?: Maybe<NoteSubscriptionFilter>;
};
export type SubscriptionDeletedNoteArgs = {
filter?: Maybe<NoteSubscriptionFilter>;
};
export type SubscriptionNewCommentArgs = {
filter?: Maybe<CommentSubscriptionFilter>;
};
export type SubscriptionUpdatedCommentArgs = {
filter?: Maybe<CommentSubscriptionFilter>;
};
export type SubscriptionDeletedCommentArgs = {
filter?: Maybe<CommentSubscriptionFilter>;
};
export type NoteFieldsFragment = (
{ __typename?: 'Note' }
& Pick<Note, 'id' | 'title' | 'description'>
);
export type NoteExpandedFieldsFragment = (
{ __typename?: 'Note' }
& Pick<Note, 'id' | 'title' | 'description'>
& { comments: Array<Maybe<(
{ __typename?: 'Comment' }
& Pick<Comment, 'id' | 'text' | 'description'>
)>> }
);
export type CommentFieldsFragment = (
{ __typename?: 'Comment' }
& Pick<Comment, 'id' | 'text' | 'description'>
);
export type CommentExpandedFieldsFragment = (
{ __typename?: 'Comment' }
& Pick<Comment, 'id' | 'text' | 'description'>
& { note?: Maybe<(
{ __typename?: 'Note' }
& Pick<Note, 'id' | 'title' | 'description'>
)> }
);
export type FindNotesQueryVariables = Exact<{
filter?: Maybe<NoteFilter>;
page?: Maybe<PageRequest>;
orderBy?: Maybe<OrderByInput>;
}>;
export type FindNotesQuery = (
{ __typename?: 'Query' }
& { findNotes: (
{ __typename?: 'NoteResultList' }
& Pick<NoteResultList, 'offset' | 'limit' | 'count'>
& { items: Array<Maybe<(
{ __typename?: 'Note' }
& NoteExpandedFieldsFragment
)>> }
) }
);
export type GetNoteQueryVariables = Exact<{
id: Scalars['ID'];
}>;
export type GetNoteQuery = (
{ __typename?: 'Query' }
& { getNote?: Maybe<(
{ __typename?: 'Note' }
& NoteExpandedFieldsFragment
)> }
);
export type FindCommentsQueryVariables = Exact<{
filter?: Maybe<CommentFilter>;
page?: Maybe<PageRequest>;
orderBy?: Maybe<OrderByInput>;
}>;
export type FindCommentsQuery = (
{ __typename?: 'Query' }
& { findComments: (
{ __typename?: 'CommentResultList' }
& Pick<CommentResultList, 'offset' | 'limit' | 'count'>
& { items: Array<Maybe<(
{ __typename?: 'Comment' }
& CommentExpandedFieldsFragment
)>> }
) }
);
export type GetCommentQueryVariables = Exact<{
id: Scalars['ID'];
}>;
export type GetCommentQuery = (
{ __typename?: 'Query' }
& { getComment?: Maybe<(
{ __typename?: 'Comment' }
& CommentExpandedFieldsFragment
)> }
);
export type CreateNoteMutationVariables = Exact<{
input: CreateNoteInput;
}>;
export type CreateNoteMutation = (
{ __typename?: 'Mutation' }
& { createNote?: Maybe<(
{ __typename?: 'Note' }
& NoteFieldsFragment
)> }
);
export type UpdateNoteMutationVariables = Exact<{
input: MutateNoteInput;
}>;
export type UpdateNoteMutation = (
{ __typename?: 'Mutation' }
& { updateNote?: Maybe<(
{ __typename?: 'Note' }
& NoteFieldsFragment
)> }
);
export type DeleteNoteMutationVariables = Exact<{
input: MutateNoteInput;
}>;
export type DeleteNoteMutation = (
{ __typename?: 'Mutation' }
& { deleteNote?: Maybe<(
{ __typename?: 'Note' }
& NoteFieldsFragment
)> }
);
export type CreateCommentMutationVariables = Exact<{
input: CreateCommentInput;
}>;
export type CreateCommentMutation = (
{ __typename?: 'Mutation' }
& { createComment?: Maybe<(
{ __typename?: 'Comment' }
& CommentFieldsFragment
)> }
);
export type UpdateCommentMutationVariables = Exact<{
input: MutateCommentInput;
}>;
export type UpdateCommentMutation = (
{ __typename?: 'Mutation' }
& { updateComment?: Maybe<(
{ __typename?: 'Comment' }
& CommentFieldsFragment
)> }
);
export type DeleteCommentMutationVariables = Exact<{
input: MutateCommentInput;
}>;
export type DeleteCommentMutation = (
{ __typename?: 'Mutation' }
& { deleteComment?: Maybe<(
{ __typename?: 'Comment' }
& CommentFieldsFragment
)> }
);
export type NewNoteSubscriptionVariables = Exact<{
filter?: Maybe<NoteSubscriptionFilter>;
}>;
export type NewNoteSubscription = (
{ __typename?: 'Subscription' }
& { newNote: (
{ __typename?: 'Note' }
& NoteFieldsFragment
) }
);
export type UpdatedNoteSubscriptionVariables = Exact<{
filter?: Maybe<NoteSubscriptionFilter>;
}>;
export type UpdatedNoteSubscription = (
{ __typename?: 'Subscription' }
& { updatedNote: (
{ __typename?: 'Note' }
& NoteFieldsFragment
) }
);
export type DeletedNoteSubscriptionVariables = Exact<{
filter?: Maybe<NoteSubscriptionFilter>;
}>;
export type DeletedNoteSubscription = (
{ __typename?: 'Subscription' }
& { deletedNote: (
{ __typename?: 'Note' }
& NoteFieldsFragment
) }
);
export type NewCommentSubscriptionVariables = Exact<{
filter?: Maybe<CommentSubscriptionFilter>;
}>;
export type NewCommentSubscription = (
{ __typename?: 'Subscription' }
& { newComment: (
{ __typename?: 'Comment' }
& CommentFieldsFragment
) }
);
export type UpdatedCommentSubscriptionVariables = Exact<{
filter?: Maybe<CommentSubscriptionFilter>;
}>;
export type UpdatedCommentSubscription = (
{ __typename?: 'Subscription' }
& { updatedComment: (
{ __typename?: 'Comment' }
& CommentFieldsFragment
) }
);
export type DeletedCommentSubscriptionVariables = Exact<{
filter?: Maybe<CommentSubscriptionFilter>;
}>;
export type DeletedCommentSubscription = (
{ __typename?: 'Subscription' }
& { deletedComment: (
{ __typename?: 'Comment' }
& CommentFieldsFragment
) }
);
export const NoteFieldsFragmentDoc = gql`
fragment NoteFields on Note {
id
title
description
}
`;
export const NoteExpandedFieldsFragmentDoc = gql`
fragment NoteExpandedFields on Note {
id
title
description
comments {
id
text
description
}
}
`;
export const CommentFieldsFragmentDoc = gql`
fragment CommentFields on Comment {
id
text
description
}
`;
export const CommentExpandedFieldsFragmentDoc = gql`
fragment CommentExpandedFields on Comment {
id
text
description
note {
id
title
description
}
}
`;
export const FindNotesDocument = gql`
query findNotes($filter: NoteFilter, $page: PageRequest, $orderBy: OrderByInput) {
findNotes(filter: $filter, page: $page, orderBy: $orderBy) {
items {
...NoteExpandedFields
}
offset
limit
count
}
}
${NoteExpandedFieldsFragmentDoc}`;
/**
* __useFindNotesQuery__
*
* To run a query within a React component, call `useFindNotesQuery` and pass it any options that fit your needs.
* When your component renders, `useFindNotesQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useFindNotesQuery({
* variables: {
* filter: // value for 'filter'
* page: // value for 'page'
* orderBy: // value for 'orderBy'
* },
* });
*/
export function useFindNotesQuery(baseOptions?: ApolloReactHooks.QueryHookOptions<FindNotesQuery, FindNotesQueryVariables>) {
return ApolloReactHooks.useQuery<FindNotesQuery, FindNotesQueryVariables>(FindNotesDocument, baseOptions);
}
export function useFindNotesLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<FindNotesQuery, FindNotesQueryVariables>) {
return ApolloReactHooks.useLazyQuery<FindNotesQuery, FindNotesQueryVariables>(FindNotesDocument, baseOptions);
}
export type FindNotesQueryHookResult = ReturnType<typeof useFindNotesQuery>;
export type FindNotesLazyQueryHookResult = ReturnType<typeof useFindNotesLazyQuery>;
export type FindNotesQueryResult = ApolloReactCommon.QueryResult<FindNotesQuery, FindNotesQueryVariables>;
export const GetNoteDocument = gql`
query getNote($id: ID!) {
getNote(id: $id) {
...NoteExpandedFields
}
}
${NoteExpandedFieldsFragmentDoc}`;
/**
* __useGetNoteQuery__
*
* To run a query within a React component, call `useGetNoteQuery` and pass it any options that fit your needs.
* When your component renders, `useGetNoteQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useGetNoteQuery({
* variables: {
* id: // value for 'id'
* },
* });
*/
export function useGetNoteQuery(baseOptions?: ApolloReactHooks.QueryHookOptions<GetNoteQuery, GetNoteQueryVariables>) {
return ApolloReactHooks.useQuery<GetNoteQuery, GetNoteQueryVariables>(GetNoteDocument, baseOptions);
}
export function useGetNoteLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<GetNoteQuery, GetNoteQueryVariables>) {
return ApolloReactHooks.useLazyQuery<GetNoteQuery, GetNoteQueryVariables>(GetNoteDocument, baseOptions);
}
export type GetNoteQueryHookResult = ReturnType<typeof useGetNoteQuery>;
export type GetNoteLazyQueryHookResult = ReturnType<typeof useGetNoteLazyQuery>;
export type GetNoteQueryResult = ApolloReactCommon.QueryResult<GetNoteQuery, GetNoteQueryVariables>;
export const FindCommentsDocument = gql`
query findComments($filter: CommentFilter, $page: PageRequest, $orderBy: OrderByInput) {
findComments(filter: $filter, page: $page, orderBy: $orderBy) {
items {
...CommentExpandedFields
}
offset
limit
count
}
}
${CommentExpandedFieldsFragmentDoc}`;
/**
* __useFindCommentsQuery__
*
* To run a query within a React component, call `useFindCommentsQuery` and pass it any options that fit your needs.
* When your component renders, `useFindCommentsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useFindCommentsQuery({
* variables: {
* filter: // value for 'filter'
* page: // value for 'page'
* orderBy: // value for 'orderBy'
* },
* });
*/
export function useFindCommentsQuery(baseOptions?: ApolloReactHooks.QueryHookOptions<FindCommentsQuery, FindCommentsQueryVariables>) {
return ApolloReactHooks.useQuery<FindCommentsQuery, FindCommentsQueryVariables>(FindCommentsDocument, baseOptions);
}
export function useFindCommentsLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<FindCommentsQuery, FindCommentsQueryVariables>) {
return ApolloReactHooks.useLazyQuery<FindCommentsQuery, FindCommentsQueryVariables>(FindCommentsDocument, baseOptions);
}
export type FindCommentsQueryHookResult = ReturnType<typeof useFindCommentsQuery>;
export type FindCommentsLazyQueryHookResult = ReturnType<typeof useFindCommentsLazyQuery>;
export type FindCommentsQueryResult = ApolloReactCommon.QueryResult<FindCommentsQuery, FindCommentsQueryVariables>;
export const GetCommentDocument = gql`
query getComment($id: ID!) {
getComment(id: $id) {
...CommentExpandedFields
}
}
${CommentExpandedFieldsFragmentDoc}`;
/**
* __useGetCommentQuery__
*
* To run a query within a React component, call `useGetCommentQuery` and pass it any options that fit your needs.
* When your component renders, `useGetCommentQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useGetCommentQuery({
* variables: {
* id: // value for 'id'
* },
* });
*/
export function useGetCommentQuery(baseOptions?: ApolloReactHooks.QueryHookOptions<GetCommentQuery, GetCommentQueryVariables>) {
return ApolloReactHooks.useQuery<GetCommentQuery, GetCommentQueryVariables>(GetCommentDocument, baseOptions);
}
export function useGetCommentLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<GetCommentQuery, GetCommentQueryVariables>) {
return ApolloReactHooks.useLazyQuery<GetCommentQuery, GetCommentQueryVariables>(GetCommentDocument, baseOptions);
}
export type GetCommentQueryHookResult = ReturnType<typeof useGetCommentQuery>;
export type GetCommentLazyQueryHookResult = ReturnType<typeof useGetCommentLazyQuery>;
export type GetCommentQueryResult = ApolloReactCommon.QueryResult<GetCommentQuery, GetCommentQueryVariables>;
export const CreateNoteDocument = gql`
mutation createNote($input: CreateNoteInput!) {
createNote(input: $input) {
...NoteFields
}
}
${NoteFieldsFragmentDoc}`;
export type CreateNoteMutationFn = ApolloReactCommon.MutationFunction<CreateNoteMutation, CreateNoteMutationVariables>;
/**
* __useCreateNoteMutation__
*
* To run a mutation, you first call `useCreateNoteMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useCreateNoteMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [createNoteMutation, { data, loading, error }] = useCreateNoteMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useCreateNoteMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<CreateNoteMutation, CreateNoteMutationVariables>) {
return ApolloReactHooks.useMutation<CreateNoteMutation, CreateNoteMutationVariables>(CreateNoteDocument, baseOptions);
}
export type CreateNoteMutationHookResult = ReturnType<typeof useCreateNoteMutation>;
export type CreateNoteMutationResult = ApolloReactCommon.MutationResult<CreateNoteMutation>;
export type CreateNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<CreateNoteMutation, CreateNoteMutationVariables>;
export const UpdateNoteDocument = gql`
mutation updateNote($input: MutateNoteInput!) {
updateNote(input: $input) {
...NoteFields
}
}
${NoteFieldsFragmentDoc}`;
export type UpdateNoteMutationFn = ApolloReactCommon.MutationFunction<UpdateNoteMutation, UpdateNoteMutationVariables>;
/**
* __useUpdateNoteMutation__
*
* To run a mutation, you first call `useUpdateNoteMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useUpdateNoteMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [updateNoteMutation, { data, loading, error }] = useUpdateNoteMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useUpdateNoteMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<UpdateNoteMutation, UpdateNoteMutationVariables>) {
return ApolloReactHooks.useMutation<UpdateNoteMutation, UpdateNoteMutationVariables>(UpdateNoteDocument, baseOptions);
}
export type UpdateNoteMutationHookResult = ReturnType<typeof useUpdateNoteMutation>;
export type UpdateNoteMutationResult = ApolloReactCommon.MutationResult<UpdateNoteMutation>;
export type UpdateNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<UpdateNoteMutation, UpdateNoteMutationVariables>;
export const DeleteNoteDocument = gql`
mutation deleteNote($input: MutateNoteInput!) {
deleteNote(input: $input) {
...NoteFields
}
}
${NoteFieldsFragmentDoc}`;
export type DeleteNoteMutationFn = ApolloReactCommon.MutationFunction<DeleteNoteMutation, DeleteNoteMutationVariables>;
/**
* __useDeleteNoteMutation__
*
* To run a mutation, you first call `useDeleteNoteMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useDeleteNoteMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [deleteNoteMutation, { data, loading, error }] = useDeleteNoteMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useDeleteNoteMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<DeleteNoteMutation, DeleteNoteMutationVariables>) {
return ApolloReactHooks.useMutation<DeleteNoteMutation, DeleteNoteMutationVariables>(DeleteNoteDocument, baseOptions);
}
export type DeleteNoteMutationHookResult = ReturnType<typeof useDeleteNoteMutation>;
export type DeleteNoteMutationResult = ApolloReactCommon.MutationResult<DeleteNoteMutation>;
export type DeleteNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<DeleteNoteMutation, DeleteNoteMutationVariables>;
export const CreateCommentDocument = gql`
mutation createComment($input: CreateCommentInput!) {
createComment(input: $input) {
...CommentFields
}
}
${CommentFieldsFragmentDoc}`;
export type CreateCommentMutationFn = ApolloReactCommon.MutationFunction<CreateCommentMutation, CreateCommentMutationVariables>;
/**
* __useCreateCommentMutation__
*
* To run a mutation, you first call `useCreateCommentMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useCreateCommentMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [createCommentMutation, { data, loading, error }] = useCreateCommentMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useCreateCommentMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<CreateCommentMutation, CreateCommentMutationVariables>) {
return ApolloReactHooks.useMutation<CreateCommentMutation, CreateCommentMutationVariables>(CreateCommentDocument, baseOptions);
}
export type CreateCommentMutationHookResult = ReturnType<typeof useCreateCommentMutation>;
export type CreateCommentMutationResult = ApolloReactCommon.MutationResult<CreateCommentMutation>;
export type CreateCommentMutationOptions = ApolloReactCommon.BaseMutationOptions<CreateCommentMutation, CreateCommentMutationVariables>;
export const UpdateCommentDocument = gql`
mutation updateComment($input: MutateCommentInput!) {
updateComment(input: $input) {
...CommentFields
}
}
${CommentFieldsFragmentDoc}`;
export type UpdateCommentMutationFn = ApolloReactCommon.MutationFunction<UpdateCommentMutation, UpdateCommentMutationVariables>;
/**
* __useUpdateCommentMutation__
*
* To run a mutation, you first call `useUpdateCommentMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useUpdateCommentMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [updateCommentMutation, { data, loading, error }] = useUpdateCommentMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useUpdateCommentMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<UpdateCommentMutation, UpdateCommentMutationVariables>) {
return ApolloReactHooks.useMutation<UpdateCommentMutation, UpdateCommentMutationVariables>(UpdateCommentDocument, baseOptions);
}
export type UpdateCommentMutationHookResult = ReturnType<typeof useUpdateCommentMutation>;
export type UpdateCommentMutationResult = ApolloReactCommon.MutationResult<UpdateCommentMutation>;
export type UpdateCommentMutationOptions = ApolloReactCommon.BaseMutationOptions<UpdateCommentMutation, UpdateCommentMutationVariables>;
export const DeleteCommentDocument = gql`
mutation deleteComment($input: MutateCommentInput!) {
deleteComment(input: $input) {
...CommentFields
}
}
${CommentFieldsFragmentDoc}`;
export type DeleteCommentMutationFn = ApolloReactCommon.MutationFunction<DeleteCommentMutation, DeleteCommentMutationVariables>;
/**
* __useDeleteCommentMutation__
*
* To run a mutation, you first call `useDeleteCommentMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useDeleteCommentMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [deleteCommentMutation, { data, loading, error }] = useDeleteCommentMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useDeleteCommentMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<DeleteCommentMutation, DeleteCommentMutationVariables>) {
return ApolloReactHooks.useMutation<DeleteCommentMutation, DeleteCommentMutationVariables>(DeleteCommentDocument, baseOptions);
}
export type DeleteCommentMutationHookResult = ReturnType<typeof useDeleteCommentMutation>;
export type DeleteCommentMutationResult = ApolloReactCommon.MutationResult<DeleteCommentMutation>;
export type DeleteCommentMutationOptions = ApolloReactCommon.BaseMutationOptions<DeleteCommentMutation, DeleteCommentMutationVariables>;
export const NewNoteDocument = gql`
subscription newNote($filter: NoteSubscriptionFilter) {
newNote(filter: $filter) {
...NoteFields
}
}
${NoteFieldsFragmentDoc}`;
/**
* __useNewNoteSubscription__
*
* To run a query within a React component, call `useNewNoteSubscription` and pass it any options that fit your needs.
* When your component renders, `useNewNoteSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useNewNoteSubscription({
* variables: {
* filter: // value for 'filter'
* },
* });
*/
export function useNewNoteSubscription(baseOptions?: ApolloReactHooks.SubscriptionHookOptions<NewNoteSubscription, NewNoteSubscriptionVariables>) {
return ApolloReactHooks.useSubscription<NewNoteSubscription, NewNoteSubscriptionVariables>(NewNoteDocument, baseOptions);
}
export type NewNoteSubscriptionHookResult = ReturnType<typeof useNewNoteSubscription>;
export type NewNoteSubscriptionResult = ApolloReactCommon.SubscriptionResult<NewNoteSubscription>;
export const UpdatedNoteDocument = gql`
subscription updatedNote($filter: NoteSubscriptionFilter) {
updatedNote(filter: $filter) {
...NoteFields
}
}
${NoteFieldsFragmentDoc}`;
/**
* __useUpdatedNoteSubscription__
*
* To run a query within a React component, call `useUpdatedNoteSubscription` and pass it any options that fit your needs.
* When your component renders, `useUpdatedNoteSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useUpdatedNoteSubscription({
* variables: {
* filter: // value for 'filter'
* },
* });
*/
export function useUpdatedNoteSubscription(baseOptions?: ApolloReactHooks.SubscriptionHookOptions<UpdatedNoteSubscription, UpdatedNoteSubscriptionVariables>) {
return ApolloReactHooks.useSubscription<UpdatedNoteSubscription, UpdatedNoteSubscriptionVariables>(UpdatedNoteDocument, baseOptions);
}
export type UpdatedNoteSubscriptionHookResult = ReturnType<typeof useUpdatedNoteSubscription>;
export type UpdatedNoteSubscriptionResult = ApolloReactCommon.SubscriptionResult<UpdatedNoteSubscription>;
export const DeletedNoteDocument = gql`
subscription deletedNote($filter: NoteSubscriptionFilter) {
deletedNote(filter: $filter) {
...NoteFields
}
}
${NoteFieldsFragmentDoc}`;
/**
* __useDeletedNoteSubscription__
*
* To run a query within a React component, call `useDeletedNoteSubscription` and pass it any options that fit your needs.
* When your component renders, `useDeletedNoteSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useDeletedNoteSubscription({
* variables: {
* filter: // value for 'filter'
* },
* });
*/
export function useDeletedNoteSubscription(baseOptions?: ApolloReactHooks.SubscriptionHookOptions<DeletedNoteSubscription, DeletedNoteSubscriptionVariables>) {
return ApolloReactHooks.useSubscription<DeletedNoteSubscription, DeletedNoteSubscriptionVariables>(DeletedNoteDocument, baseOptions);
}
export type DeletedNoteSubscriptionHookResult = ReturnType<typeof useDeletedNoteSubscription>;
export type DeletedNoteSubscriptionResult = ApolloReactCommon.SubscriptionResult<DeletedNoteSubscription>;
export const NewCommentDocument = gql`
subscription newComment($filter: CommentSubscriptionFilter) {
newComment(filter: $filter) {
...CommentFields
}
}
${CommentFieldsFragmentDoc}`;
/**
* __useNewCommentSubscription__
*
* To run a query within a React component, call `useNewCommentSubscription` and pass it any options that fit your needs.
* When your component renders, `useNewCommentSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useNewCommentSubscription({
* variables: {
* filter: // value for 'filter'
* },
* });
*/
export function useNewCommentSubscription(baseOptions?: ApolloReactHooks.SubscriptionHookOptions<NewCommentSubscription, NewCommentSubscriptionVariables>) {
return ApolloReactHooks.useSubscription<NewCommentSubscription, NewCommentSubscriptionVariables>(NewCommentDocument, baseOptions);
}
export type NewCommentSubscriptionHookResult = ReturnType<typeof useNewCommentSubscription>;
export type NewCommentSubscriptionResult = ApolloReactCommon.SubscriptionResult<NewCommentSubscription>;
export const UpdatedCommentDocument = gql`
subscription updatedComment($filter: CommentSubscriptionFilter) {
updatedComment(filter: $filter) {
...CommentFields
}
}
${CommentFieldsFragmentDoc}`;
/**
* __useUpdatedCommentSubscription__
*
* To run a query within a React component, call `useUpdatedCommentSubscription` and pass it any options that fit your needs.
* When your component renders, `useUpdatedCommentSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useUpdatedCommentSubscription({
* variables: {
* filter: // value for 'filter'
* },
* });
*/
export function useUpdatedCommentSubscription(baseOptions?: ApolloReactHooks.SubscriptionHookOptions<UpdatedCommentSubscription, UpdatedCommentSubscriptionVariables>) {
return ApolloReactHooks.useSubscription<UpdatedCommentSubscription, UpdatedCommentSubscriptionVariables>(UpdatedCommentDocument, baseOptions);
}
export type UpdatedCommentSubscriptionHookResult = ReturnType<typeof useUpdatedCommentSubscription>;
export type UpdatedCommentSubscriptionResult = ApolloReactCommon.SubscriptionResult<UpdatedCommentSubscription>;
export const DeletedCommentDocument = gql`
subscription deletedComment($filter: CommentSubscriptionFilter) {
deletedComment(filter: $filter) {
...CommentFields
}
}
${CommentFieldsFragmentDoc}`;
/**
* __useDeletedCommentSubscription__
*
* To run a query within a React component, call `useDeletedCommentSubscription` and pass it any options that fit your needs.
* When your component renders, `useDeletedCommentSubscription` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useDeletedCommentSubscription({
* variables: {
* filter: // value for 'filter'
* },
* });
*/
export function useDeletedCommentSubscription(baseOptions?: ApolloReactHooks.SubscriptionHookOptions<DeletedCommentSubscription, DeletedCommentSubscriptionVariables>) {
return ApolloReactHooks.useSubscription<DeletedCommentSubscription, DeletedCommentSubscriptionVariables>(DeletedCommentDocument, baseOptions);
}
export type DeletedCommentSubscriptionHookResult = ReturnType<typeof useDeletedCommentSubscription>;
export type DeletedCommentSubscriptionResult = ApolloReactCommon.SubscriptionResult<DeletedCommentSubscription>;
================================================
FILE: templates/fullstack/client/src/graphql/graphback.graphql
================================================
fragment NoteFields on Note {
id
title
description
}
fragment NoteExpandedFields on Note {
id
title
description
comments {
id
text
description
}
}
fragment CommentFields on Comment {
id
text
description
}
fragment CommentExpandedFields on Comment {
id
text
description
note {
id
title
description
}
}
query findNotes($filter: NoteFilter, $page: PageRequest, $orderBy: OrderByInput) {
findNotes(filter: $filter, page: $page, orderBy: $orderBy) {
items {
...NoteExpandedFields
}
offset
limit
count
}
}
query getNote($id: ID!) {
getNote(id: $id) {
...NoteExpandedFields
}
}
query findComments($filter: CommentFilter, $page: PageRequest, $orderBy: OrderByInput) {
findComments(filter: $filter, page: $page, orderBy: $orderBy) {
items {
...CommentExpandedFields
}
offset
limit
count
}
}
query getComment($id: ID!) {
getComment(id: $id) {
...CommentExpandedFields
}
}
mutation createNote($input: CreateNoteInput!) {
createNote(input: $input) {
...NoteFields
}
}
mutation updateNote($input: MutateNoteInput!) {
updateNote(input: $input) {
...NoteFields
}
}
mutation deleteNote($input: MutateNoteInput!) {
deleteNote(input: $input) {
...NoteFields
}
}
mutation createComment($input: CreateCommentInput!) {
createComment(input: $input) {
...CommentFields
}
}
mutation updateComment($input: MutateCommentInput!) {
updateComment(input: $input) {
...CommentFields
}
}
mutation deleteComment($input: MutateCommentInput!) {
deleteComment(input: $input) {
...CommentFields
}
}
subscription newNote($filter: NoteSubscriptionFilter) {
newNote(filter: $filter) {
...NoteFields
}
}
subscription updatedNote($filter: NoteSubscriptionFilter) {
updatedNote(filter: $filter) {
...NoteFields
}
}
subscription deletedNote($filter: NoteSubscriptionFilter) {
deletedNote(filter: $filter) {
...NoteFields
}
}
subscription newComment($filter: CommentSubscriptionFilter) {
newComment(filter: $filter) {
...CommentFields
}
}
subscription updatedComment($filter: CommentSubscriptionFilter) {
updatedComment(filter: $filter) {
...CommentFields
}
}
subscription deletedComment($filter: CommentSubscriptionFilter) {
deletedComment(filter: $filter) {
...CommentFields
}
}
================================================
FILE: templates/fullstack/client/src/index.css
================================================
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
================================================
FILE: templates/fullstack/client/src/index.tsx
================================================
import { ApolloProvider } from '@apollo/react-hooks';
import ApolloClient from 'apollo-boost';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
import * as serviceWorker from './serviceWorker';
const apolloClient = new ApolloClient({
uri: 'http://localhost:4000/graphql',
});
ReactDOM.render(
<ApolloProvider client={apolloClient}>
<App />
</ApolloProvider>,
document.getElementById('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
================================================
FILE: templates/fullstack/client/src/react-app-env.d.ts
================================================
/// <reference types="react-scripts" />
================================================
FILE: templates/fullstack/client/src/serviceWorker.ts
================================================
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
);
type Config = {
onSuccess?: (registration: ServiceWorkerRegistration) => void;
onUpdate?: (registration: ServiceWorkerRegistration) => void;
};
export function register(config?: Config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL((process as { env: { [key: string]: string } }).env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl: string, config?: Config) {
navigator.serviceWorker
.register(swUrl)
.then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch((error) => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl: string, config?: Config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (response.status === 404 || (contentType != null && contentType.indexOf('javascript') === -1)) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log('No internet connection found. App is running in offline mode.');
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then((registration) => {
registration.unregister();
});
}
}
================================================
FILE: templates/fullstack/client/tsconfig.json
================================================
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"src"
]
}
================================================
FILE: templates/fullstack/docker-compose.yml
================================================
version: '3'
services:
postgres:
image: postgres:9.6
ports:
- "55432:5432"
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgresql
POSTGRES_DB: users
================================================
FILE: templates/fullstack/model/datamodel.graphql
================================================
""" @model """
type Note {
id: ID!
title: String!
description: String
"""
@oneToMany(field: 'note')
"""
comments: [Comment]!
}
""" @model """
type Comment {
id: ID!
text: String
description: String
}
================================================
FILE: templates/fullstack/package.json
================================================
{
"name": "full-stack-template",
"version": "4.1.0",
"private": true,
"workspaces": [
"client",
"server"
],
"scripts": {
"start:server": "cd server/ && yarn start",
"start:client": "cd client/ && yarn start"
},
"license": "MIT",
"devDependencies": {
"@graphql-codegen/add": "2.0.2",
"@graphql-codegen/typescript": "1.23.0",
"@graphql-codegen/typescript-operations": "1.18.4",
"@graphql-codegen/typescript-react-apollo": "2.3.1",
"@graphql-codegen/typescript-resolvers": "1.20.0",
"@graphql-cli/codegen": "1.17.27",
"@graphql-cli/coverage": "2.1.0",
"@graphql-cli/diff": "2.1.0",
"@graphql-cli/generate": "4.1.0",
"@graphql-cli/serve": "4.1.0",
"@graphql-cli/similar": "2.1.0",
"@graphql-cli/validate": "2.1.0",
"graphql": "15.7.2",
"graphql-cli": "4.1.0",
"schemats": "3.0.3",
"tslint": "6.1.3",
"typescript": "4.4.4"
},
"resolutions": {
"graphql": "15.7.2"
},
"author": {
"name": "Arda TANRIKULU"
}
}
================================================
FILE: templates/fullstack/renovate.json
================================================
{
"extends": [
"config:base"
],
"automerge": true,
"major": {
"automerge": false
}
}
================================================
FILE: templates/fullstack/schemats.json
================================================
{
"conn": "postgres://postgresql:postgres@localhost:55432/users",
"output": "server/src/generated-db-types.ts"
}
================================================
FILE: templates/fullstack/server/package.json
================================================
{
"private": true,
"name": "full-stack-template-server",
"version": "4.1.0",
"scripts": {
"develop": "ts-node-dev src/index.ts",
"start": "ts-node src/index.ts"
},
"dependencies": {
"graphback": "1.1.2",
"@graphback/runtime-knex": "1.1.2",
"@graphback/codegen-schema": "1.1.2",
"graphql-migrations": "1.1.2",
"@graphql-tools/load-files": "6.5.2",
"@types/cors": "2.8.12",
"@types/express": "4.17.13",
"@types/node": "13.13.45",
"apollo-server-express": "2.25.3",
"cors": "2.8.5",
"express": "4.17.1",
"graphql": "15.7.2",
"graphql-config": "3.4.1",
"graphql-tag": "2.12.6",
"knex": "0.95.14",
"pg": "8.7.1",
"ts-node": "9.1.1",
"ts-node-dev": "1.1.8",
"typescript": "4.4.4"
}
}
================================================
FILE: templates/fullstack/server/src/db.ts
================================================
import { loadConfig } from 'graphql-config';
import Knex from 'knex';
export const getConfig = async () => {
const config = await loadConfig({
extensions: [() => ({ name: 'dbmigrations' })],
});
if (!config) {
throw new Error('Missing dbmigrations config');
}
const conf = await config.getDefault().extension('dbmigrations');
return conf;
};
/**
* Creates knex based database using migration configuration
* For production use please use different source of the configuration
*/
export const createDB = async () => {
const dbmigrations = await getConfig();
// connect to db
const db = Knex(dbmigrations);
return db as any;
};
================================================
FILE: templates/fullstack/server/src/generated-db-types.ts
================================================
/* tslint:disable */
/**
* AUTO-GENERATED FILE @ 2020-06-03 11:49:44 - DO NOT EDIT!
*
* This file was automatically generated by schemats v.3.0.3
* $ schemats generate -c postgres://username:password@localhost:55432/users -t note -t comment -s public
*
*/
export namespace noteFields {
export type title = string;
export type description = string | null;
export type id = number;
}
export interface note {
title: noteFields.title;
description: noteFields.description;
id: noteFields.id;
}
export namespace commentFields {
export type text = string | null;
export type description = string | null;
export type noteId = number | null;
export type id = number;
}
export interface comment {
text: commentFields.text;
description: commentFields.description;
noteId: commentFields.noteId;
id: commentFields.id;
}
================================================
FILE: templates/fullstack/server/src/generated-types.ts
================================================
/* tslint:disable */
import { GraphQLResolveInfo } from 'graphql';
import { comment, note } from './generated-db-types';
import { GraphbackRuntimeContext } from '@graphback/runtime';
export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: any }> = { [K in keyof T]: T[K] };
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type RequireFields<T, K extends keyof T> = { [X in Exclude<keyof T, K>]?: T[X] } & { [P in K]-?: NonNullable<T[P]> };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
};
/** @model */
export type Comment = {
__typename?: 'Comment';
id: Scalars['ID'];
text?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
/** @manyToOne(field: 'comments', key: 'noteId') */
note?: Maybe<Note>;
};
export type CommentFilter = {
id?: Maybe<IdInput>;
text?: Maybe<StringInput>;
description?: Maybe<StringInput>;
noteId?: Maybe<IdInput>;
and?: Maybe<Array<CommentFilter>>;
or?: Maybe<Array<CommentFilter>>;
not?: Maybe<CommentFilter>;
};
export type CommentResultList = {
__typename?: 'CommentResultList';
items: Array<Maybe<Comment>>;
offset?: Maybe<Scalars['Int']>;
limit?: Maybe<Scalars['Int']>;
count?: Maybe<Scalars['Int']>;
};
export type CommentSubscriptionFilter = {
id?: Maybe<Scalars['ID']>;
text?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
};
export type CreateCommentInput = {
id?: Maybe<Scalars['ID']>;
text?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
noteId?: Maybe<Scalars['ID']>;
};
export type CreateNoteInput = {
id?: Maybe<Scalars['ID']>;
title: Scalars['String'];
description?: Maybe<Scalars['String']>;
};
export type IdInput = {
ne?: Maybe<Scalars['ID']>;
eq?: Maybe<Scalars['ID']>;
le?: Maybe<Scalars['ID']>;
lt?: Maybe<Scalars['ID']>;
ge?: Maybe<Scalars['ID']>;
gt?: Maybe<Scalars['ID']>;
in?: Maybe<Array<Scalars['ID']>>;
};
export type MutateCommentInput = {
id: Scalars['ID'];
text?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
noteId?: Maybe<Scalars['ID']>;
};
export type MutateNoteInput = {
id: Scalars['ID'];
title?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
};
export type Mutation = {
__typename?: 'Mutation';
createNote?: Maybe<Note>;
updateNote?: Maybe<Note>;
deleteNote?: Maybe<Note>;
createComment?: Maybe<Comment>;
updateComment?: Maybe<Comment>;
deleteComment?: Maybe<Comment>;
};
export type MutationCreateNoteArgs = {
input: CreateNoteInput;
};
export type MutationUpdateNoteArgs = {
input: MutateNoteInput;
};
export type MutationDeleteNoteArgs = {
input: MutateNoteInput;
};
export type MutationCreateCommentArgs = {
input: CreateCommentInput;
};
export type MutationUpdateCommentArgs = {
input: MutateCommentInput;
};
export type MutationDeleteCommentArgs = {
input: MutateCommentInput;
};
/** @model */
export type Note = {
__typename?: 'Note';
id: Scalars['ID'];
title: Scalars['String'];
description?: Maybe<Scalars['String']>;
/** @oneToMany(field: 'note', key: 'noteId') */
comments: Array<Maybe<Comment>>;
};
/** @model */
export type NoteCommentsArgs = {
filter?: Maybe<CommentFilter>;
};
export type NoteFilter = {
id?: Maybe<IdInput>;
title?: Maybe<StringInput>;
description?: Maybe<StringInput>;
and?: Maybe<Array<NoteFilter>>;
or?: Maybe<Array<NoteFilter>>;
not?: Maybe<NoteFilter>;
};
export type NoteResultList = {
__typename?: 'NoteResultList';
items: Array<Maybe<Note>>;
offset?: Maybe<Scalars['Int']>;
limit?: Maybe<Scalars['Int']>;
count?: Maybe<Scalars['Int']>;
};
export type NoteSubscriptionFilter = {
id?: Maybe<Scalars['ID']>;
title?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>;
};
export type OrderByInput = {
field: Scalars['String'];
order?: Maybe<SortDirectionEnum>;
};
export type PageRequest = {
limit?: Maybe<Scalars['Int']>;
offset?: Maybe<Scalars['Int']>;
};
export type Query = {
__typename?: 'Query';
getNote?: Maybe<Note>;
findNotes: NoteResultList;
getComment?: Maybe<Comment>;
findComments: CommentResultList;
};
export type QueryGetNoteArgs = {
id: Scalars['ID'];
};
export type QueryFindNotesArgs = {
filter?: Maybe<NoteFilter>;
page?: Maybe<PageRequest>;
orderBy?: Maybe<OrderByInput>;
};
export type QueryGetCommentArgs = {
id: Scalars['ID'];
};
export type QueryFindCommentsArgs = {
filter?: Maybe<CommentFilter>;
page?: Maybe<PageRequest>;
orderBy?: Maybe<OrderByInput>;
};
export enum SortDirectionEnum {
Desc = 'DESC',
Asc = 'ASC'
}
export type StringInput = {
ne?: Maybe<Scalars['String']>;
eq?: Maybe<Scalars['String']>;
le?: Maybe<Scalars['String']>;
lt?: Maybe<Scalars['String']>;
ge?: Maybe<Scalars['String']>;
gt?: Maybe<Scalars['String']>;
in?: Maybe<Array<Scalars['String']>>;
contains?: Maybe<Scalars['String']>;
startsWith?: Maybe<Scalars['String']>;
endsWith?: Maybe<Scalars['String']>;
};
export type Subscription = {
__typename?: 'Subscription';
newNote: Note;
updatedNote: Note;
deletedNote: Note;
newComment: Comment;
updatedComment: Comment;
deletedComment: Comment;
};
export type SubscriptionNewNoteArgs = {
filter?: Maybe<NoteSubscriptionFilter>;
};
export type SubscriptionUpdatedNoteArgs = {
filter?: Maybe<NoteSubscriptionFilter>;
};
export type SubscriptionDeletedNoteArgs = {
filter?: Maybe<NoteSubscriptionFilter>;
};
export type SubscriptionNewCommentArgs = {
filter?: Maybe<CommentSubscriptionFilter>;
};
export type SubscriptionUpdatedCommentArgs = {
filter?: Maybe<CommentSubscriptionFilter>;
};
export type SubscriptionDeletedCommentArgs = {
filter?: Maybe<CommentSubscriptionFilter>;
};
export type WithIndex<TObject> = TObject & Record<string, any>;
export type ResolversObject<TObject> = WithIndex<TObject>;
export type ResolverTypeWrapper<T> = Promise<T> | T;
export type LegacyStitchingResolver<TResult, TParent, TContext, TArgs> = {
fragment: string;
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
};
export type NewStitchingResolver<TResult, TParent, TContext, TArgs> = {
selectionSet: string;
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
};
export type StitchingResolver<TResult, TParent, TContext, TArgs> = LegacyStitchingResolver<TResult, TParent, TContext, TArgs> | NewStitchingResolver<TResult, TParent, TContext, TArgs>;
export type Resolver<TResult, TParent = {}, TContext = {}, TArgs = {}> =
| ResolverFn<TResult, TParent, TContext, TArgs>
| StitchingResolver<TResult, TParent, TContext, TArgs>;
export type ResolverFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => Promise<TResult> | TResult;
export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;
export interface SubscriptionSubscriberObject<TResult, TKey extends string, TParent, TContext, TArgs> {
subscribe: SubscriptionSubscribeFn<{ [key in TKey]: TResult }, TParent, TContext, TArgs>;
resolve?: SubscriptionResolveFn<TResult, { [key in TKey]: TResult }, TContext, TArgs>;
}
export interface SubscriptionResolverObject<TResult, TParent, TContext, TArgs> {
subscribe: SubscriptionSubscribeFn<any, TParent, TContext, TArgs>;
resolve: SubscriptionResolveFn<TResult, any, TContext, TArgs>;
}
export type SubscriptionObject<TResult, TKey extends string, TParent, TContext, TArgs> =
| SubscriptionSubscriberObject<TResult, TKey, TParent, TContext, TArgs>
| SubscriptionResolverObject<TResult, TParent, TContext, TArgs>;
export type SubscriptionResolver<TResult, TKey extends string, TParent = {}, TContext = {}, TArgs = {}> =
| ((...args: any[]) => SubscriptionObject<TResult, TKey, TParent, TContext, TArgs>)
| SubscriptionObject<TResult, TKey, TParent, TContext, TArgs>;
export type TypeResolveFn<TTypes, TParent = {}, TContext = {}> = (
parent: TParent,
context: TContext,
info: GraphQLResolveInfo
) => Maybe<TTypes> | Promise<Maybe<TTypes>>;
export type IsTypeOfResolverFn<T = {}> = (obj: T, info: GraphQLResolveInfo) => boolean | Promise<boolean>;
export type NextResolverFn<T> = () => Promise<T>;
export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs = {}> = (
next: NextResolverFn<TResult>,
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;
/** Mapping between all available schema types and the resolvers types */
export type ResolversTypes = ResolversObject<{
Comment: ResolverTypeWrapper<comment>;
ID: ResolverTypeWrapper<Scalars['ID']>;
String: ResolverTypeWrapper<Scalars['String']>;
CommentFilter: CommentFilter;
CommentResultList: ResolverTypeWrapper<Omit<CommentResultList, 'items'> & { items: Array<Maybe<ResolversTypes['Comment']>> }>;
Int: ResolverTypeWrapper<Scalars['Int']>;
CommentSubscriptionFilter: CommentSubscriptionFilter;
CreateCommentInput: CreateCommentInput;
CreateNoteInput: CreateNoteInput;
IDInput: IdInput;
MutateCommentInput: MutateCommentInput;
MutateNoteInput: MutateNoteInput;
Mutation: ResolverTypeWrapper<{}>;
Note: ResolverTypeWrapper<note>;
NoteFilter: NoteFilter;
NoteResultList: ResolverTypeWrapper<Omit<NoteResultList, 'items'> & { items: Array<Maybe<ResolversTypes['Note']>> }>;
Note
gitextract_ex53v_nb/
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ └── workflows/
│ ├── algolia-integrity.yml
│ ├── algolia-publish.yml
│ ├── main.yml
│ └── website.yml
├── .gitignore
├── .npmrc
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── docs/
│ ├── CUSTOM_EXTENSION.md
│ └── MIGRATION.md
├── integration/
│ ├── package.json
│ ├── test-project/
│ │ ├── .dockerignore
│ │ ├── .gitignore
│ │ ├── .graphqlrc.yml
│ │ ├── package.json
│ │ ├── renovate.json
│ │ ├── schema/
│ │ │ └── schema.graphql
│ │ ├── tsconfig.json
│ │ └── tslint.json
│ ├── tests/
│ │ └── workflow.ts
│ └── tsconfig.json
├── lerna.json
├── package.json
├── packages/
│ ├── cli/
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── CONTRIBUTING.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src/
│ │ │ ├── bin.ts
│ │ │ ├── discover.ts
│ │ │ └── index.ts
│ │ └── tsconfig.json
│ ├── commands/
│ │ ├── generate/
│ │ │ ├── .gitignore
│ │ │ ├── README.md
│ │ │ ├── package.json
│ │ │ ├── src/
│ │ │ │ └── index.ts
│ │ │ └── tsconfig.json
│ │ ├── init/
│ │ │ ├── .gitignore
│ │ │ ├── .npmignore
│ │ │ ├── README.md
│ │ │ ├── package.json
│ │ │ ├── src/
│ │ │ │ ├── common.ts
│ │ │ │ ├── features/
│ │ │ │ │ ├── codegen.ts
│ │ │ │ │ └── inspector.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── search-codegen-config.ts
│ │ │ │ └── sources/
│ │ │ │ ├── from-existing.ts
│ │ │ │ ├── from-open-api.ts
│ │ │ │ └── from-scratch.ts
│ │ │ └── tsconfig.json
│ │ └── serve/
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src/
│ │ │ └── index.ts
│ │ └── tsconfig.json
│ ├── common/
│ │ ├── .gitignore
│ │ ├── .npmignore
│ │ ├── package.json
│ │ ├── src/
│ │ │ ├── command.ts
│ │ │ ├── index.ts
│ │ │ └── types.ts
│ │ └── tsconfig.json
│ └── loaders/
│ ├── .gitignore
│ ├── .npmignore
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── renovate.json
├── scripts/
│ ├── introspect-config.js
│ └── release.js
├── templates/
│ └── fullstack/
│ ├── .dockerignore
│ ├── .gitignore
│ ├── .graphqlrc.yml
│ ├── Dockerfile
│ ├── README.md
│ ├── client/
│ │ ├── .gitignore
│ │ ├── generated-types.tsx
│ │ ├── package.json
│ │ ├── public/
│ │ │ ├── index.html
│ │ │ ├── manifest.json
│ │ │ └── robots.txt
│ │ ├── src/
│ │ │ ├── App.css
│ │ │ ├── App.test.tsx
│ │ │ ├── App.tsx
│ │ │ ├── components/
│ │ │ │ ├── comment/
│ │ │ │ │ ├── Comment.css
│ │ │ │ │ ├── CreateComment.tsx
│ │ │ │ │ └── OneComment.tsx
│ │ │ │ └── notes/
│ │ │ │ ├── CreateNote.tsx
│ │ │ │ ├── EditNote.tsx
│ │ │ │ ├── Note.css
│ │ │ │ └── OneNote.tsx
│ │ │ ├── generated-types.tsx
│ │ │ ├── graphql/
│ │ │ │ └── graphback.graphql
│ │ │ ├── index.css
│ │ │ ├── index.tsx
│ │ │ ├── react-app-env.d.ts
│ │ │ └── serviceWorker.ts
│ │ └── tsconfig.json
│ ├── docker-compose.yml
│ ├── model/
│ │ └── datamodel.graphql
│ ├── package.json
│ ├── renovate.json
│ ├── schemats.json
│ ├── server/
│ │ ├── package.json
│ │ ├── src/
│ │ │ ├── db.ts
│ │ │ ├── generated-db-types.ts
│ │ │ ├── generated-types.ts
│ │ │ ├── graphql.ts
│ │ │ ├── index.ts
│ │ │ └── schema/
│ │ │ └── schema.graphql
│ │ └── tsconfig.json
│ └── tslint.json
├── templates.json
└── website/
├── .gitignore
├── README.md
├── algolia-lockfile.json
├── babel.config.js
├── docs/
│ ├── codegen.md
│ ├── coverage.md
│ ├── custom-commands.md
│ ├── diff.md
│ ├── discover.md
│ ├── generate.md
│ ├── init.md
│ ├── introduction.md
│ ├── introspect.md
│ ├── migration.md
│ ├── serve.md
│ ├── similar.md
│ └── validate.md
├── docusaurus.config.js
├── package.json
├── scripts/
│ └── algolia-ci.ts
├── sidebars.js
├── src/
│ ├── css/
│ │ └── custom.css
│ ├── pages/
│ │ ├── index.js
│ │ └── styles.module.css
│ └── theme/
│ └── Root.js
└── static/
├── CNAME
└── js/
└── light-mode-by-default.js
SYMBOL INDEX (402 symbols across 25 files)
FILE: packages/cli/src/discover.ts
method handler (line 8) | handler() {
FILE: packages/cli/src/index.ts
function cli (line 7) | async function cli(): Promise<void> {
function discoverCommands (line 29) | async function discoverCommands() {
function loadCommand (line 52) | function loadCommand(name: string): CommandFactory {
FILE: packages/commands/generate/src/index.ts
method builder (line 7) | builder(builder: any) {
FILE: packages/commands/init/src/common.ts
type StandardEnum (line 7) | type StandardEnum<T> = {
function askForEnum (line 12) | async function askForEnum<T, Enum extends StandardEnum<T>>(options: {
type Context (line 38) | interface Context {
type InitializationType (line 45) | enum InitializationType {
type ProjectType (line 51) | enum ProjectType {
type FrontendType (line 57) | enum FrontendType {
type BackendType (line 67) | enum BackendType {
type PackageManifest (line 74) | type PackageManifest = ReturnType<typeof managePackageManifest>;
function managePackageManifest (line 75) | function managePackageManifest() {
FILE: packages/commands/init/src/features/codegen.ts
function askForCodegen (line 4) | async function askForCodegen({ context, project }: { context: Context; p...
FILE: packages/commands/init/src/features/inspector.ts
function askForInspector (line 4) | async function askForInspector({ context, project }: { context: Context;...
FILE: packages/commands/init/src/index.ts
method builder (line 24) | builder(yargs) {
method handler (line 40) | async handler(args) {
function askForProject (line 113) | function askForProject() {
function askForInitializationType (line 121) | function askForInitializationType() {
function loadGraphQLConfig (line 130) | function loadGraphQLConfig(context: Context) {
function askForSchema (line 142) | async function askForSchema(context: Context) {
function askForDocuments (line 163) | async function askForDocuments(context: Context) {
function writeGraphQLConfig (line 179) | async function writeGraphQLConfig(context: Context) {
FILE: packages/commands/init/src/search-codegen-config.ts
function generateSearchPlaces (line 4) | function generateSearchPlaces(moduleName: string) {
function customLoader (line 14) | function customLoader(ext: 'json' | 'yaml' | 'js') {
function searchCodegenConfig (line 36) | async function searchCodegenConfig(cwd: string) {
FILE: packages/commands/init/src/sources/from-existing.ts
function fromExisting (line 8) | async function fromExisting({ context, project }: { context: Context; pr...
FILE: packages/commands/init/src/sources/from-open-api.ts
function fromExistingOpenAPI (line 7) | async function fromExistingOpenAPI(context: Context) {
FILE: packages/commands/init/src/sources/from-scratch.ts
function fromScratch (line 6) | async function fromScratch({
FILE: packages/common/src/command.ts
type CommandFactory (line 7) | type CommandFactory<T = {}, U = {}> = (api: {
function defineCommand (line 12) | function defineCommand<T = {}, U = {}>(factory: CommandFactory<T, U>) {
function useConfig (line 16) | function useConfig(options: LoadConfigOptions = {}) {
type PointerOf (line 25) | type PointerOf<T extends (...args: any) => any> = Parameters<T>[0];
type OptionsOf (line 26) | type OptionsOf<T extends (...args: any) => any> = Omit<Parameters<T>[1],...
function useLoaders (line 28) | function useLoaders({ loaders }: { loaders: Loader[] }) {
FILE: packages/common/src/types.ts
type LoadConfigOptions (line 3) | type LoadConfigOptions = Partial<Parameters<typeof loadConfig>[0]>;
FILE: scripts/introspect-config.js
function main (line 8) | async function main() {
FILE: scripts/release.js
function release (line 9) | async function release() {
FILE: templates/fullstack/client/generated-types.tsx
type Maybe (line 5) | type Maybe<T> = T | null;
type Scalars (line 8) | type Scalars = {
type Comment (line 17) | type Comment = {
type CommentInput (line 26) | type CommentInput = {
type Mutation (line 33) | type Mutation = {
type MutationCreateNoteArgs (line 43) | type MutationCreateNoteArgs = {
type MutationUpdateNoteArgs (line 47) | type MutationUpdateNoteArgs = {
type MutationDeleteNoteArgs (line 51) | type MutationDeleteNoteArgs = {
type MutationCreateCommentArgs (line 55) | type MutationCreateCommentArgs = {
type MutationUpdateCommentArgs (line 59) | type MutationUpdateCommentArgs = {
type MutationDeleteCommentArgs (line 63) | type MutationDeleteCommentArgs = {
type Note (line 68) | type Note = {
type NoteInput (line 77) | type NoteInput = {
type Query (line 83) | type Query = {
type QueryFindAllNotesArgs (line 91) | type QueryFindAllNotesArgs = {
type QueryFindNotesArgs (line 96) | type QueryFindNotesArgs = {
type QueryFindAllCommentsArgs (line 102) | type QueryFindAllCommentsArgs = {
type QueryFindCommentsArgs (line 107) | type QueryFindCommentsArgs = {
type Subscription (line 113) | type Subscription = {
type SubscriptionNewNoteArgs (line 123) | type SubscriptionNewNoteArgs = {
type SubscriptionUpdatedNoteArgs (line 127) | type SubscriptionUpdatedNoteArgs = {
type SubscriptionDeletedNoteArgs (line 131) | type SubscriptionDeletedNoteArgs = {
type SubscriptionNewCommentArgs (line 135) | type SubscriptionNewCommentArgs = {
type SubscriptionUpdatedCommentArgs (line 139) | type SubscriptionUpdatedCommentArgs = {
type SubscriptionDeletedCommentArgs (line 143) | type SubscriptionDeletedCommentArgs = {
type CommentFieldsFragment (line 147) | type CommentFieldsFragment = { __typename?: 'Comment' } & Pick<Comment, ...
type CommentExpandedFieldsFragment (line 149) | type CommentExpandedFieldsFragment = { __typename?: 'Comment' } & Pick<
type NoteFieldsFragment (line 154) | type NoteFieldsFragment = { __typename?: 'Note' } & Pick<Note, 'id' | 't...
type NoteExpandedFieldsFragment (line 156) | type NoteExpandedFieldsFragment = { __typename?: 'Note' } & Pick<Note, '...
type CreateCommentMutationVariables (line 160) | type CreateCommentMutationVariables = {
type CreateCommentMutation (line 164) | type CreateCommentMutation = { __typename?: 'Mutation' } & {
type CreateNoteMutationVariables (line 168) | type CreateNoteMutationVariables = {
type CreateNoteMutation (line 172) | type CreateNoteMutation = { __typename?: 'Mutation' } & {
type DeleteCommentMutationVariables (line 176) | type DeleteCommentMutationVariables = {
type DeleteCommentMutation (line 180) | type DeleteCommentMutation = { __typename?: 'Mutation' } & {
type DeleteNoteMutationVariables (line 184) | type DeleteNoteMutationVariables = {
type DeleteNoteMutation (line 188) | type DeleteNoteMutation = { __typename?: 'Mutation' } & {
type UpdateCommentMutationVariables (line 192) | type UpdateCommentMutationVariables = {
type UpdateCommentMutation (line 196) | type UpdateCommentMutation = { __typename?: 'Mutation' } & {
type UpdateNoteMutationVariables (line 200) | type UpdateNoteMutationVariables = {
type UpdateNoteMutation (line 204) | type UpdateNoteMutation = { __typename?: 'Mutation' } & {
type FindAllCommentsQueryVariables (line 208) | type FindAllCommentsQueryVariables = {
type FindAllCommentsQuery (line 213) | type FindAllCommentsQuery = { __typename?: 'Query' } & {
type FindAllNotesQueryVariables (line 217) | type FindAllNotesQueryVariables = {
type FindAllNotesQuery (line 222) | type FindAllNotesQuery = { __typename?: 'Query' } & {
type FindCommentsQueryVariables (line 226) | type FindCommentsQueryVariables = {
type FindCommentsQuery (line 232) | type FindCommentsQuery = { __typename?: 'Query' } & {
type FindNotesQueryVariables (line 236) | type FindNotesQueryVariables = {
type FindNotesQuery (line 242) | type FindNotesQuery = { __typename?: 'Query' } & {
type DeletedCommentSubscriptionVariables (line 246) | type DeletedCommentSubscriptionVariables = {};
type DeletedCommentSubscription (line 248) | type DeletedCommentSubscription = { __typename?: 'Subscription' } & {
type DeletedNoteSubscriptionVariables (line 252) | type DeletedNoteSubscriptionVariables = {};
type DeletedNoteSubscription (line 254) | type DeletedNoteSubscription = { __typename?: 'Subscription' } & {
type NewCommentSubscriptionVariables (line 258) | type NewCommentSubscriptionVariables = {};
type NewCommentSubscription (line 260) | type NewCommentSubscription = { __typename?: 'Subscription' } & {
type NewNoteSubscriptionVariables (line 264) | type NewNoteSubscriptionVariables = {};
type NewNoteSubscription (line 266) | type NewNoteSubscription = { __typename?: 'Subscription' } & {
type UpdatedCommentSubscriptionVariables (line 270) | type UpdatedCommentSubscriptionVariables = {};
type UpdatedCommentSubscription (line 272) | type UpdatedCommentSubscription = { __typename?: 'Subscription' } & {
type UpdatedNoteSubscriptionVariables (line 276) | type UpdatedNoteSubscriptionVariables = {};
type UpdatedNoteSubscription (line 278) | type UpdatedNoteSubscription = { __typename?: 'Subscription' } & {
type CreateCommentMutationFn (line 328) | type CreateCommentMutationFn = ApolloReactCommon.MutationFunction<
function useCreateCommentMutation (line 350) | function useCreateCommentMutation(
type CreateCommentMutationHookResult (line 358) | type CreateCommentMutationHookResult = ReturnType<typeof useCreateCommen...
type CreateCommentMutationResult (line 359) | type CreateCommentMutationResult = ApolloReactCommon.MutationResult<Crea...
type CreateCommentMutationOptions (line 360) | type CreateCommentMutationOptions = ApolloReactCommon.BaseMutationOptions<
type CreateNoteMutationFn (line 372) | type CreateNoteMutationFn = ApolloReactCommon.MutationFunction<CreateNot...
function useCreateNoteMutation (line 391) | function useCreateNoteMutation(
type CreateNoteMutationHookResult (line 396) | type CreateNoteMutationHookResult = ReturnType<typeof useCreateNoteMutat...
type CreateNoteMutationResult (line 397) | type CreateNoteMutationResult = ApolloReactCommon.MutationResult<CreateN...
type CreateNoteMutationOptions (line 398) | type CreateNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<
type DeleteCommentMutationFn (line 410) | type DeleteCommentMutationFn = ApolloReactCommon.MutationFunction<
function useDeleteCommentMutation (line 432) | function useDeleteCommentMutation(
type DeleteCommentMutationHookResult (line 440) | type DeleteCommentMutationHookResult = ReturnType<typeof useDeleteCommen...
type DeleteCommentMutationResult (line 441) | type DeleteCommentMutationResult = ApolloReactCommon.MutationResult<Dele...
type DeleteCommentMutationOptions (line 442) | type DeleteCommentMutationOptions = ApolloReactCommon.BaseMutationOptions<
type DeleteNoteMutationFn (line 454) | type DeleteNoteMutationFn = ApolloReactCommon.MutationFunction<DeleteNot...
function useDeleteNoteMutation (line 473) | function useDeleteNoteMutation(
type DeleteNoteMutationHookResult (line 478) | type DeleteNoteMutationHookResult = ReturnType<typeof useDeleteNoteMutat...
type DeleteNoteMutationResult (line 479) | type DeleteNoteMutationResult = ApolloReactCommon.MutationResult<DeleteN...
type DeleteNoteMutationOptions (line 480) | type DeleteNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<
type UpdateCommentMutationFn (line 492) | type UpdateCommentMutationFn = ApolloReactCommon.MutationFunction<
function useUpdateCommentMutation (line 514) | function useUpdateCommentMutation(
type UpdateCommentMutationHookResult (line 522) | type UpdateCommentMutationHookResult = ReturnType<typeof useUpdateCommen...
type UpdateCommentMutationResult (line 523) | type UpdateCommentMutationResult = ApolloReactCommon.MutationResult<Upda...
type UpdateCommentMutationOptions (line 524) | type UpdateCommentMutationOptions = ApolloReactCommon.BaseMutationOptions<
type UpdateNoteMutationFn (line 536) | type UpdateNoteMutationFn = ApolloReactCommon.MutationFunction<UpdateNot...
function useUpdateNoteMutation (line 555) | function useUpdateNoteMutation(
type UpdateNoteMutationHookResult (line 560) | type UpdateNoteMutationHookResult = ReturnType<typeof useUpdateNoteMutat...
type UpdateNoteMutationResult (line 561) | type UpdateNoteMutationResult = ApolloReactCommon.MutationResult<UpdateN...
type UpdateNoteMutationOptions (line 562) | type UpdateNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<
function useFindAllCommentsQuery (line 592) | function useFindAllCommentsQuery(
function useFindAllCommentsLazyQuery (line 600) | function useFindAllCommentsLazyQuery(
type FindAllCommentsQueryHookResult (line 608) | type FindAllCommentsQueryHookResult = ReturnType<typeof useFindAllCommen...
type FindAllCommentsLazyQueryHookResult (line 609) | type FindAllCommentsLazyQueryHookResult = ReturnType<typeof useFindAllCo...
type FindAllCommentsQueryResult (line 610) | type FindAllCommentsQueryResult = ApolloReactCommon.QueryResult<
function useFindAllNotesQuery (line 640) | function useFindAllNotesQuery(
function useFindAllNotesLazyQuery (line 645) | function useFindAllNotesLazyQuery(
type FindAllNotesQueryHookResult (line 653) | type FindAllNotesQueryHookResult = ReturnType<typeof useFindAllNotesQuery>;
type FindAllNotesLazyQueryHookResult (line 654) | type FindAllNotesLazyQueryHookResult = ReturnType<typeof useFindAllNotes...
type FindAllNotesQueryResult (line 655) | type FindAllNotesQueryResult = ApolloReactCommon.QueryResult<FindAllNote...
function useFindCommentsQuery (line 683) | function useFindCommentsQuery(
function useFindCommentsLazyQuery (line 688) | function useFindCommentsLazyQuery(
type FindCommentsQueryHookResult (line 696) | type FindCommentsQueryHookResult = ReturnType<typeof useFindCommentsQuery>;
type FindCommentsLazyQueryHookResult (line 697) | type FindCommentsLazyQueryHookResult = ReturnType<typeof useFindComments...
type FindCommentsQueryResult (line 698) | type FindCommentsQueryResult = ApolloReactCommon.QueryResult<FindComment...
function useFindNotesQuery (line 726) | function useFindNotesQuery(
function useFindNotesLazyQuery (line 731) | function useFindNotesLazyQuery(
type FindNotesQueryHookResult (line 736) | type FindNotesQueryHookResult = ReturnType<typeof useFindNotesQuery>;
type FindNotesLazyQueryHookResult (line 737) | type FindNotesLazyQueryHookResult = ReturnType<typeof useFindNotesLazyQu...
type FindNotesQueryResult (line 738) | type FindNotesQueryResult = ApolloReactCommon.QueryResult<FindNotesQuery...
function useDeletedCommentSubscription (line 763) | function useDeletedCommentSubscription(
type DeletedCommentSubscriptionHookResult (line 774) | type DeletedCommentSubscriptionHookResult = ReturnType<typeof useDeleted...
type DeletedCommentSubscriptionResult (line 775) | type DeletedCommentSubscriptionResult = ApolloReactCommon.SubscriptionRe...
function useDeletedNoteSubscription (line 800) | function useDeletedNoteSubscription(
type DeletedNoteSubscriptionHookResult (line 808) | type DeletedNoteSubscriptionHookResult = ReturnType<typeof useDeletedNot...
type DeletedNoteSubscriptionResult (line 809) | type DeletedNoteSubscriptionResult = ApolloReactCommon.SubscriptionResul...
function useNewCommentSubscription (line 834) | function useNewCommentSubscription(
type NewCommentSubscriptionHookResult (line 842) | type NewCommentSubscriptionHookResult = ReturnType<typeof useNewCommentS...
type NewCommentSubscriptionResult (line 843) | type NewCommentSubscriptionResult = ApolloReactCommon.SubscriptionResult...
function useNewNoteSubscription (line 868) | function useNewNoteSubscription(
type NewNoteSubscriptionHookResult (line 876) | type NewNoteSubscriptionHookResult = ReturnType<typeof useNewNoteSubscri...
type NewNoteSubscriptionResult (line 877) | type NewNoteSubscriptionResult = ApolloReactCommon.SubscriptionResult<Ne...
function useUpdatedCommentSubscription (line 902) | function useUpdatedCommentSubscription(
type UpdatedCommentSubscriptionHookResult (line 913) | type UpdatedCommentSubscriptionHookResult = ReturnType<typeof useUpdated...
type UpdatedCommentSubscriptionResult (line 914) | type UpdatedCommentSubscriptionResult = ApolloReactCommon.SubscriptionRe...
function useUpdatedNoteSubscription (line 939) | function useUpdatedNoteSubscription(
type UpdatedNoteSubscriptionHookResult (line 947) | type UpdatedNoteSubscriptionHookResult = ReturnType<typeof useUpdatedNot...
type UpdatedNoteSubscriptionResult (line 948) | type UpdatedNoteSubscriptionResult = ApolloReactCommon.SubscriptionResul...
FILE: templates/fullstack/client/src/components/comment/CreateComment.tsx
type createCommentProps (line 6) | type createCommentProps = {
FILE: templates/fullstack/client/src/components/notes/EditNote.tsx
type noteProps (line 6) | type noteProps = {
FILE: templates/fullstack/client/src/generated-types.tsx
type Maybe (line 5) | type Maybe<T> = T | null;
type Exact (line 6) | type Exact<T extends { [key: string]: any }> = { [K in keyof T]: T[K] };
type Scalars (line 9) | type Scalars = {
type Comment (line 18) | type Comment = {
type CommentFilter (line 27) | type CommentFilter = {
type CommentResultList (line 37) | type CommentResultList = {
type CommentSubscriptionFilter (line 45) | type CommentSubscriptionFilter = {
type CreateCommentInput (line 51) | type CreateCommentInput = {
type CreateNoteInput (line 58) | type CreateNoteInput = {
type IdInput (line 64) | type IdInput = {
type MutateCommentInput (line 74) | type MutateCommentInput = {
type MutateNoteInput (line 81) | type MutateNoteInput = {
type Mutation (line 87) | type Mutation = {
type MutationCreateNoteArgs (line 98) | type MutationCreateNoteArgs = {
type MutationUpdateNoteArgs (line 103) | type MutationUpdateNoteArgs = {
type MutationDeleteNoteArgs (line 108) | type MutationDeleteNoteArgs = {
type MutationCreateCommentArgs (line 113) | type MutationCreateCommentArgs = {
type MutationUpdateCommentArgs (line 118) | type MutationUpdateCommentArgs = {
type MutationDeleteCommentArgs (line 123) | type MutationDeleteCommentArgs = {
type Note (line 128) | type Note = {
type NoteCommentsArgs (line 139) | type NoteCommentsArgs = {
type NoteFilter (line 143) | type NoteFilter = {
type NoteResultList (line 152) | type NoteResultList = {
type NoteSubscriptionFilter (line 160) | type NoteSubscriptionFilter = {
type OrderByInput (line 166) | type OrderByInput = {
type PageRequest (line 171) | type PageRequest = {
type Query (line 176) | type Query = {
type QueryGetNoteArgs (line 185) | type QueryGetNoteArgs = {
type QueryFindNotesArgs (line 190) | type QueryFindNotesArgs = {
type QueryGetCommentArgs (line 197) | type QueryGetCommentArgs = {
type QueryFindCommentsArgs (line 202) | type QueryFindCommentsArgs = {
type SortDirectionEnum (line 208) | enum SortDirectionEnum {
type StringInput (line 213) | type StringInput = {
type Subscription (line 226) | type Subscription = {
type SubscriptionNewNoteArgs (line 237) | type SubscriptionNewNoteArgs = {
type SubscriptionUpdatedNoteArgs (line 242) | type SubscriptionUpdatedNoteArgs = {
type SubscriptionDeletedNoteArgs (line 247) | type SubscriptionDeletedNoteArgs = {
type SubscriptionNewCommentArgs (line 252) | type SubscriptionNewCommentArgs = {
type SubscriptionUpdatedCommentArgs (line 257) | type SubscriptionUpdatedCommentArgs = {
type SubscriptionDeletedCommentArgs (line 262) | type SubscriptionDeletedCommentArgs = {
type NoteFieldsFragment (line 266) | type NoteFieldsFragment = (
type NoteExpandedFieldsFragment (line 271) | type NoteExpandedFieldsFragment = (
type CommentFieldsFragment (line 280) | type CommentFieldsFragment = (
type CommentExpandedFieldsFragment (line 285) | type CommentExpandedFieldsFragment = (
type FindNotesQueryVariables (line 294) | type FindNotesQueryVariables = Exact<{
type FindNotesQuery (line 301) | type FindNotesQuery = (
type GetNoteQueryVariables (line 313) | type GetNoteQueryVariables = Exact<{
type GetNoteQuery (line 318) | type GetNoteQuery = (
type FindCommentsQueryVariables (line 326) | type FindCommentsQueryVariables = Exact<{
type FindCommentsQuery (line 333) | type FindCommentsQuery = (
type GetCommentQueryVariables (line 345) | type GetCommentQueryVariables = Exact<{
type GetCommentQuery (line 350) | type GetCommentQuery = (
type CreateNoteMutationVariables (line 358) | type CreateNoteMutationVariables = Exact<{
type CreateNoteMutation (line 363) | type CreateNoteMutation = (
type UpdateNoteMutationVariables (line 371) | type UpdateNoteMutationVariables = Exact<{
type UpdateNoteMutation (line 376) | type UpdateNoteMutation = (
type DeleteNoteMutationVariables (line 384) | type DeleteNoteMutationVariables = Exact<{
type DeleteNoteMutation (line 389) | type DeleteNoteMutation = (
type CreateCommentMutationVariables (line 397) | type CreateCommentMutationVariables = Exact<{
type CreateCommentMutation (line 402) | type CreateCommentMutation = (
type UpdateCommentMutationVariables (line 410) | type UpdateCommentMutationVariables = Exact<{
type UpdateCommentMutation (line 415) | type UpdateCommentMutation = (
type DeleteCommentMutationVariables (line 423) | type DeleteCommentMutationVariables = Exact<{
type DeleteCommentMutation (line 428) | type DeleteCommentMutation = (
type NewNoteSubscriptionVariables (line 436) | type NewNoteSubscriptionVariables = Exact<{
type NewNoteSubscription (line 441) | type NewNoteSubscription = (
type UpdatedNoteSubscriptionVariables (line 449) | type UpdatedNoteSubscriptionVariables = Exact<{
type UpdatedNoteSubscription (line 454) | type UpdatedNoteSubscription = (
type DeletedNoteSubscriptionVariables (line 462) | type DeletedNoteSubscriptionVariables = Exact<{
type DeletedNoteSubscription (line 467) | type DeletedNoteSubscription = (
type NewCommentSubscriptionVariables (line 475) | type NewCommentSubscriptionVariables = Exact<{
type NewCommentSubscription (line 480) | type NewCommentSubscription = (
type UpdatedCommentSubscriptionVariables (line 488) | type UpdatedCommentSubscriptionVariables = Exact<{
type UpdatedCommentSubscription (line 493) | type UpdatedCommentSubscription = (
type DeletedCommentSubscriptionVariables (line 501) | type DeletedCommentSubscriptionVariables = Exact<{
type DeletedCommentSubscription (line 506) | type DeletedCommentSubscription = (
function useFindNotesQuery (line 583) | function useFindNotesQuery(baseOptions?: ApolloReactHooks.QueryHookOptio...
function useFindNotesLazyQuery (line 586) | function useFindNotesLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryH...
type FindNotesQueryHookResult (line 589) | type FindNotesQueryHookResult = ReturnType<typeof useFindNotesQuery>;
type FindNotesLazyQueryHookResult (line 590) | type FindNotesLazyQueryHookResult = ReturnType<typeof useFindNotesLazyQu...
type FindNotesQueryResult (line 591) | type FindNotesQueryResult = ApolloReactCommon.QueryResult<FindNotesQuery...
function useGetNoteQuery (line 616) | function useGetNoteQuery(baseOptions?: ApolloReactHooks.QueryHookOptions...
function useGetNoteLazyQuery (line 619) | function useGetNoteLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHoo...
type GetNoteQueryHookResult (line 622) | type GetNoteQueryHookResult = ReturnType<typeof useGetNoteQuery>;
type GetNoteLazyQueryHookResult (line 623) | type GetNoteLazyQueryHookResult = ReturnType<typeof useGetNoteLazyQuery>;
type GetNoteQueryResult (line 624) | type GetNoteQueryResult = ApolloReactCommon.QueryResult<GetNoteQuery, Ge...
function useFindCommentsQuery (line 656) | function useFindCommentsQuery(baseOptions?: ApolloReactHooks.QueryHookOp...
function useFindCommentsLazyQuery (line 659) | function useFindCommentsLazyQuery(baseOptions?: ApolloReactHooks.LazyQue...
type FindCommentsQueryHookResult (line 662) | type FindCommentsQueryHookResult = ReturnType<typeof useFindCommentsQuery>;
type FindCommentsLazyQueryHookResult (line 663) | type FindCommentsLazyQueryHookResult = ReturnType<typeof useFindComments...
type FindCommentsQueryResult (line 664) | type FindCommentsQueryResult = ApolloReactCommon.QueryResult<FindComment...
function useGetCommentQuery (line 689) | function useGetCommentQuery(baseOptions?: ApolloReactHooks.QueryHookOpti...
function useGetCommentLazyQuery (line 692) | function useGetCommentLazyQuery(baseOptions?: ApolloReactHooks.LazyQuery...
type GetCommentQueryHookResult (line 695) | type GetCommentQueryHookResult = ReturnType<typeof useGetCommentQuery>;
type GetCommentLazyQueryHookResult (line 696) | type GetCommentLazyQueryHookResult = ReturnType<typeof useGetCommentLazy...
type GetCommentQueryResult (line 697) | type GetCommentQueryResult = ApolloReactCommon.QueryResult<GetCommentQue...
type CreateNoteMutationFn (line 705) | type CreateNoteMutationFn = ApolloReactCommon.MutationFunction<CreateNot...
function useCreateNoteMutation (line 724) | function useCreateNoteMutation(baseOptions?: ApolloReactHooks.MutationHo...
type CreateNoteMutationHookResult (line 727) | type CreateNoteMutationHookResult = ReturnType<typeof useCreateNoteMutat...
type CreateNoteMutationResult (line 728) | type CreateNoteMutationResult = ApolloReactCommon.MutationResult<CreateN...
type CreateNoteMutationOptions (line 729) | type CreateNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<C...
type UpdateNoteMutationFn (line 737) | type UpdateNoteMutationFn = ApolloReactCommon.MutationFunction<UpdateNot...
function useUpdateNoteMutation (line 756) | function useUpdateNoteMutation(baseOptions?: ApolloReactHooks.MutationHo...
type UpdateNoteMutationHookResult (line 759) | type UpdateNoteMutationHookResult = ReturnType<typeof useUpdateNoteMutat...
type UpdateNoteMutationResult (line 760) | type UpdateNoteMutationResult = ApolloReactCommon.MutationResult<UpdateN...
type UpdateNoteMutationOptions (line 761) | type UpdateNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<U...
type DeleteNoteMutationFn (line 769) | type DeleteNoteMutationFn = ApolloReactCommon.MutationFunction<DeleteNot...
function useDeleteNoteMutation (line 788) | function useDeleteNoteMutation(baseOptions?: ApolloReactHooks.MutationHo...
type DeleteNoteMutationHookResult (line 791) | type DeleteNoteMutationHookResult = ReturnType<typeof useDeleteNoteMutat...
type DeleteNoteMutationResult (line 792) | type DeleteNoteMutationResult = ApolloReactCommon.MutationResult<DeleteN...
type DeleteNoteMutationOptions (line 793) | type DeleteNoteMutationOptions = ApolloReactCommon.BaseMutationOptions<D...
type CreateCommentMutationFn (line 801) | type CreateCommentMutationFn = ApolloReactCommon.MutationFunction<Create...
function useCreateCommentMutation (line 820) | function useCreateCommentMutation(baseOptions?: ApolloReactHooks.Mutatio...
type CreateCommentMutationHookResult (line 823) | type CreateCommentMutationHookResult = ReturnType<typeof useCreateCommen...
type CreateCommentMutationResult (line 824) | type CreateCommentMutationResult = ApolloReactCommon.MutationResult<Crea...
type CreateCommentMutationOptions (line 825) | type CreateCommentMutationOptions = ApolloReactCommon.BaseMutationOption...
type UpdateCommentMutationFn (line 833) | type UpdateCommentMutationFn = ApolloReactCommon.MutationFunction<Update...
function useUpdateCommentMutation (line 852) | function useUpdateCommentMutation(baseOptions?: ApolloReactHooks.Mutatio...
type UpdateCommentMutationHookResult (line 855) | type UpdateCommentMutationHookResult = ReturnType<typeof useUpdateCommen...
type UpdateCommentMutationResult (line 856) | type UpdateCommentMutationResult = ApolloReactCommon.MutationResult<Upda...
type UpdateCommentMutationOptions (line 857) | type UpdateCommentMutationOptions = ApolloReactCommon.BaseMutationOption...
type DeleteCommentMutationFn (line 865) | type DeleteCommentMutationFn = ApolloReactCommon.MutationFunction<Delete...
function useDeleteCommentMutation (line 884) | function useDeleteCommentMutation(baseOptions?: ApolloReactHooks.Mutatio...
type DeleteCommentMutationHookResult (line 887) | type DeleteCommentMutationHookResult = ReturnType<typeof useDeleteCommen...
type DeleteCommentMutationResult (line 888) | type DeleteCommentMutationResult = ApolloReactCommon.MutationResult<Dele...
type DeleteCommentMutationOptions (line 889) | type DeleteCommentMutationOptions = ApolloReactCommon.BaseMutationOption...
function useNewNoteSubscription (line 914) | function useNewNoteSubscription(baseOptions?: ApolloReactHooks.Subscript...
type NewNoteSubscriptionHookResult (line 917) | type NewNoteSubscriptionHookResult = ReturnType<typeof useNewNoteSubscri...
type NewNoteSubscriptionResult (line 918) | type NewNoteSubscriptionResult = ApolloReactCommon.SubscriptionResult<Ne...
function useUpdatedNoteSubscription (line 943) | function useUpdatedNoteSubscription(baseOptions?: ApolloReactHooks.Subsc...
type UpdatedNoteSubscriptionHookResult (line 946) | type UpdatedNoteSubscriptionHookResult = ReturnType<typeof useUpdatedNot...
type UpdatedNoteSubscriptionResult (line 947) | type UpdatedNoteSubscriptionResult = ApolloReactCommon.SubscriptionResul...
function useDeletedNoteSubscription (line 972) | function useDeletedNoteSubscription(baseOptions?: ApolloReactHooks.Subsc...
type DeletedNoteSubscriptionHookResult (line 975) | type DeletedNoteSubscriptionHookResult = ReturnType<typeof useDeletedNot...
type DeletedNoteSubscriptionResult (line 976) | type DeletedNoteSubscriptionResult = ApolloReactCommon.SubscriptionResul...
function useNewCommentSubscription (line 1001) | function useNewCommentSubscription(baseOptions?: ApolloReactHooks.Subscr...
type NewCommentSubscriptionHookResult (line 1004) | type NewCommentSubscriptionHookResult = ReturnType<typeof useNewCommentS...
type NewCommentSubscriptionResult (line 1005) | type NewCommentSubscriptionResult = ApolloReactCommon.SubscriptionResult...
function useUpdatedCommentSubscription (line 1030) | function useUpdatedCommentSubscription(baseOptions?: ApolloReactHooks.Su...
type UpdatedCommentSubscriptionHookResult (line 1033) | type UpdatedCommentSubscriptionHookResult = ReturnType<typeof useUpdated...
type UpdatedCommentSubscriptionResult (line 1034) | type UpdatedCommentSubscriptionResult = ApolloReactCommon.SubscriptionRe...
function useDeletedCommentSubscription (line 1059) | function useDeletedCommentSubscription(baseOptions?: ApolloReactHooks.Su...
type DeletedCommentSubscriptionHookResult (line 1062) | type DeletedCommentSubscriptionHookResult = ReturnType<typeof useDeleted...
type DeletedCommentSubscriptionResult (line 1063) | type DeletedCommentSubscriptionResult = ApolloReactCommon.SubscriptionRe...
FILE: templates/fullstack/client/src/serviceWorker.ts
type Config (line 21) | type Config = {
function register (line 26) | function register(config?: Config) {
function registerValidSW (line 60) | function registerValidSW(swUrl: string, config?: Config) {
function checkValidServiceWorker (line 104) | function checkValidServiceWorker(swUrl: string, config?: Config) {
function unregister (line 127) | function unregister() {
FILE: templates/fullstack/server/src/generated-db-types.ts
type title (line 12) | type title = string;
type description (line 13) | type description = string | null;
type id (line 14) | type id = number;
type note (line 18) | interface note {
type text (line 26) | type text = string | null;
type description (line 27) | type description = string | null;
type noteId (line 28) | type noteId = number | null;
type id (line 29) | type id = number;
type comment (line 33) | interface comment {
FILE: templates/fullstack/server/src/generated-types.ts
type Maybe (line 5) | type Maybe<T> = T | null;
type Exact (line 6) | type Exact<T extends { [key: string]: any }> = { [K in keyof T]: T[K] };
type Omit (line 7) | type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
type RequireFields (line 8) | type RequireFields<T, K extends keyof T> = { [X in Exclude<keyof T, K>]?...
type Scalars (line 11) | type Scalars = {
type Comment (line 20) | type Comment = {
type CommentFilter (line 29) | type CommentFilter = {
type CommentResultList (line 39) | type CommentResultList = {
type CommentSubscriptionFilter (line 47) | type CommentSubscriptionFilter = {
type CreateCommentInput (line 53) | type CreateCommentInput = {
type CreateNoteInput (line 60) | type CreateNoteInput = {
type IdInput (line 66) | type IdInput = {
type MutateCommentInput (line 76) | type MutateCommentInput = {
type MutateNoteInput (line 83) | type MutateNoteInput = {
type Mutation (line 89) | type Mutation = {
type MutationCreateNoteArgs (line 100) | type MutationCreateNoteArgs = {
type MutationUpdateNoteArgs (line 105) | type MutationUpdateNoteArgs = {
type MutationDeleteNoteArgs (line 110) | type MutationDeleteNoteArgs = {
type MutationCreateCommentArgs (line 115) | type MutationCreateCommentArgs = {
type MutationUpdateCommentArgs (line 120) | type MutationUpdateCommentArgs = {
type MutationDeleteCommentArgs (line 125) | type MutationDeleteCommentArgs = {
type Note (line 130) | type Note = {
type NoteCommentsArgs (line 141) | type NoteCommentsArgs = {
type NoteFilter (line 145) | type NoteFilter = {
type NoteResultList (line 154) | type NoteResultList = {
type NoteSubscriptionFilter (line 162) | type NoteSubscriptionFilter = {
type OrderByInput (line 168) | type OrderByInput = {
type PageRequest (line 173) | type PageRequest = {
type Query (line 178) | type Query = {
type QueryGetNoteArgs (line 187) | type QueryGetNoteArgs = {
type QueryFindNotesArgs (line 192) | type QueryFindNotesArgs = {
type QueryGetCommentArgs (line 199) | type QueryGetCommentArgs = {
type QueryFindCommentsArgs (line 204) | type QueryFindCommentsArgs = {
type SortDirectionEnum (line 210) | enum SortDirectionEnum {
type StringInput (line 215) | type StringInput = {
type Subscription (line 228) | type Subscription = {
type SubscriptionNewNoteArgs (line 239) | type SubscriptionNewNoteArgs = {
type SubscriptionUpdatedNoteArgs (line 244) | type SubscriptionUpdatedNoteArgs = {
type SubscriptionDeletedNoteArgs (line 249) | type SubscriptionDeletedNoteArgs = {
type SubscriptionNewCommentArgs (line 254) | type SubscriptionNewCommentArgs = {
type SubscriptionUpdatedCommentArgs (line 259) | type SubscriptionUpdatedCommentArgs = {
type SubscriptionDeletedCommentArgs (line 264) | type SubscriptionDeletedCommentArgs = {
type WithIndex (line 268) | type WithIndex<TObject> = TObject & Record<string, any>;
type ResolversObject (line 269) | type ResolversObject<TObject> = WithIndex<TObject>;
type ResolverTypeWrapper (line 271) | type ResolverTypeWrapper<T> = Promise<T> | T;
type LegacyStitchingResolver (line 274) | type LegacyStitchingResolver<TResult, TParent, TContext, TArgs> = {
type NewStitchingResolver (line 279) | type NewStitchingResolver<TResult, TParent, TContext, TArgs> = {
type StitchingResolver (line 283) | type StitchingResolver<TResult, TParent, TContext, TArgs> = LegacyStitch...
type Resolver (line 284) | type Resolver<TResult, TParent = {}, TContext = {}, TArgs = {}> =
type ResolverFn (line 288) | type ResolverFn<TResult, TParent, TContext, TArgs> = (
type SubscriptionSubscribeFn (line 295) | type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
type SubscriptionResolveFn (line 302) | type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
type SubscriptionSubscriberObject (line 309) | interface SubscriptionSubscriberObject<TResult, TKey extends string, TPa...
type SubscriptionResolverObject (line 314) | interface SubscriptionResolverObject<TResult, TParent, TContext, TArgs> {
type SubscriptionObject (line 319) | type SubscriptionObject<TResult, TKey extends string, TParent, TContext,...
type SubscriptionResolver (line 323) | type SubscriptionResolver<TResult, TKey extends string, TParent = {}, TC...
type TypeResolveFn (line 327) | type TypeResolveFn<TTypes, TParent = {}, TContext = {}> = (
type IsTypeOfResolverFn (line 333) | type IsTypeOfResolverFn<T = {}> = (obj: T, info: GraphQLResolveInfo) => ...
type NextResolverFn (line 335) | type NextResolverFn<T> = () => Promise<T>;
type DirectiveResolverFn (line 337) | type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArg...
type ResolversTypes (line 346) | type ResolversTypes = ResolversObject<{
type ResolversParentTypes (line 374) | type ResolversParentTypes = ResolversObject<{
type CommentResolvers (line 400) | type CommentResolvers<ContextType = GraphbackRuntimeContext, ParentType ...
type CommentResultListResolvers (line 408) | type CommentResultListResolvers<ContextType = GraphbackRuntimeContext, P...
type MutationResolvers (line 416) | type MutationResolvers<ContextType = GraphbackRuntimeContext, ParentType...
type NoteResolvers (line 425) | type NoteResolvers<ContextType = GraphbackRuntimeContext, ParentType ext...
type NoteResultListResolvers (line 433) | type NoteResultListResolvers<ContextType = GraphbackRuntimeContext, Pare...
type QueryResolvers (line 441) | type QueryResolvers<ContextType = GraphbackRuntimeContext, ParentType ex...
type SubscriptionResolvers (line 448) | type SubscriptionResolvers<ContextType = GraphbackRuntimeContext, Parent...
type Resolvers (line 457) | type Resolvers<ContextType = GraphbackRuntimeContext> = ResolversObject<{
type IResolvers (line 472) | type IResolvers<ContextType = GraphbackRuntimeContext> = Resolvers<Conte...
FILE: templates/fullstack/server/src/index.ts
function start (line 7) | async function start() {
FILE: website/src/pages/index.js
function Home (line 4) | function Home() {
FILE: website/src/theme/Root.js
function Root (line 6) | function Root({ children }) {
Condensed preview — 145 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (261K chars).
[
{
"path": ".github/ISSUE_TEMPLATE/bug_report.md",
"chars": 689,
"preview": "---\nname: Bug report\nabout: Create a report to help us improve\n\n---\n\n**Describe the bug**\nA clear and concise descriptio"
},
{
"path": ".github/ISSUE_TEMPLATE/feature_request.md",
"chars": 560,
"preview": "---\nname: Feature request\nabout: Suggest an idea for this project\n\n---\n\n**Is your feature request related to a problem? "
},
{
"path": ".github/workflows/algolia-integrity.yml",
"chars": 1650,
"preview": "name: Algolia Integrity\non:\n pull_request:\n paths:\n - 'website/**'\njobs:\n algolia-records-check:\n runs-on: "
},
{
"path": ".github/workflows/algolia-publish.yml",
"chars": 1730,
"preview": "name: Algolia Publish\n\non:\n push:\n branches:\n - master\n\njobs:\n algolia-push-records:\n name: Push new record"
},
{
"path": ".github/workflows/main.yml",
"chars": 2241,
"preview": "name: CI\n\non:\n push:\n branches:\n - master\n pull_request:\n branches:\n - master\n release:\n types: [r"
},
{
"path": ".github/workflows/website.yml",
"chars": 1450,
"preview": "name: Website Deployment\non:\n push:\n branches:\n - master\n\njobs:\n deploy-website:\n name: Deploy Website\n "
},
{
"path": ".gitignore",
"chars": 874,
"preview": "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Directo"
},
{
"path": ".npmrc",
"chars": 15,
"preview": "save-exact=true"
},
{
"path": "CONTRIBUTING.md",
"chars": 353,
"preview": "# Contributing guide\n\nWe are using Yarn workspaces, so make sure you have the latest version of Yarn installed.\n\n## Buil"
},
{
"path": "LICENSE",
"chars": 1068,
"preview": "MIT License\n\nCopyright (c) 2019 Dotan Simha\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
},
{
"path": "README.md",
"chars": 6933,
"preview": "# GraphQL CLI\n\n 2019 Dotan Simha\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
},
{
"path": "packages/cli/README.md",
"chars": 191,
"preview": "# GraphQL CLI\n\n;\n"
},
{
"path": "packages/cli/src/discover.ts",
"chars": 322,
"preview": "import { defineCommand } from '@graphql-cli/common';\nimport open from 'open';\n\nexport default defineCommand(() => {\n re"
},
{
"path": "packages/cli/src/index.ts",
"chars": 1494,
"preview": "import yargs from 'yargs';\nimport globby from 'globby';\nimport { join } from 'path';\nimport { CommandFactory, useConfig,"
},
{
"path": "packages/cli/tsconfig.json",
"chars": 634,
"preview": "{\n \"compilerOptions\": {\n \"skipLibCheck\": true,\n \"esModuleInterop\": true,\n \"importHelpers\": true,\n \"experime"
},
{
"path": "packages/commands/generate/.gitignore",
"chars": 67,
"preview": "node_modules\nnpm-debug.log\ndist\ntemp\nyarn-error.log\ntests/coverage/"
},
{
"path": "packages/commands/generate/README.md",
"chars": 198,
"preview": "## GraphQL CLI Generate command\n\nThis package is part of the GraphQL CLI ecosystem and it is not designed to be consumed"
},
{
"path": "packages/commands/generate/package.json",
"chars": 672,
"preview": "{\n \"name\": \"@graphql-cli/generate\",\n \"description\": \"Generate schema and client-side documents for your GraphQL projec"
},
{
"path": "packages/commands/generate/src/index.ts",
"chars": 293,
"preview": "import { defineCommand } from '@graphql-cli/common';\nimport { command, builder as builderConfig, handler } from 'graphba"
},
{
"path": "packages/commands/generate/tsconfig.json",
"chars": 641,
"preview": "{\n \"compilerOptions\": {\n \"skipLibCheck\": true,\n \"esModuleInterop\": true,\n \"importHelpers\": true,\n \"experime"
},
{
"path": "packages/commands/init/.gitignore",
"chars": 67,
"preview": "node_modules\nnpm-debug.log\ndist\ntemp\nyarn-error.log\ntests/coverage/"
},
{
"path": "packages/commands/init/.npmignore",
"chars": 4,
"preview": "src/"
},
{
"path": "packages/commands/init/README.md",
"chars": 194,
"preview": "## GraphQL CLI Init command\n\nThis package is part of the GraphQL CLI ecosystem and it is not designed to be consumed sep"
},
{
"path": "packages/commands/init/package.json",
"chars": 1037,
"preview": "{\n \"name\": \"@graphql-cli/init\",\n \"description\": \"Creates a GraphQL project using a template or GraphQL Config file for"
},
{
"path": "packages/commands/init/src/common.ts",
"chars": 3685,
"preview": "import { join } from 'path';\nimport { ensureFile, writeFileSync } from 'fs-extra';\nimport { prompt } from 'inquirer';\nim"
},
{
"path": "packages/commands/init/src/features/codegen.ts",
"chars": 3830,
"preview": "import { prompt } from 'inquirer';\nimport { Context, PackageManifest, ProjectType, FrontendType, BackendType, askForEnum"
},
{
"path": "packages/commands/init/src/features/inspector.ts",
"chars": 1631,
"preview": "import { prompt } from 'inquirer';\nimport { Context, PackageManifest, ProjectType } from '../common';\n\nexport async func"
},
{
"path": "packages/commands/init/src/index.ts",
"chars": 5526,
"preview": "import { defineCommand } from '@graphql-cli/common';\nimport { prompt } from 'inquirer';\nimport { join } from 'path';\nimp"
},
{
"path": "packages/commands/init/src/search-codegen-config.ts",
"chars": 1430,
"preview": "import { cosmiconfig, defaultLoaders } from 'cosmiconfig';\nimport { env } from 'string-env-interpolation';\n\nfunction gen"
},
{
"path": "packages/commands/init/src/sources/from-existing.ts",
"chars": 1607,
"preview": "import rimraf from 'rimraf';\nimport { join } from 'path';\nimport { existsSync } from 'fs-extra';\nimport { prompt } from "
},
{
"path": "packages/commands/init/src/sources/from-open-api.ts",
"chars": 1492,
"preview": "import ora from 'ora';\nimport { safeLoad as YAMLParse } from 'js-yaml';\nimport { readFileSync, writeFileSync, ensureFile"
},
{
"path": "packages/commands/init/src/sources/from-scratch.ts",
"chars": 710,
"preview": "import { join } from 'path';\nimport { prompt } from 'inquirer';\nimport { Context } from '../common';\nimport { handler } "
},
{
"path": "packages/commands/init/tsconfig.json",
"chars": 672,
"preview": "{\n \"compilerOptions\": {\n \"skipLibCheck\": true,\n \"esModuleInterop\": true,\n \"importHelpers\": true,\n \"experime"
},
{
"path": "packages/commands/serve/.gitignore",
"chars": 67,
"preview": "node_modules\nnpm-debug.log\ndist\ntemp\nyarn-error.log\ntests/coverage/"
},
{
"path": "packages/commands/serve/.npmignore",
"chars": 4,
"preview": "src/"
},
{
"path": "packages/commands/serve/README.md",
"chars": 195,
"preview": "## GraphQL CLI Serve command\n\nThis package is part of the GraphQL CLI ecosystem and it is not designed to be consumed se"
},
{
"path": "packages/commands/serve/package.json",
"chars": 632,
"preview": "{\n \"name\": \"@graphql-cli/serve\",\n \"description\": \"Serves a GraphQL server using an in memory MongoDB\",\n \"version\": \"5"
},
{
"path": "packages/commands/serve/src/index.ts",
"chars": 298,
"preview": "import { defineCommand } from '@graphql-cli/common';\nimport { serve } from 'graphql-serve';\n\nexport default defineComman"
},
{
"path": "packages/commands/serve/tsconfig.json",
"chars": 641,
"preview": "{\n \"compilerOptions\": {\n \"skipLibCheck\": true,\n \"esModuleInterop\": true,\n \"importHelpers\": true,\n \"experime"
},
{
"path": "packages/common/.gitignore",
"chars": 67,
"preview": "node_modules\nnpm-debug.log\ndist\ntemp\nyarn-error.log\ntests/coverage/"
},
{
"path": "packages/common/.npmignore",
"chars": 4,
"preview": "src/"
},
{
"path": "packages/common/package.json",
"chars": 359,
"preview": "{\n \"name\": \"@graphql-cli/common\",\n \"version\": \"5.0.0\",\n \"license\": \"MIT\",\n \"main\": \"dist/index.js\",\n \"publishConfig"
},
{
"path": "packages/common/src/command.ts",
"chars": 1298,
"preview": "import { CommandModule } from 'yargs';\nimport { loadConfig, GraphQLConfig } from 'graphql-config';\nimport { loadDocument"
},
{
"path": "packages/common/src/index.ts",
"chars": 52,
"preview": "export * from './types';\nexport * from './command';\n"
},
{
"path": "packages/common/src/types.ts",
"chars": 121,
"preview": "import { loadConfig } from 'graphql-config';\n\nexport type LoadConfigOptions = Partial<Parameters<typeof loadConfig>[0]>;"
},
{
"path": "packages/common/tsconfig.json",
"chars": 612,
"preview": "{\n \"compilerOptions\": {\n \"skipLibCheck\": true,\n \"importHelpers\": true,\n \"experimentalDecorators\": true,\n \"m"
},
{
"path": "packages/loaders/.gitignore",
"chars": 67,
"preview": "node_modules\nnpm-debug.log\ndist\ntemp\nyarn-error.log\ntests/coverage/"
},
{
"path": "packages/loaders/.npmignore",
"chars": 4,
"preview": "src/"
},
{
"path": "packages/loaders/package.json",
"chars": 625,
"preview": "{\n \"name\": \"@graphql-cli/loaders\",\n \"description\": \"Internal usage\",\n \"version\": \"5.0.0\",\n \"license\": \"MIT\",\n \"main"
},
{
"path": "packages/loaders/src/index.ts",
"chars": 592,
"preview": "import { Loader } from '@graphql-tools/utils';\nimport { ApolloEngineLoader } from '@graphql-tools/apollo-engine-loader';"
},
{
"path": "packages/loaders/tsconfig.json",
"chars": 612,
"preview": "{\n \"compilerOptions\": {\n \"skipLibCheck\": true,\n \"importHelpers\": true,\n \"experimentalDecorators\": true,\n \"m"
},
{
"path": "renovate.json",
"chars": 133,
"preview": "{\n \"extends\": [\n \"config:base\"\n ],\n \"automerge\": true,\n \"major\": {\n \"automerge\": false\n },\n \"rangeStrategy\":"
},
{
"path": "scripts/introspect-config.js",
"chars": 644,
"preview": "const { loadSchema } = require('@graphql-tools/load');\nconst { GraphQLFileLoader } = require('@graphql-tools/graphql-fil"
},
{
"path": "scripts/release.js",
"chars": 3640,
"preview": "const { argv } = require('yargs');\nconst { sync: glob } = require('globby');\nconst { writeFile } = require('fs-extra');\n"
},
{
"path": "templates/fullstack/.dockerignore",
"chars": 26,
"preview": "node_modules\nnpm-debug.log"
},
{
"path": "templates/fullstack/.gitignore",
"chars": 49,
"preview": "node_modules\ndist\ntypes\nyarn.lock\nyarn-error.log\n"
},
{
"path": "templates/fullstack/.graphqlrc.yml",
"chars": 1372,
"preview": "schema: ./server/src/schema/**/*.graphql\ndocuments: ./client/src/graphql/**/*.graphql\nextensions:\n codegen:\n generat"
},
{
"path": "templates/fullstack/Dockerfile",
"chars": 148,
"preview": "# Stage 1 - the build process\nFROM node:10 as compile-server\nWORKDIR /usr/src/app\nCOPY . .\nRUN npm install\nRUN npm run b"
},
{
"path": "templates/fullstack/README.md",
"chars": 780,
"preview": "# GraphQL CLI Basic Full Stack Template\n\nStarter Full Stack template using GraphQL CLI.\n\n## Usage\n\nThis project has been"
},
{
"path": "templates/fullstack/client/.gitignore",
"chars": 310,
"preview": "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pn"
},
{
"path": "templates/fullstack/client/generated-types.tsx",
"chars": 33085,
"preview": "/* tslint:disable */\nimport gql from 'graphql-tag';\nimport * as ApolloReactCommon from '@apollo/react-common';\nimport * "
},
{
"path": "templates/fullstack/client/package.json",
"chars": 973,
"preview": "{\n \"name\": \"full-stack-template-client\",\n \"version\": \"4.1.0\",\n \"private\": true,\n \"devDependencies\": {\n \"@types/je"
},
{
"path": "templates/fullstack/client/public/index.html",
"chars": 1708,
"preview": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <link rel=\"icon\" href=\"%PUBLIC_URL%/favicon.i"
},
{
"path": "templates/fullstack/client/public/manifest.json",
"chars": 492,
"preview": "{\n \"short_name\": \"React App\",\n \"name\": \"Create React App Sample\",\n \"icons\": [\n {\n \"src\": \"favicon.ico\",\n "
},
{
"path": "templates/fullstack/client/public/robots.txt",
"chars": 57,
"preview": "# https://www.robotstxt.org/robotstxt.html\nUser-agent: *\n"
},
{
"path": "templates/fullstack/client/src/App.css",
"chars": 306,
"preview": ".App {\n text-align: center;\n}\n\n.App-logo {\n height: 40vmin;\n}\n\n.App-header {\n background-color: #282c34;\n min-height"
},
{
"path": "templates/fullstack/client/src/App.test.tsx",
"chars": 248,
"preview": "import React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\n\nit('renders without crashing', ()"
},
{
"path": "templates/fullstack/client/src/App.tsx",
"chars": 854,
"preview": "import React from 'react';\nimport './App.css';\nimport { useFindNotesQuery } from './generated-types';\nimport CreateNote "
},
{
"path": "templates/fullstack/client/src/components/comment/Comment.css",
"chars": 27,
"preview": ".comment{\n color:grey;\n}"
},
{
"path": "templates/fullstack/client/src/components/comment/CreateComment.tsx",
"chars": 1560,
"preview": "import React, { useState } from 'react';\nimport { useCreateCommentMutation } from '../../generated-types';\nimport { Card"
},
{
"path": "templates/fullstack/client/src/components/comment/OneComment.tsx",
"chars": 663,
"preview": "import React from 'react';\nimport { useDeleteCommentMutation, Comment } from '../../generated-types';\nimport { Button } "
},
{
"path": "templates/fullstack/client/src/components/notes/CreateNote.tsx",
"chars": 1378,
"preview": "import React, { useState } from 'react';\nimport { useCreateNoteMutation } from '../../generated-types';\nimport { Button,"
},
{
"path": "templates/fullstack/client/src/components/notes/EditNote.tsx",
"chars": 1466,
"preview": "import React, { useState } from 'react';\nimport { useUpdateNoteMutation } from '../../generated-types';\nimport { Button,"
},
{
"path": "templates/fullstack/client/src/components/notes/Note.css",
"chars": 144,
"preview": ".inputForm{\n display:grid;\n margin: 15%;\n width: 70%;\n}\n\n.inputCard{\n width: 50%;\n margin-left: 25%;\n}\n.O"
},
{
"path": "templates/fullstack/client/src/components/notes/OneNote.tsx",
"chars": 1637,
"preview": "import React, { useState } from 'react';\nimport EditNote from './EditNote';\nimport { Note } from '../../generated-types'"
},
{
"path": "templates/fullstack/client/src/generated-types.tsx",
"chars": 36684,
"preview": "/* tslint:disable */\nimport gql from 'graphql-tag';\nimport * as ApolloReactCommon from '@apollo/react-common';\nimport * "
},
{
"path": "templates/fullstack/client/src/graphql/graphback.graphql",
"chars": 2504,
"preview": "fragment NoteFields on Note {\n id\n title\n description\n\n} \n\nfragment NoteExpandedFields on Note {\n id\n title\n "
},
{
"path": "templates/fullstack/client/src/index.css",
"chars": 366,
"preview": "body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Can"
},
{
"path": "templates/fullstack/client/src/index.tsx",
"chars": 701,
"preview": "import { ApolloProvider } from '@apollo/react-hooks';\nimport ApolloClient from 'apollo-boost';\nimport React from 'react'"
},
{
"path": "templates/fullstack/client/src/react-app-env.d.ts",
"chars": 40,
"preview": "/// <reference types=\"react-scripts\" />\n"
},
{
"path": "templates/fullstack/client/src/serviceWorker.ts",
"chars": 5141,
"preview": "// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the ap"
},
{
"path": "templates/fullstack/client/tsconfig.json",
"chars": 491,
"preview": "{\n \"compilerOptions\": {\n \"target\": \"es5\",\n \"lib\": [\n \"dom\",\n \"dom.iterable\",\n \"esnext\"\n ],\n "
},
{
"path": "templates/fullstack/docker-compose.yml",
"chars": 200,
"preview": "version: '3'\n\nservices:\n postgres:\n image: postgres:9.6\n ports:\n - \"55432:5432\"\n environment:\n POSTG"
},
{
"path": "templates/fullstack/model/datamodel.graphql",
"chars": 220,
"preview": "\"\"\" @model \"\"\"\ntype Note {\n id: ID!\n title: String!\n description: String\n \"\"\"\n @oneToMany(field: 'note')\n \"\"\"\n co"
},
{
"path": "templates/fullstack/package.json",
"chars": 1022,
"preview": "{\n \"name\": \"full-stack-template\",\n \"version\": \"4.1.0\",\n \"private\": true,\n \"workspaces\": [\n \"client\",\n \"server\""
},
{
"path": "templates/fullstack/renovate.json",
"chars": 103,
"preview": "{\n \"extends\": [\n \"config:base\"\n ],\n \"automerge\": true,\n \"major\": {\n \"automerge\": false\n }\n}\n"
},
{
"path": "templates/fullstack/schemats.json",
"chars": 120,
"preview": "{\n \"conn\": \"postgres://postgresql:postgres@localhost:55432/users\",\n \"output\": \"server/src/generated-db-types.ts\"\n}"
},
{
"path": "templates/fullstack/server/package.json",
"chars": 776,
"preview": "{\n \"private\": true,\n \"name\": \"full-stack-template-server\",\n \"version\": \"4.1.0\",\n \"scripts\": {\n \"develop\": \"ts-nod"
},
{
"path": "templates/fullstack/server/src/db.ts",
"chars": 661,
"preview": "import { loadConfig } from 'graphql-config';\nimport Knex from 'knex';\n\nexport const getConfig = async () => {\n const co"
},
{
"path": "templates/fullstack/server/src/generated-db-types.ts",
"chars": 917,
"preview": "/* tslint:disable */\r\n\r\n/**\r\n * AUTO-GENERATED FILE @ 2020-06-03 11:49:44 - DO NOT EDIT!\r\n *\r\n * This file was automatic"
},
{
"path": "templates/fullstack/server/src/generated-types.ts",
"chars": 16768,
"preview": "/* tslint:disable */\nimport { GraphQLResolveInfo } from 'graphql';\nimport { comment, note } from './generated-db-types';"
},
{
"path": "templates/fullstack/server/src/graphql.ts",
"chars": 1197,
"preview": "import { join } from 'path';\nimport { loadFiles } from '@graphql-tools/load-files';\nimport { ApolloServer } from 'apollo"
},
{
"path": "templates/fullstack/server/src/index.ts",
"chars": 686,
"preview": "import cors from 'cors';\nimport express from 'express';\nimport http from 'http';\n\nimport { createApolloServer } from './"
},
{
"path": "templates/fullstack/server/src/schema/schema.graphql",
"chars": 2919,
"preview": "## NOTE: This schema was generated by Graphback and should not be changed manually\n\n\"\"\"Exposes a URL that specifies the "
},
{
"path": "templates/fullstack/server/tsconfig.json",
"chars": 655,
"preview": "{\n \"compilerOptions\": {\n \"outDir\": \"./dist/\",\n \"declarationDir\": \"./types\",\n \"lib\": [\n \"esnext\",\n \"d"
},
{
"path": "templates/fullstack/tslint.json",
"chars": 582,
"preview": "{\n \"extends\": \"tslint:recommended\",\n \"rules\": {\n \"max-line-length\": {\n \"options\": [120]\n },\n \""
},
{
"path": "templates.json",
"chars": 228,
"preview": "{\n \"Full Stack Template with React Hooks, Apollo, NodeJS and PostgreSQL\": {\n \"repository\": \"https://github.com"
},
{
"path": "website/.gitignore",
"chars": 233,
"preview": "# Dependencies\n/node_modules\n\n# Production\n/build\n\n# Generated files\n.docusaurus\n.cache-loader\n\n# Misc\n.DS_Store\n.env.lo"
},
{
"path": "website/README.md",
"chars": 721,
"preview": "# Website\n\nThis website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator.\n\n##"
},
{
"path": "website/algolia-lockfile.json",
"chars": 5816,
"preview": "[\n {\n \"objectID\": \"cli-codegen\",\n \"headings\": [],\n \"toc\": [],\n \"content\": \"-\",\n \"url\": \"https://www.grap"
},
{
"path": "website/babel.config.js",
"chars": 89,
"preview": "module.exports = {\n presets: [require.resolve('@docusaurus/core/lib/babel/preset')],\n};\n"
},
{
"path": "website/docs/codegen.md",
"chars": 1891,
"preview": "---\nid: codegen\ntitle: codegen\nsidebar_label: codegen\n---\n\nGenerate code from your GraphQL schema and operations. See th"
},
{
"path": "website/docs/coverage.md",
"chars": 1493,
"preview": "---\nid: coverage\ntitle: coverage\nsidebar_label: coverage\n---\n\nSchema coverage based on documents. Find out how many time"
},
{
"path": "website/docs/custom-commands.md",
"chars": 3852,
"preview": "---\nid: custom-commands\ntitle: Custom commands\nsidebar_label: Custom commands\n---\n\n## Writing your own commands\n\n`graphq"
},
{
"path": "website/docs/diff.md",
"chars": 1241,
"preview": "---\nid: diff\ntitle: diff\nsidebar_label: diff\n---\n\nDetect changes to your GraphQL Schema and prevent breaking your existi"
},
{
"path": "website/docs/discover.md",
"chars": 257,
"preview": "---\nid: discover\ntitle: discover\nsidebar_label: discover\n---\n\nOpen a list of available plugins in your browser.\n\n### Ins"
},
{
"path": "website/docs/generate.md",
"chars": 1286,
"preview": "---\nid: generate\ntitle: generate\nsidebar_label: generate\n---\n\nGenerate schema and client documents for your GraphQL proj"
},
{
"path": "website/docs/init.md",
"chars": 1188,
"preview": "---\nid: init\ntitle: init\nsidebar_label: init\n---\n\nCreate a GraphQL project using a template or GraphQL Config file for y"
},
{
"path": "website/docs/introduction.md",
"chars": 3353,
"preview": "---\nid: introduction\ntitle: Introduction\nsidebar_label: Introduction\n---\n\n API"
},
{
"path": "website/docs/similar.md",
"chars": 1279,
"preview": "---\nid: similar\ntitle: similar\nsidebar_label: similar\n---\n\nGet a list of similar types in order to find duplicates. See "
},
{
"path": "website/docs/validate.md",
"chars": 1723,
"preview": "---\nid: validate\ntitle: validate\nsidebar_label: validate\n---\n\nValidates documents against a schema and looks for depreca"
},
{
"path": "website/docusaurus.config.js",
"chars": 3209,
"preview": "module.exports = {\n title: 'GraphQL CLI',\n tagline: '📟 Command line tool for common GraphQL development workflows',\n\n "
},
{
"path": "website/package.json",
"chars": 816,
"preview": "{\n \"name\": \"website\",\n \"version\": \"4.1.0\",\n \"private\": true,\n \"scripts\": {\n \"start\": \"docusaurus start\",\n \"bui"
},
{
"path": "website/scripts/algolia-ci.ts",
"chars": 544,
"preview": "import { indexToAlgolia } from '@guild-docs/algolia';\nimport { resolve } from 'path';\nimport * as sidebars from '../side"
},
{
"path": "website/sidebars.js",
"chars": 353,
"preview": "module.exports = {\n docs: {\n 'Getting Started': [\n 'introduction',\n ],\n 'Commands': [\n 'codegen',\n "
},
{
"path": "website/src/css/custom.css",
"chars": 468,
"preview": ":root {\n --ifm-color-primary: #8c0082;\n --ifm-color-primary-dark: #8c0082;\n --ifm-color-primary-darker: #8c0082;\n --"
},
{
"path": "website/src/pages/index.js",
"chars": 157,
"preview": "import React from 'react';\nimport {Redirect} from '@docusaurus/router';\n\nfunction Home() {\n return <Redirect to=\"/intro"
},
{
"path": "website/src/pages/styles.module.css",
"chars": 558,
"preview": "/* stylelint-disable docusaurus/copyright-header */\n/**\n * CSS files with the .module.css suffix will be treated as CSS "
},
{
"path": "website/src/theme/Root.js",
"chars": 517,
"preview": "import React from 'react';\nimport BrowserOnly from '@docusaurus/BrowserOnly';\nimport { ThemeProvider, Header } from 'the"
},
{
"path": "website/static/CNAME",
"chars": 20,
"preview": "www.graphql-cli.com\n"
},
{
"path": "website/static/js/light-mode-by-default.js",
"chars": 80,
"preview": "if (!localStorage.getItem('theme')) {\n localStorage.setItem('theme', 'light')\n}"
}
]
About this extraction
This page contains the full source code of the graphcool/graphql-cli GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 145 files (234.9 KB), approximately 62.4k tokens, and a symbol index with 402 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.