ashkan18 / graphlient

Ruby GraphQL Client
MIT License
251 stars 43 forks source link

Enable fragments #94

Closed rellampec closed 1 year ago

rellampec commented 2 years ago

@dblock I have added some logic to resolve constants defined in a different context, provided that the full namespace path is included on Graphlient::Query::#parse, although stub_const doesn't seem to offer a way to mock the scenario.

module Test
  module Foo
    module Bar
      Fragment = "client.parse ..."
    end
  end
end

module Test
  module Foo
    module Baz
      # use of ___Bar__Fragment
      puts Bar::Fragment
    end
  end
end

In the example above, a graphlient.parse in Baz referring to ___Bar__Fragment would fail to resolve. And for this reason, I have added evaluate (capture the context) and resolve_fragment_constant (constant resolution + type validation).

dangerpr-bot commented 2 years ago
1 Warning
:warning: Unless you're refactoring existing code, please update CHANGELOG.md.

Here's an example of a CHANGELOG.md entry:

* [#94](https://github.com/ashkan18/graphlient/pull/94): Enable fragments - [@rellampec](https://github.com/rellampec).

Generated by :no_entry_sign: Danger

dblock commented 2 years ago

Looks good. Let's increment the version to 0.7.0 per semver part of this PR and update/edit https://github.com/ashkan18/graphlient/blob/master/CHANGELOG.md please?

rellampec commented 1 year ago

@ashkan18 added PR changelog and incremented to version 0.7.0

ashkan18 commented 1 year ago

Looks like tests are failing, once they are green let's merge 🙌 thanks for doing this ❤️

rellampec commented 1 year ago

@ashkan18 I had to change the connection message to pass the tests locally.

image

I have reverted that test to its previous expected value.

ashkan18 commented 1 year ago

Awesome! thanks for the quick fix ❤️