Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSL compiler for GraphQL::Schema::ObjectType #1920

Open
JacobyJoukema opened this issue Jun 13, 2024 · 0 comments
Open

DSL compiler for GraphQL::Schema::ObjectType #1920

JacobyJoukema opened this issue Jun 13, 2024 · 0 comments

Comments

@JacobyJoukema
Copy link

JacobyJoukema commented Jun 13, 2024

When using field in GraphQL object types, new methods are created in the class dynamically. In certain occasions, like in batch loading, we need to be able to refer to those methods and avoid type checking errors.

class MyType < GraphQL::Schema::Object
  field "foo", type: String

  class << self
    extend T::Sig

    sig { params(objects: T::Array[MyType]).void }
    def load_foo(objects)
      objects.each { |obj| obj.foo = "hello!" }
                              # ^ error: foo doesn't exist on MyType
    end
  end
end
@vinistock vinistock changed the title Tapioca DSL compiler missing for GraphApi::Admin::FulfillmentOrderLineItem DSL compiler for GraphQL::Schema::ObjectType Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant