Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Mutation Operation #1492

Closed
shafreenAnfar opened this issue Jun 17, 2021 · 2 comments · Fixed by ballerina-platform/module-ballerina-graphql#360
Closed

Support for Mutation Operation #1492

shafreenAnfar opened this issue Jun 17, 2021 · 2 comments · Fixed by ballerina-platform/module-ballerina-graphql#360
Assignees
Labels
module/graphql Issues related to Ballerina GraphQL module Priority/High Team/PCM Protocol connector packages related issues Type/Improvement

Comments

@shafreenAnfar
Copy link
Contributor

Description:
For more details see here.

@shafreenAnfar shafreenAnfar added Type/Improvement module/graphql Issues related to Ballerina GraphQL module Priority/High labels Jun 17, 2021
@ldclakmal ldclakmal added the Team/PCM Protocol connector packages related issues label Jun 25, 2021
@ThisaruGuruge
Copy link
Member

Example Implementation of a mutation operation:

import ballerina/graphql;

service /graphql on new graphql:Listener(9000) {
    remote function updateCity(int id, string newCity) returns Person {
        Person p = people[id];
        p.address.city = newCity;
        return p;
    }
}

Person[] people = [
    {
        name: "Walter White",
        age: 51,
        address: {
            number: "308",
            street: "Negra Arroyo Lane",
            city: "Albuquerque"
        }
    }
];

type Person record {|
    string name;
    int age;
    Address address;
|};

type Address record {|
    string number;
    string street;
    string city;
|};

Now, this can be mutated by using the following document:

mutation City {
    updateCity(id: 0, newCity: "New Hampshire") {
        name
        address {
            city
        }
    }
}

The result should be:

{
    "data": {
        "updateCity": {
            "name": "Walter White",
            "address": {
                "city": "New Hampshire"
            }
        }
    }
}

@ThisaruGuruge
Copy link
Member

This is currently blocked due to ballerina-platform/ballerina-lang#31581

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/graphql Issues related to Ballerina GraphQL module Priority/High Team/PCM Protocol connector packages related issues Type/Improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants