Tag: resolver

  • Apollo GraphQL: dynamically caching a schema type, not the entire resolver

    Apollo GraphQL: dynamically caching a schema type, not the entire resolver

    0 I would like to use dynamic cache. I was able to set the cache maxAge into the query resolver, but since the resolver can return both an unsuccessful and a successful response I would like to only cache the successful one. In order to do this I would like to set up the info…

  • undefined method `ids’ for [#

    undefined method `ids’ for [#

    0 def resolve(where: {}, order_by: {‘field’: ‘updated_at’, ‘direction’: ‘desc’}) order_by.symbolize_keys! [context[:current_user]] unless context[:current_user].has_capability?(self.class.name.demodulize) cap_belongs_to = context[:current_user].determine_capability_belongs_to(self.class.name.demodulize) users = if cap_belongs_to[:direct] || context[:current_user].user_type == ‘SuperAdmin’ context[:tenant].users.includes([:groups, :roles]).where(where).order("#{order_by[:field]} #{order_by[:direction]}") elsif cap_belongs_to[:group].present? context[:tenant].groups.where(cap_belongs_to[‘group’]).map(&:users).flatten else [context[:current_user]] end stored_user_contents = (UserContent.select("DISTINCT ON (user_id) user_contents.*")) users.to_a missing_user_content_ids = users.ids – stored_user_contents.pluck(:user_id) missing_user_contents = missing_user_content_ids.map do |user_id| UserContent.new(user_id: user_id, on_fly: true) end…

  • Microservice Communication for Graphql APIs

    Microservice Communication for Graphql APIs

    1 Problem Statement : I have a GraphQl query defined which is responsible for fetching few details from the database. This graphql schema let’s say is defined in microservice-B . Now I want this garphql API to be called by an upstream microservice-A. microservice-A is actually the one which is actually called by our Clients(UI…

  • Another way of merging graphql resolvers

    Another way of merging graphql resolvers

    0 In many tutorials that I have read, the most common way of using graphql resolvers is like below. export const rootResolvers: IResolvers = { Query: { getUserById: async (root, { id }, context, info) => { return await getUserController(id); }, getUsers: async (root, args, context, info) => { return await getUsersController(); }, }, Mutation:…