Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
kyri-petrou committed May 24, 2024
2 parents 6531319 + c849e0e commit 364d255
Show file tree
Hide file tree
Showing 274 changed files with 6,373 additions and 5,280 deletions.
42 changes: 21 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.13.13 check ++3.3.3 check
- run: sbt ++2.13 check ++3.3 check
- save_cache:
key: sbtcache
paths:
Expand All @@ -23,7 +23,7 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.12.19 rootJVM212/test
- run: sbt ++2.12 rootJVM212/test
- save_cache:
key: sbtcache
paths:
Expand All @@ -38,7 +38,7 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.12.19 codegenSbt/scripted
- run: sbt ++2.12 codegenSbt/scripted
- save_cache:
key: sbtcache
paths:
Expand Down Expand Up @@ -68,22 +68,22 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.13.13 rootJVM213/test examples/compile benchmarks/compile
- run: sbt ++2.13 rootJVM213/test examples/compile benchmarks/test
- save_cache:
key: sbtcache
paths:
- "~/.ivy2/cache"
- "~/.sbt"
- "~/.m2"
test213_jdk17:
test213_jdk21:
docker:
- image: cimg/openjdk:17.0-node
- image: cimg/openjdk:21.0-node
resource_class: large
steps:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.13.13 rootJVM213/test examples/compile benchmarks/compile
- run: sbt ++2.13 rootJVM213/test examples/compile benchmarks/test
- save_cache:
key: sbtcache
paths:
Expand All @@ -98,22 +98,22 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++3.3.3 rootJVM3/test benchmarks/compile
- run: sbt ++3.3 rootJVM3/test benchmarks/test
- save_cache:
key: sbtcache
paths:
- "~/.ivy2/cache"
- "~/.sbt"
- "~/.m2"
test3_jdk17:
test3_jdk21:
docker:
- image: cimg/openjdk:17.0-node
- image: cimg/openjdk:21.0-node
resource_class: large
steps:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++3.3.3 rootJVM3/test benchmarks/compile
- run: sbt ++3.3 rootJVM3/test benchmarks/test
- save_cache:
key: sbtcache
paths:
Expand All @@ -129,7 +129,7 @@ jobs:
- restore_cache:
key: sbtcache
- run: ./.circleci/install-native-deps.sh
- run: sbt ++2.13.13 clientJS/test clientLaminextJS/Test/fastLinkJS clientNative/Test/nativeLink
- run: sbt ++2.13 clientJS/test clientLaminextJS/Test/fastLinkJS clientNative/Test/nativeLink
- save_cache:
key: sbtcache
paths:
Expand All @@ -145,7 +145,7 @@ jobs:
- restore_cache:
key: sbtcache
- run: ./.circleci/install-native-deps.sh
- run: sbt ++3.3.3 clientJS/test clientLaminextJS/Test/fastLinkJS clientNative/Test/nativeLink
- run: sbt ++3.3 clientJS/test clientLaminextJS/Test/fastLinkJS clientNative/Test/nativeLink
- save_cache:
key: sbtcache
paths:
Expand All @@ -161,8 +161,8 @@ jobs:
- restore_cache:
key: sbtcache
- run: |
sbt ++2.13.13 docs/mdoc
sbt "++2.13.13 doc"
sbt ++2.13 docs/mdoc
sbt "++2.13 doc"
- save_cache:
key: sbtcache
paths:
Expand All @@ -177,8 +177,8 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++2.13.13 http4s/mimaReportBinaryIssues akkaHttp/mimaReportBinaryIssues pekkoHttp/mimaReportBinaryIssues catsInterop/mimaReportBinaryIssues monixInterop/mimaReportBinaryIssues clientJVM/mimaReportBinaryIssues clientJS/mimaReportBinaryIssues clientLaminextJS/mimaReportBinaryIssues federation/mimaReportBinaryIssues reporting/mimaReportBinaryIssues tracing/mimaReportBinaryIssues core/mimaReportBinaryIssues tapirInterop/mimaReportBinaryIssues quickAdapter/mimaReportBinaryIssues zioHttp/mimaReportBinaryIssues play/mimaReportBinaryIssues # tools/mimaReportBinaryIssues
- run: sbt ++3.3.3 catsInterop/mimaReportBinaryIssues monixInterop/mimaReportBinaryIssues clientJVM/mimaReportBinaryIssues clientJS/mimaReportBinaryIssues clientLaminextJS/mimaReportBinaryIssues http4s/mimaReportBinaryIssues federation/mimaReportBinaryIssues reporting/mimaReportBinaryIssues tracing/mimaReportBinaryIssues core/mimaReportBinaryIssues tapirInterop/mimaReportBinaryIssues pekkoHttp/mimaReportBinaryIssues quickAdapter/mimaReportBinaryIssues zioHttp/mimaReportBinaryIssues play/mimaReportBinaryIssues # tools/mimaReportBinaryIssues
- run: sbt ++2.13 http4s/mimaReportBinaryIssues akkaHttp/mimaReportBinaryIssues pekkoHttp/mimaReportBinaryIssues catsInterop/mimaReportBinaryIssues monixInterop/mimaReportBinaryIssues clientJVM/mimaReportBinaryIssues clientJS/mimaReportBinaryIssues clientLaminextJS/mimaReportBinaryIssues federation/mimaReportBinaryIssues reporting/mimaReportBinaryIssues tracing/mimaReportBinaryIssues core/mimaReportBinaryIssues tapirInterop/mimaReportBinaryIssues quickAdapter/mimaReportBinaryIssues zioHttp/mimaReportBinaryIssues play/mimaReportBinaryIssues # tools/mimaReportBinaryIssues
- run: sbt ++3.3 catsInterop/mimaReportBinaryIssues monixInterop/mimaReportBinaryIssues clientJVM/mimaReportBinaryIssues clientJS/mimaReportBinaryIssues clientLaminextJS/mimaReportBinaryIssues http4s/mimaReportBinaryIssues federation/mimaReportBinaryIssues reporting/mimaReportBinaryIssues tracing/mimaReportBinaryIssues core/mimaReportBinaryIssues tapirInterop/mimaReportBinaryIssues pekkoHttp/mimaReportBinaryIssues quickAdapter/mimaReportBinaryIssues zioHttp/mimaReportBinaryIssues play/mimaReportBinaryIssues # tools/mimaReportBinaryIssues
- save_cache:
key: sbtcache
paths:
Expand Down Expand Up @@ -268,7 +268,7 @@ workflows:
filters:
tags:
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
- test213_jdk17:
- test213_jdk21:
requires:
- lint
filters:
Expand All @@ -289,7 +289,7 @@ workflows:
filters:
tags:
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
- test3_jdk17:
- test3_jdk21:
requires:
- lint
filters:
Expand All @@ -311,11 +311,11 @@ workflows:
- scripted212_jdk
- scripted3_jdk
- test213_jdk
- test213_jdk17
- test213_jdk21
- test213_js_native
- test213_docs
- test3_jdk
- test3_jdk17
- test3_jdk21
- test3_js_native
- test_mima
filters:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/compatibility.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Federation Specification Compatibility Test

