From dbcb0c61304db01cc18ca71373041adc10fef90d Mon Sep 17 00:00:00 2001 From: Thisaru Guruge Date: Fri, 23 Dec 2022 17:08:35 +0530 Subject: [PATCH 1/3] Add Ballerina language and ballerina-graphql to language support --- .../ballerina/client/ballerina-graphql.md | 6 ++++ .../ballerina/server/ballerina-graphql.md | 28 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/content/code/language-support/ballerina/client/ballerina-graphql.md create mode 100644 src/content/code/language-support/ballerina/server/ballerina-graphql.md 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..58ae7df050 --- /dev/null +++ b/src/content/code/language-support/ballerina/client/ballerina-graphql.md @@ -0,0 +1,6 @@ +--- +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 +--- 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..e2e65268b1 --- /dev/null +++ b/src/content/code/language-support/ballerina/server/ballerina-graphql.md @@ -0,0 +1,28 @@ +--- +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.bal` to run the service, with with this code in the `graphql.bal` file: + +```ballerina +import ballerina/graphql; + +service 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 + From a45c38ff83f141cf57f2dfe12e73561ca265bb7b Mon Sep 17 00:00:00 2001 From: Thisaru Guruge Date: Fri, 23 Dec 2022 17:34:12 +0530 Subject: [PATCH 2/3] Add ballerina to slug-map --- src/content/code/slug-map.json | 1 + 1 file changed, 1 insertion(+) 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", From 39c82876a06c9b4d96ff42119586e3223744ef38 Mon Sep 17 00:00:00 2001 From: Thisaru Guruge Date: Thu, 5 Jan 2023 19:51:15 +0530 Subject: [PATCH 3/3] Add example for Ballerina client --- .../ballerina/client/ballerina-graphql.md | 21 +++++++++++++++++++ .../ballerina/server/ballerina-graphql.md | 5 ++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/content/code/language-support/ballerina/client/ballerina-graphql.md b/src/content/code/language-support/ballerina/client/ballerina-graphql.md index 58ae7df050..6e40c1eaed 100644 --- a/src/content/code/language-support/ballerina/client/ballerina-graphql.md +++ b/src/content/code/language-support/ballerina/client/ballerina-graphql.md @@ -4,3 +4,24 @@ 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 index e2e65268b1..4f24d246d2 100644 --- a/src/content/code/language-support/ballerina/server/ballerina-graphql.md +++ b/src/content/code/language-support/ballerina/server/ballerina-graphql.md @@ -8,12 +8,12 @@ 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.bal` to run the service, with with this code in the `graphql.bal` file: +- 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 on new graphql:Listener(9090) { +service /graphql on new graphql:Listener(9090) { resource function get hello() returns string { return "Hello, world!"; } @@ -25,4 +25,3 @@ service on new graphql:Listener(9090) { - Supports subscriptions over websocket (No additional libraries needed) - Supports file upload - Built-in GraphiQL client -