AddThis

Wednesday 21 October 2020

How to format graphql query string in Java


import graphql.language.AstPrinter;
import graphql.language.Document;
import graphql.parser.Parser;

public class GraphqlQueryFormatter {
    public static void main(String[] args) {
        String gql = "query { getEmployee (employeeId:"4859493") { name dob department } ";
        Parser parser = new Parser();
        Document doc = parser.parseDocument(gql);
        System.out.println(AstPrinter.printAst(doc));
    }
}

No comments:

Post a Comment

100 AWS Services in Just One Line Each

  100 AWS Services in Just One Line Each Amazon EC2:  Virtual servers in the cloud. Amazon S3:  Scalable object storage service. Amazon RDS:...