on:
pull_request:
branches:
- series/2.x

jobs:
compatibility:
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'adopt'
cache: 'sbt'
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Run assembly
run: sbt "apolloCompatibility/assembly"

- name: Compatibility Test
uses: apollographql/federation-subgraph-compatibility@v2
with:
compose: 'apollo-compatibility/docker-compose.yaml'
schema: 'apollo-compatibility/products.graphql'
path: '/graphql'
port: 4001
debug: true
# Boolean flag to indicate whether any failing test should fail the script
failOnWarning: false
# Boolean flag to indicate whether any required test should fail the script
failOnRequired: false
# Working directory to run the test from
workingDirectory: ''
8 changes: 6 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version = "3.1.2"

version = "3.8.1"
runner.dialect = scala213
maxColumn = 120
align.preset = most
Expand All @@ -22,3 +21,8 @@ fileOverride {
runner.dialect = scala3
}
}

project.excludePaths = [
"glob:**/target/**"
"glob:**/resources/**"
]
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Contributing to Caliban

First off, thanks for taking the time to contribute! 🎉
The following is a set of guidelines for contributing to Caliban.

## Code of Conduct

This project and everyone participating in it is governed by the [Caliban Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.

## How Can I Contribute?

### Reporting Bugs

If you find a bug, please report it by opening a new issue in the [Issues section](https://github.com/ghostdogpr/caliban/issues) and include:

- A clear and descriptive title.
- A detailed description of the problem.
- Steps to reproduce the issue.
- Any relevant logs, screenshots, or files that may help us understand the issue.

### Suggesting Features

If you have an idea for a new feature, please suggest it by opening a new issue in the [Issues section](https://github.com/ghostdogpr/caliban/issues) and include:

- A clear and descriptive title.
- A detailed description of the feature.
- Any relevant sample code, diagrams, or screenshots.

### Submitting Changes

1. Fork the repository.
2. Create a new branch (`git checkout -b feature/YourFeature`).
3. Make your changes.
4. Format your code using the `fmt` command in sbt.
5. Ensure all tests pass.
6. Commit your changes (`git commit -m 'Add some feature'`).
7. Push to the branch (`git push origin feature/YourFeature`).
8. Open a pull request. It will trigger the CI to run various with different Scala versions and platforms.

## Additional Notes

- If you have questions or need help, feel free to ask on our [Discord channel](https://discordapp.com/channels/629491597070827530/633200096393166868) or open an issue.
- Before starting to work on a major change, please open an issue to discuss your proposed changes to ensure they fit within the project's scope and are not already being worked on.

Thank you for contributing to Caliban!
12 changes: 2 additions & 10 deletions adapters/http4s/src/test/scala/caliban/Http4sAdapterSpec.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package caliban

import caliban.interop.tapir.TestData.sampleCharacters
import caliban.interop.tapir.{
FakeAuthorizationInterceptor,
HttpInterpreter,
HttpUploadInterpreter,
TapirAdapterSpec,
TestApi,
TestService,
WebSocketInterpreter
}
import caliban.interop.tapir._
import caliban.uploads.Uploads
import com.comcast.ip4s._
import com.github.plokhotnyuk.jsoniter_scala.core._
import com.github.plokhotnyuk.jsoniter_scala.macros._
import fs2.io.net.Network
import org.http4s.ember.server.EmberServerBuilder
import org.http4s.server.Router
import org.http4s.server.middleware.CORS
Expand All @@ -22,7 +15,6 @@ import sttp.tapir.Codec.JsonCodec
import zio._
import zio.interop.catz._
import zio.test.{ Live, ZIOSpecDefault }
import fs2.io.net.Network

import scala.language.postfixOps

Expand Down
3 changes: 3 additions & 0 deletions adapters/quick/src/main/scala/caliban/GraphiQLHandler.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package caliban

import zio.Trace
import zio.http._
import zio.stacktracer.TracingImplicits.disableAutoTrace

object GraphiQLHandler {
private implicit val trace: Trace = Trace.empty

/**
* Creates a handler which serves the GraphiQL UI from CDN.
Expand Down
26 changes: 19 additions & 7 deletions adapters/quick/src/main/scala/caliban/QuickAdapter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package caliban
import caliban.Configurator.ExecutionConfiguration
import zio._
import zio.http._
import zio.stacktracer.TracingImplicits.disableAutoTrace

final class QuickAdapter[-R] private (requestHandler: QuickRequestHandler[R]) {
final class QuickAdapter[R] private (requestHandler: QuickRequestHandler[R]) {

private implicit val trace: Trace = Trace.empty

/**
* Converts this adapter to a [[QuickHandlers]] which contains [[zio.http.RequestHandler]]s for manually constructing zio-http routes
Expand All @@ -20,19 +23,19 @@ final class QuickAdapter[-R] private (requestHandler: QuickRequestHandler[R]) {
Handler.fromFunctionZIO[Request](requestHandler.handleHttpRequest)

/**
* Converts this adapter to an `HttpApp` serving the GraphQL API at the specified path.
* Converts this adapter to an `Routes` serving the GraphQL API at the specified path.
*
* @param apiPath The path where the GraphQL API will be served.
* @param graphiqlPath The path where the GraphiQL UI will be served. If None, GraphiQL will not be served.
* @param uploadPath The path where files can be uploaded. If None, uploads will be disabled.
* @param webSocketPath The path where websocket requests will be set. If None, websocket-based subscriptions will be disabled.
*/
def toApp(
def routes(
apiPath: String,
graphiqlPath: Option[String] = None,
uploadPath: Option[String] = None,
webSocketPath: Option[String] = None
): HttpApp[R] = {
): Routes[R, Nothing] = {
val apiRoutes = List(
RoutePattern(Method.POST, apiPath) -> handlers.api,
RoutePattern(Method.GET, apiPath) -> handlers.api
Expand All @@ -46,9 +49,18 @@ final class QuickAdapter[-R] private (requestHandler: QuickRequestHandler[R]) {
val wsRoute = webSocketPath.toList.map { wsPath =>
RoutePattern(Method.ANY, wsPath) -> handlers.webSocket
}
Routes.fromIterable(apiRoutes ::: graphiqlRoute ::: uploadRoute ::: wsRoute).toHttpApp
Routes.fromIterable(apiRoutes ::: graphiqlRoute ::: uploadRoute ::: wsRoute)
}

@deprecated("Use `routes` instead", "2.6.1")
def toApp(
apiPath: String,
graphiqlPath: Option[String] = None,
uploadPath: Option[String] = None,
webSocketPath: Option[String] = None
): HttpApp[R] =
HttpApp(routes(apiPath, graphiqlPath, uploadPath, webSocketPath))

/**
* Runs the server using the default zio-http server configuration on the specified port.
* This is meant as a convenience method for getting started quickly
Expand All @@ -65,9 +77,9 @@ final class QuickAdapter[-R] private (requestHandler: QuickRequestHandler[R]) {
graphiqlPath: Option[String] = None,
uploadPath: Option[String] = None,
webSocketPath: Option[String] = None
)(implicit trace: Trace): RIO[R, Nothing] =
)(implicit trace: Trace, tag: Tag[R]): RIO[R, Nothing] =
Server
.serve[R](toApp(apiPath, graphiqlPath = graphiqlPath, uploadPath = uploadPath, webSocketPath = webSocketPath))
.serve[R](routes(apiPath, graphiqlPath = graphiqlPath, uploadPath = uploadPath, webSocketPath = webSocketPath))
.provideSomeLayer[R](Server.defaultWithPort(port))

def configure(config: ExecutionConfiguration)(implicit trace: Trace): QuickAdapter[R] =
Expand Down
6 changes: 5 additions & 1 deletion adapters/quick/src/main/scala/caliban/QuickHandlers.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package caliban

import zio.Trace
import zio.http.{ HandlerAspect, RequestHandler }
import zio.stacktracer.TracingImplicits.disableAutoTrace

final case class QuickHandlers[-R](
api: RequestHandler[R, Nothing],
Expand All @@ -11,11 +13,13 @@ final case class QuickHandlers[-R](
/**
* Applies a ZIO HTTP `HandlerAspect` to both the api and upload handlers
*/
def @@[R1 <: R](aspect: HandlerAspect[R1, Unit]): QuickHandlers[R1] =
def @@[R1 <: R](aspect: HandlerAspect[R1, Unit]): QuickHandlers[R1] = {
implicit val trace: Trace = Trace.empty
QuickHandlers(
api = (api @@ aspect).merge,
upload = (upload @@ aspect).merge,
webSocket = (webSocket @@ aspect).merge
)
}

}
Loading

0 comments on commit 364d255

Please sign in to comment.