diff --git a/src/content/code/language-support/ballerina/client/ballerina-graphql.md b/src/content/code/language-support/ballerina/client/ballerina-graphql.md new file mode 100644 index 0000000000..6e40c1eaed --- /dev/null +++ b/src/content/code/language-support/ballerina/client/ballerina-graphql.md @@ -0,0 +1,27 @@ +--- +name: ballerina-graphql +description: The Ballerina Standard Library Package for consume GraphQL services. +url: https://lib.ballerina.io/ballerina/graphql/latest +github: ballerina-platform/module-ballerina-graphql +--- + +To run a `ballerina-graphql` client: + +- Download and install [Ballerina Language](https://ballerina.io/downloads) +- Then run `bal run graphql_client.bal` to run the service, with with this code in the `graphql_client.bal` file: + +```ballerina +import ballerina/graphql; +import ballerina/io; + +type Response record { + record { string hello; } data; +}; + +public function main() returns error? { + graphql:Client helloClient = check new ("localhost:9090/graphql"); + string document = "{ hello }"; + Response response = check helloClient->execute(document); + io:println(response.data.hello); +} +``` diff --git a/src/content/code/language-support/ballerina/server/ballerina-graphql.md b/src/content/code/language-support/ballerina/server/ballerina-graphql.md new file mode 100644 index 0000000000..4f24d246d2 --- /dev/null +++ b/src/content/code/language-support/ballerina/server/ballerina-graphql.md @@ -0,0 +1,27 @@ +--- +name: ballerina-graphql +description: The Ballerina Standard Library Package for write GraphQL services. +url: https://lib.ballerina.io/ballerina/graphql/latest +github: ballerina-platform/module-ballerina-graphql +--- + +To run a `ballerina-graphql` hello world server: + +- Download and install [Ballerina Language](https://ballerina.io/downloads) +- Then run `bal run graphql_service.bal` to run the service, with with this code in the `graphql_service.bal` file: + +```ballerina +import ballerina/graphql; + +service /graphql on new graphql:Listener(9090) { + resource function get hello() returns string { + return "Hello, world!"; + } +} +``` + +## Features +- Built with Ballerina `service` and `listener` model, which are first-class citizens in Ballerina +- Supports subscriptions over websocket (No additional libraries needed) +- Supports file upload +- Built-in GraphiQL client diff --git a/src/content/code/slug-map.json b/src/content/code/slug-map.json index a4895135eb..275f1a1826 100644 --- a/src/content/code/slug-map.json +++ b/src/content/code/slug-map.json @@ -1,4 +1,5 @@ { + "ballerina": "Ballerina", "c-c": "C / C++", "c-net": "C# / .NET", "clojure": "Clojure",