Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

How can I give graphQL context of current signed in user? #563

@dan-fein

Description

@dan-fein

I have the below definition for a Thing and I can't seem to figure out how to get isFollowing to work as it's not clear how to pass custom variables to neo4j-graphql-js.

I thought I might be able to put them in my query e.g:

query get_thing {
Thing (id: "QEQXbK2Z6Ngp40TMOYKVx73XtEu2", uid: "ffe38a42-474f-4426-bc45-2453e19a4d83") {
id
isFollowing
}

but it doesn't seem like there's any way for the "uid" variable that I passed to make its way to the Type Definition here, to be used for the "isFollowing" cypher directive.

type Thing {
    id: String,
    name: String,
    description: String,
    image: String,
    followers: [User] @relation(name: "FOLLOWS", direction: "IN"),
    follower_count: Int @cypher(statement: """
        MATCH (u:User)-[:FOLLOWS]->(this)
        RETURN count(u)
    """),
    isFollowing: Boolean @cypher(statement: """
            MATCH (u:User {id: $cypherParams.currentUserId}),(this)
            RETURN EXISTS((u)-[:FOLLOWS]->(t))
        """),
}

I've seen the ability to add contextParams to an @cypher directive (here), but it's unclear how to inject information like that into a query such that it's even retrievable from "req".

Any thoughts on how to pass a currently signed in user's ID in a graphql query to neo4j-graphql-js?

Thank you in advance, and Happy New Year!

I'm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions