Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/wasm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: wasm

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
# NOTE: swift tests won't compile due to usage
# of NIOPosix. But we can at least test that wasm compilation
# works, to prevent future breakages.
wasm:
name: Test wasm compilation
runs-on: ubuntu-latest
container: swift:6.1.0
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: swiftwasm/setup-swiftwasm@v2
with:
target: "wasm32-unknown-wasip1-threads"
- run: swift build --swift-sdk wasm32-unknown-wasip1-threads
11 changes: 6 additions & 5 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.8
// swift-tools-version:5.10.0
Copy link
Contributor Author

@scottmarchant scottmarchant Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this might be a breaking change for some users of this repository, depending on what swift version they are using. It shouldn't be very hard for anyone to move from Swift 5.8 to Swift 5.10, though.

// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -13,7 +13,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-algorithms.git", from: "1.0.0"),
.package(url: "https://github.com/adam-fowler/async-collections", from: "0.0.1"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.84.0"),
],
targets: [
.target(
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](https://tldrlegal.com/license/mit-license)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FGraphQLSwift%2FDataLoader%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/GraphQLSwift/DataLoader)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FGraphQLSwift%2FDataLoader%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/GraphQLSwift/DataLoader)
[![WASI 0.1](https://github.com/GraphQLSwift/DataLoader/actions/workflows/wasm.yml/badge.svg?branch=main)](https://github.com/GraphQLSwift/DataLoader/actions/workflows/wasm.yml)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a somewhat theoretical change. Not sure on the best way to test this until it is merged.


DataLoader is a generic utility to be used as part of your application's data fetching layer to provide a simplified and consistent API over various remote data sources such as databases or web services via batching and caching.

Expand Down
3 changes: 1 addition & 2 deletions Tests/AsyncDataLoaderTests/DataLoaderAbuseTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import XCTest

@testable import AsyncDataLoader
import XCTest

/// Provides descriptive error messages for API abuse
class DataLoaderAbuseTests: XCTestCase {
Expand Down
9 changes: 4 additions & 5 deletions Tests/AsyncDataLoaderTests/DataLoaderTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import XCTest

@testable import AsyncDataLoader
import XCTest

let sleepConstant = UInt64(2_000_000)

Expand Down Expand Up @@ -53,7 +52,7 @@ final class DataLoaderTests: XCTestCase {
XCTAssertTrue(empty.isEmpty)
}

// Batches multiple requests
/// Batches multiple requests
func testMultipleRequests() async throws {
let loadCalls = Concurrent<[[Int]]>([])

Expand Down Expand Up @@ -178,7 +177,7 @@ final class DataLoaderTests: XCTestCase {
XCTAssertTrue(calls.map { $0.sorted() } == [[1]])
}

// Caches repeated requests
/// Caches repeated requests
func testCachesRepeatedRequests() async throws {
let loadCalls = Concurrent<[[String]]>([])

Expand Down Expand Up @@ -399,7 +398,7 @@ final class DataLoaderTests: XCTestCase {
XCTAssertTrue(calls2.map { $0.sorted() } == [["A", "B"], ["A", "B"]])
}

// Allows priming the cache
/// Allows priming the cache
func testAllowsPrimingTheCache() async throws {
let loadCalls = Concurrent<[[String]]>([])

Expand Down
3 changes: 1 addition & 2 deletions Tests/DataLoaderTests/DataLoaderAbuseTests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@testable import DataLoader
import NIOPosix
import XCTest

@testable import DataLoader

/// Provides descriptive error messages for API abuse
class DataLoaderAbuseTests: XCTestCase {
func testFuntionWithNoValues() throws {
Expand Down
9 changes: 4 additions & 5 deletions Tests/DataLoaderTests/DataLoaderAsyncTests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@testable import DataLoader
import NIOPosix
import XCTest

@testable import DataLoader

#if compiler(>=5.5) && canImport(_Concurrency)

@available(macOS 12, iOS 15, watchOS 8, tvOS 15, *)
Expand Down Expand Up @@ -70,7 +69,7 @@ import XCTest
XCTAssertTrue(empty.isEmpty)
}

// Batches multiple requests
/// Batches multiple requests
func testMultipleRequests() async throws {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer {
Expand All @@ -96,8 +95,8 @@ import XCTest
async let value1 = identityLoader.load(key: 1, on: eventLoopGroup)
async let value2 = identityLoader.load(key: 2, on: eventLoopGroup)

/// Have to wait for a split second because Tasks may not be executed before this
/// statement
// Have to wait for a split second because Tasks may not be executed before this
// statement
try await Task.sleep(nanoseconds: 500_000_000)

XCTAssertNoThrow(try identityLoader.execute())
Expand Down
11 changes: 5 additions & 6 deletions Tests/DataLoaderTests/DataLoaderTests.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
@testable import DataLoader
import NIOCore
import NIOPosix
import XCTest

@testable import DataLoader

/// Primary API
final class DataLoaderTests: XCTestCase {
/// Builds a really really simple data loader'
Expand Down Expand Up @@ -48,7 +47,7 @@ final class DataLoaderTests: XCTestCase {
XCTAssertTrue(empty.isEmpty)
}

// Batches multiple requests
/// Batches multiple requests
func testMultipleRequests() throws {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer {
Expand Down Expand Up @@ -144,7 +143,7 @@ final class DataLoaderTests: XCTestCase {
XCTAssertTrue(loadCalls == [[1]])
}

// Caches repeated requests
/// Caches repeated requests
func testCachesRepeatedRequests() throws {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer {
Expand Down Expand Up @@ -270,7 +269,7 @@ final class DataLoaderTests: XCTestCase {
XCTAssertTrue(loadCalls == [["A", "B"], ["A", "B"]])
}

// Allows priming the cache
/// Allows priming the cache
func testAllowsPrimingTheCache() throws {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer {
Expand Down Expand Up @@ -384,7 +383,7 @@ final class DataLoaderTests: XCTestCase {
XCTAssertTrue(loadCalls == [["B"]])
}

// Caches repeated requests, even if initiated asyncronously
/// Caches repeated requests, even if initiated asyncronously
func testCacheConcurrency() throws {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer {
Expand Down