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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ input PetAdoptionInput {
favoriteToy: String!
isSpayedOrNeutered: Boolean! = false
measurements: MeasurementsInput
adoptionDate: CustomDate
}

input MeasurementsInput {
Expand Down Expand Up @@ -54,6 +55,7 @@ interface Pet @typePolicy(keyFields: "id") {
humanName: String
favoriteToy: String!
owner: Human
adoptionDate: CustomDate
}

interface HousePet implements Animal & Pet {
Expand All @@ -68,7 +70,8 @@ interface HousePet implements Animal & Pet {
bestFriend: Pet
rival: Pet
livesWith: ClassroomPet
birthdate: CustomDate
adoptionDate: CustomDate
birthdate: CustomDate!
}

interface WarmBlooded implements Animal {
Expand Down Expand Up @@ -110,6 +113,7 @@ type Cat implements Animal & Pet & WarmBlooded {
humanName: String
favoriteToy: String!
owner: Human
adoptionDate: CustomDate
bodyTemperature: Int!
laysEggs: Boolean!
isJellicle: Boolean!
Expand All @@ -124,12 +128,13 @@ type Dog implements Animal & Pet & HousePet & WarmBlooded {
humanName: String
favoriteToy: String!
owner: Human
adoptionDate: CustomDate
bodyTemperature: Int!
laysEggs: Boolean!
bestFriend: HousePet
rival: Cat
livesWith: Bird
birthdate: CustomDate
birthdate: CustomDate!
houseDetails: Object
}

Expand All @@ -142,6 +147,7 @@ type Bird implements Animal & Pet & WarmBlooded {
humanName: String
favoriteToy: String!
owner: Human
adoptionDate: CustomDate
bodyTemperature: Int!
laysEggs: Boolean!
wingspan: Float!
Expand All @@ -156,6 +162,7 @@ type Fish implements Animal & Pet {
humanName: String
favoriteToy: String!
owner: Human
adoptionDate: CustomDate
}

type Rat implements Animal & Pet {
Expand All @@ -167,6 +174,7 @@ type Rat implements Animal & Pet {
humanName: String
favoriteToy: String!
owner: Human
adoptionDate: CustomDate
}

type Crocodile implements Animal {
Expand All @@ -184,6 +192,7 @@ type PetRock implements Pet {
humanName: String
favoriteToy: String!
owner: Human
adoptionDate: CustomDate
}

union ClassroomPet = Cat | Bird | Rat | PetRock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ fragment PetDetailsMutation on Pet @apollo_client_ios_localCacheMutation {
owner {
firstName
}
adoptionDate
}
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ class MockObjectTemplateTests: XCTestCase {

public extension Mock where O == Dog {
convenience init(
customScalar: TestSchema.CustomScalar = try! .init(_jsonValue: ""),
customScalar: TestSchema.CustomScalar = .defaultMockValue,
customScalarList: [TestSchema.CustomScalar]? = nil,
customScalarOptionalList: [TestSchema.CustomScalar?]? = nil,
enumList: [GraphQLEnum<TestSchema.EnumType>]? = nil,
Expand Down Expand Up @@ -580,7 +580,7 @@ class MockObjectTemplateTests: XCTestCase {

public extension Mock where O == Dog {
convenience init(
customScalar: TestSchema.CustomScalar = try! .init(_jsonValue: ""),
customScalar: TestSchema.CustomScalar = .defaultMockValue,
customScalarList: [TestSchema.CustomScalar] = [],
enumList: [GraphQLEnum<TestSchema.EnumType>] = [],
enumType: GraphQLEnum<TestSchema.EnumType> = .case(.foo),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

xcodebuild archive -configuration Release -project "CodegenXCFramework.xcodeproj" -scheme "CodegenXCFramework" -destination 'generic/platform=iOS Simulator' -archivePath "./build/iphonesimulator.xcarchive" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcbeautify
xcodebuild archive -configuration Release -project "CodegenXCFramework.xcodeproj" -scheme "CodegenXCFramework" -destination 'generic/platform=iOS' -archivePath "./build/iphoneos.xcarchive" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcbeautify
xcodebuild -create-xcframework -output ./build/CodegenXCFramework.xcframework -framework ./build/iphonesimulator.xcarchive/Products/Library/Frameworks/CodegenXCFramework.framework -framework ./build/iphoneos.xcarchive/Products/Library/Frameworks/CodegenXCFramework.framework | xcbeautify
set -o pipefail # Fail if any command in a pipeline fails

# Clean up previous build artifacts
rm -rf ./build

xcodebuild archive -configuration Release -project "CodegenXCFramework.xcodeproj" -scheme "CodegenXCFramework" -destination 'generic/platform=macOS' -archivePath "./build/macOS.xcarchive" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=NO | xcbeautify

xcodebuild -create-xcframework -allow-internal-distribution -output ./build/CodegenXCFramework.xcframework -framework ./build/macOS.xcarchive/Products/Library/Frameworks/CodegenXCFramework.framework | xcbeautify
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import ApolloAPI

enum SchemaConfiguration: ApolloAPI.SchemaConfiguration {
static func cacheKeyInfo(for type: Object, object: ObjectData) -> CacheKeyInfo? {
try? CacheKeyInfo(jsonValue: object["id"])
static func cacheKeyInfo(for type: ApolloAPI.Object, object: ApolloAPI.ObjectData) -> CacheKeyInfo? {
// Implement this function to configure cache key resolution for your schema types.
return try? CacheKeyInfo(jsonValue: object["id"])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension GraphQLScalarType: DefaultMockValueProviding {
case "Boolean":
return "false"
default:
return "try! .init(_jsonValue: \"\")"
return ".defaultMockValue"
}
}
}
Expand Down
Binary file modified apollo-ios/CLI/apollo-ios-cli.tar.gz
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@_spi(Internal) import ApolloAPI

public extension ScalarType {
static var defaultMockValue: Self {
try! .init(_jsonValue: "")
}
}

public extension CustomScalarType {
static var defaultMockValue: Self {
try! .init(_jsonValue: "")
}
}
18 changes: 14 additions & 4 deletions scripts/run-test-codegen-configurations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,27 @@ for dir in `ls $CodeGenConfigsDirectory`;
do
echo "-- Generating code for project: $dir --"
(cd apollo-ios-codegen && swift run apollo-ios-cli generate -p ../$CodeGenConfigsDirectory/$dir/apollo-codegen-config.json)

if [ $? -ne 0 ]; then
echo "Error: Code generation failed for $dir"
exit 1
fi

if [ "$test_projects" = true ]
then
echo -e "-- Testing project: $dir --"
cd $CodeGenConfigsDirectory/$dir

if /bin/bash ./test-project.sh; then
echo -e "\n"
cd - > /dev/null
else
/bin/bash ./test-project.sh
test_exit_code=$?

cd - > /dev/null

if [ $test_exit_code -ne 0 ]; then
echo "Error: Test failed for $dir"
exit 1
fi

echo -e "\n"
fi
done
Loading