Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Urigo/graphql-cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.0.0
Choose a base ref
...
head repository: Urigo/graphql-cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.1.0
Choose a head ref
Loading
Showing with 2,996 additions and 1,102 deletions.
  1. +21 −0 .github/workflows/main.yml
  2. +37 −0 .github/workflows/website.yml
  3. +5 −11 README.md
  4. +21 −15 docs/MIGRATION.md
  5. +4 −4 integration/package.json
  6. +2 −0 integration/test-project/.dockerignore
  7. +5 −0 integration/test-project/.gitignore
  8. +15 −0 integration/test-project/.graphqlrc.yml
  9. +31 −0 integration/test-project/package.json
  10. +9 −0 integration/test-project/renovate.json
  11. +161 −0 integration/test-project/schema/schema.graphql
  12. +28 −0 integration/test-project/tsconfig.json
  13. +25 −0 integration/test-project/tslint.json
  14. +1 −1 integration/tests/workflow.ts
  15. +1 −1 lerna.json
  16. +18 −0 now.json
  17. +20 −17 package.json
  18. +6 −6 packages/cli/package.json
  19. +2 −2 packages/commands/generate/README.md
  20. +6 −7 packages/commands/generate/package.json
  21. +6 −36 packages/commands/generate/src/index.ts
  22. +2 −2 packages/commands/init/README.md
  23. +13 −12 packages/commands/init/package.json
  24. +1 −1 packages/commands/init/src/common.ts
  25. +3 −1 packages/commands/init/src/features/codegen.ts
  26. +15 −12 packages/commands/init/src/index.ts
  27. +2 −54 packages/commands/init/src/sources/from-scratch.ts
  28. +2 −2 packages/commands/serve/README.md
  29. +6 −9 packages/commands/serve/package.json
  30. +7 −103 packages/commands/serve/src/index.ts
  31. +5 −5 packages/common/package.json
  32. +9 −9 packages/loaders/package.json
  33. +0 −17 scripts/fix-bin.js
  34. +3 −9 templates/fullstack/.graphqlrc.yml
  35. +8 −8 templates/fullstack/client/package.json
  36. +4 −4 templates/fullstack/client/src/App.tsx
  37. +543 −408 templates/fullstack/client/src/generated-types.tsx
  38. +0 −6 templates/fullstack/client/src/graphql/fragments/Comment.graphql
  39. +0 −10 templates/fullstack/client/src/graphql/fragments/CommentExpanded.graphql
  40. +0 −6 templates/fullstack/client/src/graphql/fragments/Note.graphql
  41. +0 −10 templates/fullstack/client/src/graphql/fragments/NoteExpanded.graphql
  42. +147 −0 templates/fullstack/client/src/graphql/graphback.graphql
  43. +0 −5 templates/fullstack/client/src/graphql/mutations/createComment.graphql
  44. +0 −5 templates/fullstack/client/src/graphql/mutations/createNote.graphql
  45. +0 −5 templates/fullstack/client/src/graphql/mutations/deleteComment.graphql
  46. +0 −5 templates/fullstack/client/src/graphql/mutations/deleteNote.graphql
  47. +0 −5 templates/fullstack/client/src/graphql/mutations/updateComment.graphql
  48. +0 −5 templates/fullstack/client/src/graphql/mutations/updateNote.graphql
  49. +0 −5 templates/fullstack/client/src/graphql/queries/findAllComments.graphql
  50. +0 −5 templates/fullstack/client/src/graphql/queries/findAllNotes.graphql
  51. +0 −5 templates/fullstack/client/src/graphql/queries/findComments.graphql
  52. +0 −5 templates/fullstack/client/src/graphql/queries/findNotes.graphql
  53. +0 −5 templates/fullstack/client/src/graphql/subscriptions/deletedComment.graphql
  54. +0 −5 templates/fullstack/client/src/graphql/subscriptions/deletedNote.graphql
  55. +0 −5 templates/fullstack/client/src/graphql/subscriptions/newComment.graphql
  56. +0 −5 templates/fullstack/client/src/graphql/subscriptions/newNote.graphql
  57. +0 −5 templates/fullstack/client/src/graphql/subscriptions/updatedComment.graphql
  58. +0 −5 templates/fullstack/client/src/graphql/subscriptions/updatedNote.graphql
  59. +1 −1 templates/fullstack/model/datamodel.graphql
  60. +14 −14 templates/fullstack/package.json
  61. +18 −15 templates/fullstack/server/package.json
  62. +212 −60 templates/fullstack/server/src/generated-types.ts
  63. +23 −12 templates/fullstack/server/src/graphql.ts
  64. +0 −18 templates/fullstack/server/src/resolvers/models.ts
  65. +0 −93 templates/fullstack/server/src/resolvers/resolvers.ts
  66. +123 −21 templates/fullstack/server/src/schema/schema.graphql
  67. +20 −0 website/.gitignore
  68. +33 −0 website/README.md
  69. +3 −0 website/babel.config.js
  70. +74 −0 website/docs/command-codegen.md
  71. +60 −0 website/docs/command-coverage.md
  72. +57 −0 website/docs/command-diff.md
  73. +25 −0 website/docs/command-discover.md
  74. +72 −0 website/docs/command-generate.md
  75. +58 −0 website/docs/command-init.md
  76. +57 −0 website/docs/command-introspect.md
  77. +150 −0 website/docs/command-serve.md
  78. +59 −0 website/docs/command-similar.md
  79. +62 −0 website/docs/command-validate.md
  80. +125 −0 website/docs/custom-commands.md
  81. +122 −0 website/docs/introduction.md
  82. +179 −0 website/docs/migration.md
  83. +131 −0 website/docusaurus.config.js
  84. +30 −0 website/package.json
  85. +23 −0 website/sidebars.js
  86. +24 −0 website/src/css/custom.css
  87. +8 −0 website/src/pages/index.js
  88. +36 −0 website/src/pages/styles.module.css
  89. BIN website/static/img/logo.ico
  90. BIN website/static/img/logo.png
  91. +3 −0 website/static/js/light-mode-by-default.js
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ on:
pull_request:
branches:
- master
release:
types: [released, prereleased]

