Giter Club home page Giter Club logo

Comments (4)

StanBoyet avatar StanBoyet commented on August 15, 2024 1

Hey @khamusa,

Thanks for your answer, I get it now.
I proposed a PR to remove the line where you suggest to add it to the spec_helper.rb so newcomers don't get confused 😃 PR #5

Thanks for your work,

Cheers

from rspec-graphql_matchers.

StanBoyet avatar StanBoyet commented on August 15, 2024

Hi,

How do you use the gem without this? I tried including it but keep having NameError: uninitialized constant RSpec::GraphqlMatchers

from rspec-graphql_matchers.

khamusa avatar khamusa commented on August 15, 2024

Hi @StanBoyet ,

I haven't really worked on this Issue for many reasons. Mainly I'm thinking it's not a good idea as a feature, as the Graphql-ruby creator himself has been proposing to avoid the usage of types and instead using the type constants directly.

there are quite a few ways to work around this. The first one, if you want to use the types variable, is to define it yourself.

types is basically a shortcut to GraphQL::Define::TypeDefiner.instance, so you can define a method called types or assign GraphQL::Define::TypeDefiner.instance to a variable called types, depending on your context / test runner.

However, after writing quite a lot of specs on types, I believe the main purpose of these is to help you to avoid breaking changes on your api interface. For that purpose, a better idea is to specify types directly as strings instead of using the constants. Suppose you have a type User, and you write your specs using a ruby constant UserType. At some point you decide to rename the User type to Player, but you keep the same constant throught your application. If you wrote your specs using the constant UserType, they will still pass, but this is a potentially breaking change as clients may have defined queries using variables of type User, which is now Player.

Hope this helps :)

Edit: using strings you have the additional benefit of depending less on the inners of the graphql-ruby implementation.

from rspec-graphql_matchers.

khamusa avatar khamusa commented on August 15, 2024

I really thought I had already removed that line! Thank you ;)

I'll close this issue now.

from rspec-graphql_matchers.

Related Issues (19)

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.