Skip to content

Is there an example of a Graphiti schema using connections? #40

@cshadek

Description

@cshadek

I noticed that @paulofaria added connections in an earlier commit. I was trying to use them in my code but have not succeeded in getting them working.

Here is what I have been trying. What am I missing here?

Inside the Schema Definition:

Type(User.self,
Field("id", at: \.id).description("The unique id of the user."),
Field("followersConnection", at: User.followers).description("The followers connection")
)

In another file:

class User: Codable, Identifiable {
var id: String? = UUID().uuidString

func followers(context: UserContext, arguments: ForwardPaginationArguments) -> EventLoopFuture<Connection<User>> {
        let arr = context.request.eventLoop.makeSucceededFuture([User()])
        return arr.connection(from: arguments)
    }
}

I get this error:

[ ERROR ] Cannot use type "Connection<User>" for field "followersConnection". Type does not map to a GraphQL type.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions