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?
I am trying to abstract the different queries made (and welcoming suggestions!).
I have file: