Skip to content

Graphql resolver field not executed #5458

@kjurenec

Description

@kjurenec

Hi, I created schema.graphql.js in ./api/organization/config/ folder with content:

module.exports = {
  resolver: {
    Query: {
      organizations: {
        resolverOf: "application::organization.organization.find",
        resolver: async (obj, options, { context }) => {
          const { modelName } = strapi.api.organization.models.organization;
          return strapi.query(modelName).find({}, []);
        }
      }
    },
    Organization: {
      name: ({ name }) => name,
      id: ({id}) => id,
      locations: {
        resolverOf: "application::location.location.find",
        resolver: () => {
          return [];
        }
      }
    }
  }
};

When i try tu execute query:

{
  organizations { 
   id
    name
    locations {
      name
    }
  }
}

It all works. Data is returned, but i expected for organization.locations (locations is the collection type same as organizations) to return an empty array, but it returns real data. The same problem is with organization.id field. I tested organization.name, and that field is getting executed.

System

  • Node.js version: 12.13.0
  • NPM version: 6.12.0
  • Strapi version: 3.0.0-beta.19.3
  • Database: sqlite
  • Operating system: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions