-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate local cache mutations (#2311)
* Create base API for cache writes * WIP: Writing test for cache mutations * Make DataDict mutable * WIP: Cache Mutation Tests * Remove mock mutable selection set * Add _modify to DataDict * Fixed some more tests * Re-add MockMutableRootSelectionSet as protocol instead of class * JSONDecodingError Equatable * Test deletion of referenced record throws error * Add default __typename get/setter to MutableRootSelectionSet * Test for adding new entity reference to cache mutation * Finished ReadWriteFromStoreTests Refactor * Fix StoreConcurrencyTests * Fix WatchQueryTests * Fix SQLIteCacheTests * Add other operations and fragments to supported locations for cache mutation directive * Add operationType to LocalCacheMutation * Create LocalCacheMutationDefinitionTemplate and break out shared code from OperationDefinitionTemplate * Make MutableSelectionSet conform to SelectionSet * Generate SelectionSet Mutable TypeName * Generate mutable field accessors * WIP * Generate Named Fragment getter and setter * Finish generation of mutable selection sets * Generate Mutable Fragments * Compile directives on FragmentDefinition * Improve __typename addition functionality in frontend * Pretty print actual rendered on template test failure * Strip local cache mutation directive from source definition * Fix bug where __typename was added to inline fragments in Frontend * Make Fragment definition generate selection set as mutable for local cache mutations * Generate Local Cache Mutations into separate folder * Add inclusion conditions to generated Fragment Accessors (#2312) * Add resolution of inclusion conditions for conditional fragment conversion * Generate inclusion conditions on Fragment Gettters * Test * Add Mutable Typealiases to generated Schema. Clean up * Fixes for code review comments
- Loading branch information
1 parent
d545b86
commit 55623fe
Showing
46 changed files
with
1,773 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ingdomAPI/AnimalKingdomAPI/Sources/LocalCacheMutations/AllAnimalsLocalCacheMutation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
|
||
import ApolloAPI | ||
@_exported import enum ApolloAPI.GraphQLEnum | ||
@_exported import enum ApolloAPI.GraphQLNullable | ||
|
||
public class AllAnimalsLocalCacheMutation: GraphQLQuery { | ||
public static let operationName: String = "AllAnimalsLocalCacheMutation" | ||
public static let document: DocumentType = .notPersisted( | ||
definition: .init( | ||
""" | ||
query AllAnimalsLocalCacheMutation { | ||
allAnimals { | ||
__typename | ||
species | ||
skinCovering | ||
... on Bird { | ||
wingspan | ||
} | ||
} | ||
} | ||
""" | ||
)) | ||
|
||
public init() {} | ||
|
||
public struct Data: AnimalKingdomAPI.SelectionSet { | ||
public let data: DataDict | ||
public init(data: DataDict) { self.data = data } | ||
|
||
public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Query.self) } | ||
public static var selections: [Selection] { [ | ||
.field("allAnimals", [AllAnimal].self), | ||
] } | ||
|
||
public var allAnimals: [AllAnimal] { data["allAnimals"] } | ||
|
||
/// AllAnimal | ||
public struct AllAnimal: AnimalKingdomAPI.SelectionSet { | ||
public let data: DataDict | ||
public init(data: DataDict) { self.data = data } | ||
|
||
public static var __parentType: ParentType { .Interface(AnimalKingdomAPI.Animal.self) } | ||
public static var selections: [Selection] { [ | ||
.field("species", String.self), | ||
.field("skinCovering", GraphQLEnum<SkinCovering>?.self), | ||
.inlineFragment(AsBird.self), | ||
] } | ||
|
||
public var species: String { data["species"] } | ||
public var skinCovering: GraphQLEnum<SkinCovering>? { data["skinCovering"] } | ||
|
||
public var asBird: AsBird? { _asInlineFragment() } | ||
|
||
/// AllAnimal.AsBird | ||
public struct AsBird: AnimalKingdomAPI.InlineFragment { | ||
public let data: DataDict | ||
public init(data: DataDict) { self.data = data } | ||
|
||
public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Bird.self) } | ||
public static var selections: [Selection] { [ | ||
.field("wingspan", Float.self), | ||
] } | ||
|
||
public var wingspan: Float { data["wingspan"] } | ||
public var species: String { data["species"] } | ||
public var skinCovering: GraphQLEnum<SkinCovering>? { data["skinCovering"] } | ||
} | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...es/AnimalKingdomAPI/AnimalKingdomAPI/Sources/LocalCacheMutations/PetDetailsMutation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
|
||
import ApolloAPI | ||
@_exported import enum ApolloAPI.GraphQLEnum | ||
@_exported import enum ApolloAPI.GraphQLNullable | ||
|
||
public struct PetDetailsMutation: AnimalKingdomAPI.MutableSelectionSet, Fragment { | ||
public static var fragmentDefinition: StaticString { """ | ||
fragment PetDetailsMutation on Pet { | ||
__typename | ||
owner { | ||
__typename | ||
firstName | ||
} | ||
} | ||
""" } | ||
|
||
public var data: DataDict | ||
public init(data: DataDict) { self.data = data } | ||
|
||
public static var __parentType: ParentType { .Interface(AnimalKingdomAPI.Pet.self) } | ||
public static var selections: [Selection] { [ | ||
.field("owner", Owner?.self), | ||
] } | ||
|
||
public var owner: Owner? { | ||
get { data["owner"] } | ||
set { data["owner"] = newValue } | ||
} | ||
|
||
/// Owner | ||
public struct Owner: AnimalKingdomAPI.MutableSelectionSet { | ||
public var data: DataDict | ||
public init(data: DataDict) { self.data = data } | ||
|
||
public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Human.self) } | ||
public static var selections: [Selection] { [ | ||
.field("firstName", String.self), | ||
] } | ||
|
||
public var firstName: String { | ||
get { data["firstName"] } | ||
set { data["firstName"] = newValue } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Sources/AnimalKingdomAPI/graphql/AllAnimalsLocalCacheMutation.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
query AllAnimalsLocalCacheMutation @apollo_client_ios_localCacheMutation { | ||
allAnimals { | ||
species | ||
skinCovering | ||
... on Bird { | ||
wingspan | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fragment PetDetailsMutation on Pet @apollo_client_ios_localCacheMutation { | ||
owner { | ||
firstName | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.