Commit baedeb4e authored by Alex Kalderimis's avatar Alex Kalderimis

Do not commit the generated schema

We do not use it, it can be replaced by introspection queries, and
it complicates development.

The `gitlab:graphql:schema:dump` rake task now generates the file
in the `./tmp` directory.

The documentation is updated to mention the impact on front-end
development.
parent 71078842
......@@ -131,6 +131,24 @@ rspec-ee frontend_fixture:
- .frontend:rules:default-frontend-jobs
parallel: 2
graphql-schema-dump:
variables:
SETUP_DB: "false"
extends:
- .default-retry
- .rails-cache
- .default-before_script
- .frontend:rules:default-frontend-jobs
stage: fixtures
needs: []
script:
- bundle exec rake gitlab:graphql:schema:dump
artifacts:
name: graphql-schema
paths:
- tmp/tests/graphql/gitlab_schema.graphql
- tmp/tests/graphql/gitlab_schema.json
.frontend-test-base:
extends:
- .frontend-base
......@@ -214,7 +232,7 @@ jest-integration:
- *yarn-install
- run_timed_command "yarn jest:integration --ci"
# Don't use `needs` since `rspec-ee frontend_fixture` doesn't exist in `gitlab-foss` pipelines.
dependencies: ["rspec frontend_fixture", "rspec-ee frontend_fixture"]
dependencies: ["rspec frontend_fixture", "rspec-ee frontend_fixture", "graphql-schema-dump"]
jest-as-if-foss:
extends:
......
......@@ -11,4 +11,3 @@ graphql-verify:
script:
- bundle exec rake gitlab:graphql:validate
- bundle exec rake gitlab:graphql:check_docs
- bundle exec rake gitlab:graphql:check_schema
......@@ -4,7 +4,6 @@
/public/
/vendor/
/tmp/
doc/api/graphql/reference/gitlab_schema.graphql
# ignore stylesheets for now as this clashes with our linter
*.css
......
......@@ -160,11 +160,6 @@ The GitLab GraphQL reference [is available](reference/index.md).
It is automatically generated from the GitLab GraphQL schema and embedded in a Markdown file.
Machine-readable versions are also available:
- [JSON format](reference/gitlab_schema.json)
- [IDL format](reference/gitlab_schema.graphql)
## Generate updates for documentation
If you've changed the GraphQL schema, you should set up an MR to gain approval of your changes.
......
This diff is collapsed.
This diff is collapsed.
......@@ -63,6 +63,7 @@ see [Immutability and cache updates](#immutability-and-cache-updates) for more i
If you use VS Code, the Apollo GraphQL extension supports autocompletion in `.graphql` files. To set up
the GraphQL extension, follow these steps:
1. Generate the schema: `bundle exec rake gitlab:graphql:schema:dump`
1. Add an `apollo.config.js` file to the root of your `gitlab` local directory.
1. Populate the file with the following content:
......@@ -72,7 +73,7 @@ the GraphQL extension, follow these steps:
includes: ['./app/assets/javascripts/**/*.graphql', './ee/app/assets/javascripts/**/*.graphql'],
service: {
name: 'GitLab',
localSchemaFile: './doc/api/graphql/reference/gitlab_schema.graphql',
localSchemaFile: './tmp/tests/graphql/gitlab_schema.graphql',
},
},
};
......@@ -768,6 +769,16 @@ export default {
### Testing
#### Generating the GraphQL schema
Some of our tests load the schema JSON files. To generate these files, run:
```shell
bundle exec rake gitlab:graphql:schema:dump
```
You should run this task after pulling from upstream.
#### Mocking response as component data
<!-- vale gitlab.Spelling = NO -->
......
......@@ -6,6 +6,7 @@ require 'graphql/rake_task'
namespace :gitlab do
OUTPUT_DIR = Rails.root.join("doc/api/graphql/reference")
TEMP_SCHEMA_DIR = Rails.root.join('tmp/tests/graphql')
TEMPLATES_DIR = 'lib/gitlab/graphql/docs/templates/'
# Make all feature flags enabled so that all feature flag
......@@ -27,7 +28,7 @@ namespace :gitlab do
GraphQL::RakeTask.new(
schema_name: 'GitlabSchema',
dependencies: [:environment, :enable_feature_flags],
directory: OUTPUT_DIR,
directory: TEMP_SCHEMA_DIR,
idl_outfile: "gitlab_schema.graphql",
json_outfile: "gitlab_schema.json"
)
......@@ -129,19 +130,6 @@ namespace :gitlab do
abort
end
end
desc 'GitLab | GraphQL | Check if GraphQL schemas are up to date'
task check_schema: [:environment, :enable_feature_flags] do
idl_doc = File.read(Rails.root.join(OUTPUT_DIR, 'gitlab_schema.graphql'))
json_doc = File.read(Rails.root.join(OUTPUT_DIR, 'gitlab_schema.json'))
if idl_doc == GitlabSchema.to_definition && json_doc == GitlabSchema.to_json
puts "GraphQL schema is up to date"
else
format_output('GraphQL schema is outdated! Please update it by running `bundle exec rake gitlab:graphql:schema:dump`.')
abort
end
end
end
end
......
......@@ -8,7 +8,7 @@ const localVue = createLocalVue();
localVue.use(VueRouter);
const router = new VueRouter();
// Referenced from: doc/api/graphql/reference/gitlab_schema.graphql:DesignVersionEvent
// Referenced from: gitlab_schema.graphql:DesignVersionEvent
const DESIGN_VERSION_EVENT = {
CREATION: 'CREATION',
DELETION: 'DELETION',
......
import { buildSchema, graphql } from 'graphql';
import gitlabSchemaStr from '../../../../doc/api/graphql/reference/gitlab_schema.graphql';
/* eslint-disable import/no-unresolved */
// This rule is disabled for the following line.
// The graphql schema is dynamically generated in CI
// during the `graphql-schema-dump` job.
import gitlabSchemaStr from '../../../../tmp/tests/graphql/gitlab_schema.graphql';
/* eslint-enable import/no-unresolved */
const graphqlSchema = buildSchema(gitlabSchemaStr.loc.source.body);
const graphqlResolvers = {
......
......@@ -325,8 +325,6 @@ RSpec.describe Tooling::Danger::Helper do
'db/fixtures/foo.rb' | [:backend]
'ee/db/fixtures/foo.rb' | [:backend]
'doc/api/graphql/reference/gitlab_schema.graphql' | [:backend]
'doc/api/graphql/reference/gitlab_schema.json' | [:backend]
'qa/foo' | [:qa]
'ee/qa/foo' | [:qa]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment