prettier / prettier/prettier

Unstable formatting of GraphQL comments at end of argument list

Open
#9,112 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:comments area:idempotency help wanted lang:graphql
Dominant language
JavaScript
Stars
52.3k
Forks
5k
Avg merge
19h 2m
Merged PRs (30d)
117

Description

Prettier 2.0.5
Playground link

--parser graphql

Input:

# Input1: the original input

query Browse(
  $offset: Int
  $limit: Int
  $categories: [String!]
  $search: String
  # $foo: Int
  # $bar: Int
) {
  t
}

# prettier(Input1): this is the result of formatting Input1, but 
# note the output differs. Formatting should be stable.

query Browse(
  $offset: Int
  $limit: Int
  $categories: [String!]
  $search: String
) # $foo: Int
# $bar: Int
{
  t
}

# prettier(prettier(Input1)): this is the result of formatting the
# formatted output of Input1. This *should* be the same as 
# `prettier(Input1)` but isn't.

query Browse(
  $offset: Int
  $limit: Int
  $categories: [String!]
  $search: String # $foo: Int
) # $bar: Int
{
  t
}

Output:

# Input1: the original input

query Browse(
  $offset: Int
  $limit: Int
  $categories: [String!]
  $search: String
) # $foo: Int
# $bar: Int
{
  t
}

# prettier(Input1): this is the result of formatting Input1, but
# note the output differs. Formatting should be stable.

query Browse(
  $offset: Int
  $limit: Int
  $categories: [String!]
  $search: String # $foo: Int
) # $bar: Int
{
  t
}

# prettier(prettier(Input1)): this is the result of formatting the
# formatted output of Input1. This *should* be the same as
# `prettier(Input1)` but isn't.

query Browse(
  $offset: Int
  $limit: Int
  $categories: [String!]
  $search: String # $foo: Int # $bar: Int
) {
  t
}

Expected behavior:

prettier(prettier(graphql)) should be the same as prettier(graphql); formatting should be stable.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the linked GraphQL Playground reproduction with the graphql parser as the starting point. Format the provided input twice and compare both outputs; done means prettier(prettier(graphql)) matches prettier(graphql), with the comment placement stable.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.