Skip to content
GitLab
Next
Projects Groups Snippets
  • /
  • 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 44,763
    • Issues 44,763
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,330
    • Merge requests 1,330
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #227280
Closed
Open
Issue created Jul 07, 2020 by Tristan Read@tristan.read💬Developer4 of 4 checklist items completed4/4 checklist items

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 (closed)

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