@belongsToMany with @paginate

@belongsToMany with @paginate


0

Simple models, we have a user and a user is part of topics. The linking is done through a pivot table. Both users and topics have the correct relationships. The query works. But. Now we need to add the pagination to it.

type User {
    id: ID!
    uuid: String!
    email: String!
    api_token: String!
    devices: [Device]

    topics(
        orderBy: _ @orderBy(
            columns: ["created_at", "last_message_at"]
        )
    ): [Topic] @belongsToMany @paginate(type: SIMPLE)

    created_at: DateTime!
    updated_at: DateTime!
}

type Topic {
    uuid: String!
    user_uuid: String!
    title: String!
    slug: String!
    key: String!
    last_message_at: DateTime!
}

extend type Query @guard {
    me: User @auth
}

Above the Schema, when we remove the @paginate from the user, it works without pagination. Now we need the pagination on this.

This is our GraphQL query:

{
  me {
    email
    topics {
      title
      last_message_at
    }
    }
  }

And we get the following error:

Node topics can only have one directive of type Nuwave\Lighthouse\Support\Contracts\FieldResolver but found [@belongsToMany, @paginate].",


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *