absinthe-graphql / absinthe

The GraphQL toolkit for Elixir
http://absinthe-graphql.org
Other
4.27k stars 525 forks source link

Absinthe.Formatter.format/2 formats input: into one very long line #1307

Open zkessin opened 6 months ago

zkessin commented 6 months ago

I am trying to format a mutation query with a long input with the graphql formatter and it is doing something strange. All of the input data has been put onto one very long line. (See bellow)

mutation {
  createInverter(
    input: {
      adapterConfiguration: {
        name: "sims"
        simulation: { enabled: false, startingStorage: "100" }
      }
      baselineConfiguration: {
        method: POWER_PRIOR_TO_VPP_EVENT
        telemetrySource: INVERTER
      }
      connectedBatteries: [
        {
          controlConstraints: {}
          nominalEnergy: "0"
          operationalConstraints: { ratedEnergy: "5000", ratedPower: "50000" }
          remoteId: "inverter 2 battery"
        }
      ]
      connectedPhotovoltaics: [
        {
          operationalConstraints: { ratedPower: "50000" }
          remoteId: "inverter 2 pv"
        }
      ]
      name: "Inverter2"
      operationalConstraints: { efficiency: "97", ratedPower: "199000" }
      remoteId: "Inverter 2 remote id"
    }
  ) {
    inverter {
      remoteId
    }
  }
}

But it formats like this

      mutation {
        createInverter(
          input: { adapterConfiguration: { name: "sims", simulation: { enabled: false, startingStorage: "100" } }, baselineConfiguration: { method: POWER_PRIOR_TO_VPP_EVENT, telemetrySource: INVERTER }, connectedBatteries: [{ controlConstraints: {  }, nominalEnergy: "0", operationalConstraints: { ratedEnergy: "5000", ratedPower: "50000" }, remoteId: "inverter 2 battery" }], connectedPhotovoltaics: [{ operationalConstraints: { ratedPower: "50000" }, remoteId: "inverter 2 pv" }], name: "Inverter2", operationalConstraints: { efficiency: "97", ratedPower: "199000" }, remoteId: "Inverter 2 remote id" }
        ) {
          inverter {
            remoteId
          }
        }
      }
benwilson512 commented 6 months ago

Ah yeah that does seem nonoptimal. PR welcome!