Graphql findOne by slug

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

I got this super annoying problem.
Need to get my posts by slug from graphql.
By id works fine.
I am using this code but it returns null
It is a standard post simple object
Any help?

// src/index.js
‘use strict’;

module.exports = {

  • An asynchronous register function that runs before
  • your application is initialized.
  • This gives you an opportunity to extend code.
    register({ strapi }) {
    const extensionService = strapi.plugin(“graphql”).service(“extension”);
const extension = () => ({
  typeDefs: `
    type Query {
      post(slug: String!): PostEntityResponse
  resolvers: {
    Query: {
      post: {
        resolve: async (parent, args, context) => {
          const { toEntityResponse } = strapi.service(
          const data = await[""].findOne({'slug' : args.slug}); 
          const response = toEntityResponse(data.results[0]);
          return response;


bootstrap(/{ strapi }/) {},

I got this message from graphql “message”: “Undefined attribute level operator slug”,
I cant find any documentation where to update schema for slug that is present in the model
Now either post(id: “1”) { or post(slug: “test”) { works. Help!

It would be great to have such a access like in other Headless CMS (keystone6) where you can query this way:

query Post {
post(where: {slug: null}) {

What i’ve done to come up with a solution is to query posts(not post) by filtering by slug and limit the result to 1 using limit:1. Then you only need to fetch the first element.