Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Working with mixins #64

@mmahalwy

Description

@mmahalwy

I am trying to abstract the different queries made (and welcoming suggestions!).

I have file:

  def self.included(child_class)
    child_class.field(:companies, [Types::CompanyType], null: false)
    child_class.field(:company, Types::CompanyType, null: false) do
      argument :id, Integer, required: true
    end
  end

  # then implement the field
  def companies
    CompanyPolicy::Scope.new(context[:current_user], ::Company).resolve
  end

  def company(id:)
    ::Company.find(id)
  end
end``` 

That is then included in my query type:
```class Types::QueryType < GraphQL::Schema::Object
  graphql_name "Query"

  include Queries::Models::Company
end
```.

My challenge is that `CompanyPolicy::Scope.new(context[:current_user], ::Company).resolve` works for the time being but not great for the long run. How can I change this up to work with this? 

Also, in the docs there is reference to `GraphQL::Schema::FieldType` then there is no more mention of it in the README, how is it being used? 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions