Giter VIP home page Giter VIP logo

Comments (3)

xuorig avatar xuorig commented on June 8, 2024

Thanks for bringing this up!

Would it be possible to ignore such new lines in descriptions? Or would it be better to not include newlines in the schema, and fix this on graphql-ruby gem side?

Interesting. I feel like any change in the description string is indeed a change 🤔

you can't use graphql-schema_comparator any more because it always detects a change, even if there isn't one.

I'm trying to understand why you can't use it anymore. The first time you change to a description with new line, I would expect there would be description changes, but once you merge, I feel like there would be no more changes the next time? Am I getting this right?

from graphql-schema_comparator.

23tux avatar 23tux commented on June 8, 2024

Consider this test for RSpec

  it "looks if graphql schema has changed" do
    old_schema = File.read(Rails.root.join("schema.graphql"))
    new_schema = MySchema.to_graphql
    result = GraphQL::SchemaComparator.compare(old_schema, new_schema)
    expect(result).to be_identical
  end

When we have a change in the GraphQL schema, we dump it with rails graphql:schema:idl. When we have a long description, it get's dumped with new lines into the schema.graphql file. When you re-read it in the spec to check if there are changes, the MySchema.to_graphql has NO new lines, but the schema read from schema.graphql has the new lines.

So it detects a change, even if there is none. Do you know what I mean?

from graphql-schema_comparator.

CodingAnarchy avatar CodingAnarchy commented on June 8, 2024

Ran into this issue myself just now: a couple of our fields have long enough descriptions that they are word wrapped in the schema.graphql file, but the GraphQL Schema object does not include the wrapping.

We had to work around this issue by explicitly ignoring specific "changes" that would incorrectly get flagged due to the descriptions being text-wrapped in the schema dump, which is brittle thing that it would be better not to have to maintain:

        false_alarm = true
        compare_result.changes.each do |change|
          if change.is_a?(GraphQL::SchemaComparator::Changes::InputFieldDescriptionChanged) &&
              change.old_field.description.tr("\n", " ") == change.new_field.description
            # This is a false alarm non-change due to text formatting done when dumping
            # to the schema.graphql file for long descriptions, so we skip it
            next
          end
          if change.is_a?(GraphQL::SchemaComparator::Changes::FieldArgumentDescriptionChanged) &&
              change.old_argument.description.tr("\n", " ") == change.new_argument.description
            # This is a false alarm non-change due to text formatting done when dumping
            # to the schema.graphql file for long descriptions, so we skip it
            next
          end

          puts "    #{change.message}"
          false_alarm = false
        end

from graphql-schema_comparator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.