{"id":13769792,"url":"https://github.com/friatech/lilo","last_synced_at":"2025-05-11T02:33:26.428Z","repository":{"id":38388981,"uuid":"476715962","full_name":"friatech/lilo","owner":"friatech","description":"Lilo is a super-fast, easy-to-use, configurable GraphQL stitching library","archived":false,"fork":false,"pushed_at":"2024-05-26T10:54:09.000Z","size":432,"stargazers_count":38,"open_issues_count":4,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-17T05:33:50.196Z","etag":null,"topics":["graphql","graphql-java","graphql-stitching","java","stitching"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/friatech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-01T12:42:16.000Z","updated_at":"2024-09-14T18:47:03.000Z","dependencies_parsed_at":"2024-11-17T05:31:47.525Z","dependency_job_id":"3ac9a351-909c-44e7-acef-62bd28ddba50","html_url":"https://github.com/friatech/lilo","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friatech%2Flilo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friatech%2Flilo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friatech%2Flilo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friatech%2Flilo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/friatech","download_url":"https://codeload.github.com/friatech/lilo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253507210,"owners_count":21919174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","graphql-java","graphql-stitching","java","stitching"],"created_at":"2024-08-03T17:00:31.578Z","updated_at":"2025-05-11T02:33:25.844Z","avatar_url":"https://github.com/friatech.png","language":"Java","readme":"# Lilo [![Build Status](https://github.com/friatech/lilo/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/friatech/lilo/actions/workflows/ci.yml?query=branch%3Amain) [![Latest Release](https://img.shields.io/maven-central/v/io.fria/lilo?versionPrefix=24.)](https://maven-badges.herokuapp.com/maven-central/io.fria/lilo/) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n![Lilo and Stitch](resources/lilo-and-stitch.webp)\n\n**Lilo** is a super-fast GraphQL stitching library. The project is heavily inspired by [Atlassian Braid](https://bitbucket.org/atlassian/graphql-braid).\n**Lilo** focuses on simplicity and easy to use. You can find plenty of samples in the codebase and we aim to add more and more in every release.\nPlease do not forget to check `/samples` directory.\n\nWe are planning to add additional frameworks supports. For now SpringBoot is supported. If you will use `Lilo` with `SpringBoot`. Please check [Lilo Spring Documentation](lilo-spring/README.md).\n\n## Installation\n\nJust add a single **Lilo** dependency to your `pom.xml` file.\n\n```xml\n\u003cdependencies\u003e\n  ...\n  \u003cdependency\u003e\n    \u003cgroupId\u003eio.fria\u003c/groupId\u003e\n    \u003cartifactId\u003elilo\u003c/artifactId\u003e\n    \u003cversion\u003e24.5.0\u003c/version\u003e\n  \u003c/dependency\u003e\n  ...\n\u003c/dependencies\u003e\n```\n\nIf you're using gradle add the dependency to your `build.gradle` file.\n\n```groovy\nimplementation 'io.fria:lilo:24.5.0'\n```\n\n## Basic Usage\n\nHere is the story, Alice has 2 GraphQL microservices and she wants to make her gateway to dispatch\nthe GraphQL requests to their respective microservices. `Microservice A` provides a GraphQL query for user listing,\nand `Microservice B` provides a GraphQL mutation for user creation. So Alice can use both query and mutation via\njust sending requests to the `Gateway` directly. **Lilo** stitches the GraphQL schemas and provides a combined schema.\n\n```\n  +----------------+\n  |                |\n  | Microservice A | \u003c---------+\n  |                |           |            +----------------+\n  +----------------+           |            |                |        o~\n                               +----------- |    Gateway     | \u003c---- /|\\\n  +----------------+           |            |                |       / \\\n  |                |           |            +----------------+\n  | Microservice B | \u003c---------+\n  |                |\n  +----------------+\n\n```\n\nA very basic working example for that scenario would be:\n\n```java\nfinal Lilo lilo = Lilo.builder()\n    .addSource(RemoteSchemaSource.create(\"SERVER_1\", \"https://server1/graphql\"))\n    .addSource(RemoteSchemaSource.create(\"SERVER_2\", \"https://server2/graphql\"))\n    .build();\n```\n\nBut for a complete working example you need to serve the stitching logic from a GraphQL endpoint. (Probably `/graphql`)\nPlease examine the `01-spring-boot-hello-world` example in `lilo-samples` folder.\n\nIn most cases, we need an authentication or some sort of header manipulation. In that case, creating custom\nintrospection and query retrievers might help us to modify outgoing requests or incoming responses. The following\nexample shows a very basic example for custom retrievers.\n\n```java\n    .addSource(\n        RemoteSchemaSource.create(\n            \"SERVER_1\",\n            new MyIntrospectionRetriever(\"https://server1/graphql\"),\n            new MyQueryRetriever(\"https://server1/graphql\")\n        )\n    )\n    .addSource(\n        RemoteSchemaSource.create(\n            \"SERVER_2\",\n            new MyIntrospectionRetriever(\"https://server2/graphql\"),\n            new MyQueryRetriever(\"https://server2/graphql\")\n        )\n    )\n```\n\nFor further details, you can examine the `02-spring-boot-basic-stitching` example in `lilo-samples` folder.\n\nIf Gateway distributes the messages to `Microservice A` and also contains an embedded schema then the architecture might\nbe something like this:\n\n```\n\n  +----------------+                       +----------------+\n  |                |                       |                |        o~\n  | Microservice A |---------------------- |    Gateway     | \u003c---- /|\\\n  |                |                       |                |       / \\\n  +----------------+                       +----------------+\n                                                  A    |\n                                                  |    |\n                                                  +\u003c---+\n```\n\n```java\nfinal Lilo lilo = Lilo.builder()\n    .addSource(\n        RemoteSchemaSource.create(\n            \"SERVER_1\",\n            new MyIntrospectionRetriever(\"https://server1/graphql\"),\n            new MyQueryRetriever(\"https://server1/graphql\")\n        )\n    )\n    .addSource(\n        DefinedSchemaSource.create(\n            \"SCHEMA_2\",\n            stringQueryDefinition,\n            typeWiring\n        )\n    )\n    .build();\n```\n\nWe need to provide an `IntrospectionRetriever` and `QueryRetriever`. Those can fetch the query result from\na remote source and/or local source.\n\nAfter source definitions are properly set you can run your implementation similar to this:\n\n```java\nfinal Map\u003cString, Object\u003e resultMap = lilo.stitch(\"{greeting1}\").toSpecification();\n```\n\nOr more advanced GraphQL request which includes querym operation name and variables:\n\n```java\n\nfinal GraphQLRequest graphQLRequest = GraphQLRequest.builder()\n    .query(incomingGraphQlQuery)\n    .operationName(incomingGraphQlOperationName)\n    .variables(incomingGraphQlVariables)\n    .build();\n\nfinal Map\u003cString, Object\u003e resultMap = lilo.stitch(graphQLRequest.toExecutionInput()).toSpecification();\n```\n\n## Parameter passing\n\nSometimes an HTTP header or a JWT token must be passed to the retrievers. You can pass a local context object\ninside the execution input.\n\n```java\nfinal ExecutionInput executionInput = ExecutionInput.newExecutionInput()\n    .localContext(\"aLocalContextObject\")\n    .query(\"{add(a: 1, b: 2)}\")\n    .build();\n```\n\nThe localContext object is now accessible from your `IntrospectionRetriever` and `QueryRetriever`.\n\n## Subscription\n\nGraphQL provides a subscription methodology for providing continuous data. It's a well-known pub/sub pattern for applications. \nIf your application needs a continuous stream of real-time events, notifications, sensor data. Subscription might be wise\nchoice for you.\n\n### Use Lilo framework library\n\nSubscription usage needs a few configuration class definition and handlers definition. Lilo core library is framework-agnostic. If you are using\na framework like SpringBoot. Please check the lilo documentation for that specific framework. Currently, `SpringBoot` is supported.\nPlease check [Lilo Spring Documentation](lilo-spring/README.md).\n\n### Subscription Usage\n\nIf you're going to use Subscription stitching. You need to define an additional retriever other than `QueryRetriever` and `IntrospectionRetriever`.\nAs you might guess, it's a `SubscriptionRetriever`. Besides retrievers, we need to define handlers:\n- `SubscriptionGatewayHandler` is responsible for handling web socket sessions coming from GraphQL clients to Lilo Stitching Gateway.\n- `SubscriptionSourceHandler` is responsible for handling websocket sessions going from gateway to remote GraphQL servers.\n\nSince those handler classes are framework-agnostic. A binding should be implemented between framework and handlers.\n\n## Additional Resources\n\nYou can watch `Tame Your Spring Microservices With GraphQL Stitching Using Lilo` presentation.\n\n[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/5GQpxqORlr0/0.jpg)](https://www.youtube.com/watch?v=5GQpxqORlr0)\n\n## Lilo's sisters\n\n- [Atlassian Braid](https://bitbucket.org/atlassian/graphql-braid)\n- [GraphQuilt Orchestrator](https://github.com/graph-quilt/graphql-orchestrator-java)\n","funding_links":[],"categories":["Schema Libraries"],"sub_categories":["Schema First"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriatech%2Flilo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriatech%2Flilo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriatech%2Flilo/lists"}