Swan Lake Beta2 is here.
import ballerina/graphql;

// A GraphQL listener can be configured to communicate through HTTPS as well.
// To secure an listener using HTTPS, the listener needs to be configured with
// a certificate file and a private key file for the listener.
// The [`graphql:ListenerSecureSocket`](https://docs.central.ballerina.io/ballerina/graphql/latest/records/ListenerSecureSocket) record
// provides the SSL-related listener configurations of the listener.
listener graphql:Listener securedEP = new(9090,
    secureSocket = {
        key: {
            certFile: "../resource/path/to/public.crt",
            keyFile: "../resource/path/to/private.key"
        }
    }
);

service /graphql on securedEP {
    resource function get greeting() returns string {
        return "Hello, World!";
    }
}

Service - SSL/TLS

You can use the GraphQL listener to connect to or interact with an HTTPS client. Provide the graphql:ListenerSecureSocket configurations to the server to expose an HTTPS connection.

For more information on the underlying module, see the GraphQL module.

import ballerina/graphql;
listener graphql:Listener securedEP = new(9090,
    secureSocket = {
        key: {
            certFile: "../resource/path/to/public.crt",
            keyFile: "../resource/path/to/private.key"
        }
    }
);

A GraphQL listener can be configured to communicate through HTTPS as well. To secure an listener using HTTPS, the listener needs to be configured with a certificate file and a private key file for the listener. The graphql:ListenerSecureSocket record provides the SSL-related listener configurations of the listener.

service /graphql on securedEP {
    resource function get greeting() returns string {
        return "Hello, World!";
    }
}
import ballerina/graphql;

// A GraphQL listener can be configured to communicate through HTTPS as well.
// To secure an listener using HTTPS, the listener needs to be configured with
// a certificate file and a private key file for the listener.
// The [`graphql:ListenerSecureSocket`](https://docs.central.ballerina.io/ballerina/graphql/latest/records/ListenerSecureSocket) record
// provides the SSL-related listener configurations of the listener.
listener graphql:Listener securedEP = new(9090,
    secureSocket = {
        key: {
            certFile: "../resource/path/to/public.crt",
            keyFile: "../resource/path/to/private.key"
        }
    }
);

service /graphql on securedEP {
    resource function get greeting() returns string {
        return "Hello, World!";
    }
}

Service - SSL/TLS

You can use the GraphQL listener to connect to or interact with an HTTPS client. Provide the graphql:ListenerSecureSocket configurations to the server to expose an HTTPS connection.

For more information on the underlying module, see the GraphQL module.

import ballerina/graphql;
listener graphql:Listener securedEP = new(9090,
    secureSocket = {
        key: {
            certFile: "../resource/path/to/public.crt",
            keyFile: "../resource/path/to/private.key"
        }
    }
);

A GraphQL listener can be configured to communicate through HTTPS as well. To secure an listener using HTTPS, the listener needs to be configured with a certificate file and a private key file for the listener. The graphql:ListenerSecureSocket record provides the SSL-related listener configurations of the listener.

service /graphql on securedEP {
    resource function get greeting() returns string {
        return "Hello, World!";
    }
}

In the creation of Ballerina, we were inspired by so many technologies. Thank you to all that have come before us (and forgive us if we missed one): Java, Go, C, C++, D, Rust, Haskell, Kotlin, Dart, TypeScript, JavaScript, Python, Perl, Flow, Swift, Elm, RelaxNG, NPM, Crates, Maven, Gradle, Kubernetes, Docker, Envoy, Markdown, GitHub and WSO2.

Cookie Policy

This website uses cookies so that we can provide you with the best user experience. Read our Cookie Policy to find out more.

If you wish to disable cookies you can do so from your browser.

I Understand