jobs:
test:
@@ -54,3 +56,22 @@ jobs:
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@v1
- name: Use Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install Dependencies using Yarn
run: yarn install
- 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
37 changes: 37 additions & 0 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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@v1
- 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@v1
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}}
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ Feel free to contact us in Discord channel. We would love to hear your feedback.
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@next
yarn global add graphql-cli
```

The equivalent npm global install will also work.
@@ -35,7 +35,7 @@ At the heart of a project created using GraphQL CLI is the GraphQL Config config
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@next init
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.
@@ -53,7 +53,7 @@ Finally, one of the options with `graphql init` is to access schema using an Ope

## 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]@next`.
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.

@@ -95,7 +95,7 @@ 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 DB, schema, document and resolvers for your GraphQL project by using [GraphBack](https://graphback.dev).
- [`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/common) - 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:
@@ -109,14 +109,8 @@ extensions:

- [`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 faked GraphQL server, you can define your own mocks for each types and scalars inside GraphQL Config like below:
- [`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.

```yml
extensions:
serve:
mocks:
DateTime: graphql-scalars#DateTimeMock #Imports DateTimeMock function from graphql-scalars for mocking DateTimeMock
```

More plugins are definitely welcome! Please check the existing ones to see how to use GraphQL Config and GraphQL CLI API.

36 changes: 21 additions & 15 deletions docs/MIGRATION.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ Starting with GraphQL CLI 4.0 and higher, the way projects are set up is signifi
## Install the new version
To get started, install the new version:
```sh
yarn global add graphql-cli@next
yarn global add graphql-cli
```
You can also globally install using npm.

@@ -16,11 +16,11 @@ 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/docs/usage) for naming the config files supported by GraphQL CLI, but this guide will assume you're using YAML syntax.
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/docs/usage) for more information about the new structure.
You can [check here](https://graphql-config.com/usage) for more information about the new structure.

###Specifying schema(s):

@@ -44,17 +44,19 @@ 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@next @graphql-codegen/schema-ast --dev
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:
./schema.graphql:
- schema-ast
codegen:
generates:
./schema.graphql:
plugins:
- schema-ast
```

By running `graphql codegen`, the `schema.graphql` file is generated in the root path of your project.
@@ -65,9 +67,11 @@ If you want to download the schema as a `json` introspection file, you will need
```yaml
schema: http://localhost:4000/graphql
extensions:
codegen:
./schema.json:
- introspection
codegen:
generates:
./schema.json:
plugins:
- introspection
```

### `create` is no longer available: it is replaced by the `init` command.
@@ -107,7 +111,7 @@ extensions:
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@next @graphql-codegen/typescript @graphql-codegen/typescript-resolvers --dev
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:
@@ -142,16 +146,18 @@ projects:
database:
schema: prisma/prisma.yml
extensions:
codegen:
src/generated/prisma-client/prisma.graphql:
- schema-ast
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@next @graphql-codegen/schema-ast --dev
yarn add @graphql-cli/codegen @graphql-codegen/schema-ast --dev
```

Now you can run `graphql codegen --project database` for generating your `prisma.graphql` file.
8 changes: 4 additions & 4 deletions integration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-cli-integration-test",
"version": "4.0.0",
"version": "4.1.0",
"license": "MIT",
"private": true,
"main": "dist/index.js",
@@ -12,11 +12,11 @@
},
"dependencies": {
"log-symbols": "4.0.0",
"tslib": "2.0.0"
"tslib": "2.0.2"
},
"devDependencies": {
"ava": "3.8.2",
"execa": "4.0.2"
"ava": "3.13.0",
"execa": "4.0.3"
},
"ava": {
"files": [
2 changes: 2 additions & 0 deletions integration/test-project/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
5 changes: 5 additions & 0 deletions integration/test-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
types
yarn.lock
yarn-error.log
15 changes: 15 additions & 0 deletions integration/test-project/.graphqlrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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
31 changes: 31 additions & 0 deletions integration/test-project/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"private": true,
"name": "test-project",
"version": "4.1.0",
"dependencies": {
"@graphql-tools/load-files": "6.2.4",
"@types/node": "13.13.23",
"graphql": "15.3.0",
"graphql-config": "3.0.3",
"graphql-tag": "2.11.0"
},
"devDependencies": {
"@graphql-codegen/add": "2.0.1",
"@graphql-codegen/typescript": "1.17.10",
"@graphql-codegen/typescript-operations": "1.17.8",
"@graphql-codegen/typescript-react-apollo": "2.0.7",
"@graphql-codegen/typescript-resolvers": "1.17.10",
"@graphql-cli/codegen": "1.17.10",
"@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.3.0",
"graphql-cli": "4.1.0",
"tslint": "6.1.3",
"typescript": "4.0.3"
},
"license": "MIT"
}
9 changes: 9 additions & 0 deletions integration/test-project/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": [
"config:base"
],
"automerge": true,
"major": {
"automerge": false
}
}
Loading