Skip to content

GitLab Next

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 39,511
    • Issues 39,511
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 1,222
    • Merge requests 1,222
  • Requirements
    • Requirements
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #227280

Closed
Open
Created Jul 07, 2020 by Tristan Read@tristan.read💬Developer4 of 4 tasks completed4/4 tasks

Format graphql files with prettier

I've noticed some churn on graphql file changes recently, mostly for trailing commas and indentation.

Prettier is capable of linting graphql query files. If we enable this option in our prettier script and editors, we'll have consistent formatting across our files. This will reduce file churn and improve readability.

It's worth noting that there may be some extra setup steps required for each developer due to .graphql not being a supported file type by VSCode. More detail at https://github.com/prettier/prettier-vscode/issues/989. This doesn't seem to be an issue any more, confirmed by testing it locally.

Instructions for this should be added to the frontend tooling guide: https://docs.gitlab.com/ee/development/fe_guide/tooling.html.

Roll-out phases

  • Announce on internal development channels - #f_graphql and #frontend.
  • Merge !36244 (merged).
  • Add to frontend weekly agenda.
  • Announce again on internal development channels.
:sparkles: **Note** GraphQL files are now formatted with prettier.

To avoid conflicts and build failures, please incorporate the latest changes from master.

_*What does this mean for me?*_
Regardless of whether you're modifying graphql files or not, you should ensure your editor is up-to-date with the latest formatting rules. There are some details here: https://docs.gitlab.com/ee/development/fe_guide/tooling.html#formatting-with-prettier.

For example, if you're using VSCode you may want to add the following to your workspace preferences:
\```
  "[vue]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": true"
  }
\```

Related to: #219337

Edited Jul 14, 2020 by Tristan Read
Assignee
Assign to
Time tracking