Hi guys, I'm trying to use grapql-request to make ...
# orm-help
j
Hi guys, I'm trying to use grapql-request to make request server side, how can I pass the filtering option in the request method? I'm trying to do something like this but with no luck
Copy code
const query = `
        query getUser($filters: UserFilter) {
            allUsers(
                filter: $filters
            ){
                id
                email
            }
        }
    `

    const variables = {
        OR: [
            { email: userEmail },
            { id: userId }
        ]
    }

    graphcool.api('simple/v1').request<{ User }>(query, variables)
h
You can just use them as string and concatenate them like so
Copy code
const query = `
        query getUser{
            allUsers(
                filter: ${variables}
            ){
                id
                email
            }
        }
    `

    const variables =` {
        OR: [
            { email: userEmail },
            { id: userId }
        ]
    }`

    graphcool.api('simple/v1').request<{ User }>(query, variables)