Guide

Below you'll find examples using Graphql with any other language using apollo client.

You can copy paste the code in your graphql playground or open graphify playground to quickly test graphql API.



#Find all todo

query {
    findAllTodo {
        task
        isComplete
        user {
            id
            name
            email
            organization {
                name
            }
        }
    }
}

Output 👇

{
    "data": {
        "findAllTodo": [
            {
                "task": "task two",
                "isComplete": false,
                "user": {
                "id": "4865eb72-4a35-4a82-99ac-a04c034e47a5",
                "name": "NLP",
                "email": "nlp121@gmail.com",
                    "organization": {
                        "name": "Xsphere"
                    }
                }
            },
            {
                "task": "task one",
                "isComplete": false,
                "user": {
                "id": "4865eb72-4a35-4a82-99ac-a04c034e47a5",
                "name": "NLP",
                "email": "nlp121@gmail.com",
                    "organization": {
                        "name": "Xsphere"
                    }
                }
            }
        ]
    }
}   

#Find all todo by userId

query {
    findAllTodoByUserId(userId: "4865eb72-4a35-4a82-99ac-a04c034e47a5") {
        task
        isComplete
        user {
            id
            name
            email
            organization {
                name
            }
        }
    }
}

Output 👇

{
    "data": {
        "findAllTodoByUserId": [
            {
                "task": "task two",
                "isComplete": false,
                "user": {
                "id": "4865eb72-4a35-4a82-99ac-a04c034e47a5",
                "name": "NLP",
                "email": "nlp121@gmail.com",
                    "organization": {
                        "name": "Xsphere"
                    }
                }
            },
            {
                "task": "task one",
                "isComplete": false,
                "user": {
                "id": "4865eb72-4a35-4a82-99ac-a04c034e47a5",
                "name": "NLP",
                "email": "nlp121@gmail.com",
                    "organization": {
                        "name": "Xsphere"
                    }
                }
            }
        ]
    }
}   

#Find todo by id

query {
    findAllTodoById(id: "4865eb72-4a35-4a82-99ac-a04c034e47a5") {
        task
        isComplete
        user {
            id
            name
            email
            organization {
                name
            }
        }
    }
}

Output 👇

{
    "data": {
        "findAllTodoById":{
                "task": "task two",
                "isComplete": false,
                "user": {
                "id": "4865eb72-4a35-4a82-99ac-a04c034e47a5",
                "name": "NLP",
                "email": "nlp121@gmail.com",
                    "organization": {
                        "name": "Xsphere"
                    }
                }
            }
    }
}   

#Create todo

mutation {
createTodo(
    dto: { task: "task one", userId: "4865eb72-4a35-4a82-99ac-a04c034e47a5" }
    ){
        task
        isComplete
        user {
            id
            name
            email
            organization {
                name
            }
        }
    }
}

Output 👇

{
    "data": {
        "createTodo": {
        "task": "task two",
        "isComplete": false,
        "user": {
            "id": "4865eb72-4a35-4a82-99ac-a04c034e47a5",
            "name": "NLP",
            "email": "nlp121@gmail.com",
            "organization": {
                "name": "Xsphere"
                }
            }
            }
    }
} 

#Complete todo

query {
    completeTask(
        id: "4865eb72-4a35-4a82-99ac-a04c034e47a5"
        ){
            task
            isComplete
            user {
                id
                name
                email
                organization {
                    name
                }
            }
    }
}

Output 👇

{
    "data": {
        "completeTask": {
        "task": "task two",
        "isComplete": true,
        "user": {
            "id": "4865eb72-4a35-4a82-99ac-a04c034e47a5",
            "name": "NLP",
            "email": "nlp121@gmail.com",
            "organization": {
                "name": "Xsphere"
                }
            }
        }
    }
} 

#Delete todo

query {
    deleteTodo(
        id: "4865eb72-4a35-4a82-99ac-a04c034e47a5"
        ){
            task
            isComplete
            user {
                id
                name
                email
                organization {
                    name
                }
            }
    }
}

Output 👇

{
    "data": {
        "deleteTodo": {
            "task": "task two",
            "isComplete": true,
            "user": {
                "id": "4865eb72-4a35-4a82-99ac-a04c034e47a5",
                "name": "NLP",
                "email": "nlp121@gmail.com",
                "organization": {
                    "name": "Xsphere"
                    }
                }
        }
    }
}