Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Specify caching fields with typePolicy directive #554

Merged
merged 3 commits into from
Jan 22, 2025
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 @@ -4,5 +4,5 @@
import ApolloAPI

public extension Interfaces {
static let Animal = ApolloAPI.Interface(name: "Animal")
static let Animal = ApolloAPI.Interface(name: "Animal", keyFields: ["id"])
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
import ApolloAPI

public extension Interfaces {
static let HousePet = ApolloAPI.Interface(name: "HousePet")
static let HousePet = ApolloAPI.Interface(name: "HousePet", keyFields: ["id"])
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
import ApolloAPI

public extension Interfaces {
static let Pet = ApolloAPI.Interface(name: "Pet")
static let Pet = ApolloAPI.Interface(name: "Pet", keyFields: ["id"])
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
import ApolloAPI

public extension Interfaces {
static let WarmBlooded = ApolloAPI.Interface(name: "WarmBlooded")
static let WarmBlooded = ApolloAPI.Interface(name: "WarmBlooded", keyFields: ["id"])
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public extension Objects {
Interfaces.Animal.self,
Interfaces.Pet.self,
Interfaces.WarmBlooded.self
]
],
keyFields: ["id"]
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public extension Objects {
Interfaces.Animal.self,
Interfaces.Pet.self,
Interfaces.WarmBlooded.self
]
],
keyFields: ["id"]
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ApolloAPI
public extension Objects {
static let Crocodile = ApolloAPI.Object(
typename: "Crocodile",
implementedInterfaces: [Interfaces.Animal.self]
implementedInterfaces: [Interfaces.Animal.self],
keyFields: ["id"]
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public extension Objects {
Interfaces.Pet.self,
Interfaces.HousePet.self,
Interfaces.WarmBlooded.self
]
],
keyFields: ["id"]
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public extension Objects {
implementedInterfaces: [
Interfaces.Animal.self,
Interfaces.Pet.self
]
],
keyFields: ["id"]
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ApolloAPI
public extension Objects {
static let Height = ApolloAPI.Object(
typename: "Height",
implementedInterfaces: []
implementedInterfaces: [],
keyFields: nil
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public extension Objects {
implementedInterfaces: [
Interfaces.Animal.self,
Interfaces.WarmBlooded.self
]
],
keyFields: ["id"]
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ApolloAPI
public extension Objects {
static let Mutation = ApolloAPI.Object(
typename: "Mutation",
implementedInterfaces: []
implementedInterfaces: [],
keyFields: nil
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ApolloAPI
public extension Objects {
static let PetRock = ApolloAPI.Object(
typename: "PetRock",
implementedInterfaces: [Interfaces.Pet.self]
implementedInterfaces: [Interfaces.Pet.self],
keyFields: ["id"]
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ApolloAPI
public extension Objects {
static let Query = ApolloAPI.Object(
typename: "Query",
implementedInterfaces: []
implementedInterfaces: [],
keyFields: nil
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public extension Objects {
implementedInterfaces: [
Interfaces.Animal.self,
Interfaces.Pet.self
]
],
keyFields: ["id"]
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ input PetSearchFilters {
measurements: MeasurementsInput
}

interface Animal {
interface Animal @typePolicy(keyFields: "id") {
id: ID!
species: String!
height: Height!
predators: [Animal!]!
skinCovering: SkinCovering
}

interface Pet {
interface Pet @typePolicy(keyFields: "id") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the directive to one of the schemas, but I didn't regenerate the example sources since that would add another 100 files to the Pull Request

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine while we do code review. But we should go ahead and generate those files and verify they look correct and compile prior to merging.

id: ID!
humanName: String
favoriteToy: String!
Expand Down Expand Up @@ -198,5 +198,5 @@ enum SkinCovering {
FUR
HAIR
FEATHERS
SCALES
SCALES
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Represents an object which can take actions on GitHub. Typically a User or Bot.
static let Actor = ApolloAPI.Interface(name: "Actor")
static let Actor = ApolloAPI.Interface(name: "Actor", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// An object that can have users assigned to it.
static let Assignable = ApolloAPI.Interface(name: "Assignable")
static let Assignable = ApolloAPI.Interface(name: "Assignable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// An entry in the audit log.
static let AuditEntry = ApolloAPI.Interface(name: "AuditEntry")
static let AuditEntry = ApolloAPI.Interface(name: "AuditEntry", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// An object that can be closed
static let Closable = ApolloAPI.Interface(name: "Closable")
static let Closable = ApolloAPI.Interface(name: "Closable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Represents a comment.
static let Comment = ApolloAPI.Interface(name: "Comment")
static let Comment = ApolloAPI.Interface(name: "Comment", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Entities that can be deleted.
static let Deletable = ApolloAPI.Interface(name: "Deletable")
static let Deletable = ApolloAPI.Interface(name: "Deletable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Metadata for an audit entry containing enterprise account information.
static let EnterpriseAuditEntryData = ApolloAPI.Interface(name: "EnterpriseAuditEntryData")
static let EnterpriseAuditEntryData = ApolloAPI.Interface(name: "EnterpriseAuditEntryData", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Represents a Git object.
static let GitObject = ApolloAPI.Interface(name: "GitObject")
static let GitObject = ApolloAPI.Interface(name: "GitObject", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// An object that can have labels assigned to it.
static let Labelable = ApolloAPI.Interface(name: "Labelable")
static let Labelable = ApolloAPI.Interface(name: "Labelable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// An object that can be locked.
static let Lockable = ApolloAPI.Interface(name: "Lockable")
static let Lockable = ApolloAPI.Interface(name: "Lockable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Entities that have members who can set status messages.
static let MemberStatusable = ApolloAPI.Interface(name: "MemberStatusable")
static let MemberStatusable = ApolloAPI.Interface(name: "MemberStatusable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Entities that can be minimized.
static let Minimizable = ApolloAPI.Interface(name: "Minimizable")
static let Minimizable = ApolloAPI.Interface(name: "Minimizable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// An object with an ID.
static let Node = ApolloAPI.Interface(name: "Node")
static let Node = ApolloAPI.Interface(name: "Node", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Metadata for an audit entry with action oauth_application.*
static let OauthApplicationAuditEntryData = ApolloAPI.Interface(name: "OauthApplicationAuditEntryData")
static let OauthApplicationAuditEntryData = ApolloAPI.Interface(name: "OauthApplicationAuditEntryData", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Metadata for an audit entry with action org.*
static let OrganizationAuditEntryData = ApolloAPI.Interface(name: "OrganizationAuditEntryData")
static let OrganizationAuditEntryData = ApolloAPI.Interface(name: "OrganizationAuditEntryData", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Represents an owner of a package.
static let PackageOwner = ApolloAPI.Interface(name: "PackageOwner")
static let PackageOwner = ApolloAPI.Interface(name: "PackageOwner", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Represents any entity on GitHub that has a profile page.
static let ProfileOwner = ApolloAPI.Interface(name: "ProfileOwner")
static let ProfileOwner = ApolloAPI.Interface(name: "ProfileOwner", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Represents an owner of a Project.
static let ProjectOwner = ApolloAPI.Interface(name: "ProjectOwner")
static let ProjectOwner = ApolloAPI.Interface(name: "ProjectOwner", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Represents a subject that can be reacted on.
static let Reactable = ApolloAPI.Interface(name: "Reactable")
static let Reactable = ApolloAPI.Interface(name: "Reactable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Metadata for an audit entry with action repo.*
static let RepositoryAuditEntryData = ApolloAPI.Interface(name: "RepositoryAuditEntryData")
static let RepositoryAuditEntryData = ApolloAPI.Interface(name: "RepositoryAuditEntryData", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// A subset of repository info.
static let RepositoryInfo = ApolloAPI.Interface(name: "RepositoryInfo")
static let RepositoryInfo = ApolloAPI.Interface(name: "RepositoryInfo", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Represents a object that belongs to a repository.
static let RepositoryNode = ApolloAPI.Interface(name: "RepositoryNode")
static let RepositoryNode = ApolloAPI.Interface(name: "RepositoryNode", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Represents an owner of a Repository.
static let RepositoryOwner = ApolloAPI.Interface(name: "RepositoryOwner")
static let RepositoryOwner = ApolloAPI.Interface(name: "RepositoryOwner", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Entities that can be sponsored through GitHub Sponsors
static let Sponsorable = ApolloAPI.Interface(name: "Sponsorable")
static let Sponsorable = ApolloAPI.Interface(name: "Sponsorable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Things that can be starred.
static let Starrable = ApolloAPI.Interface(name: "Starrable")
static let Starrable = ApolloAPI.Interface(name: "Starrable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Entities that can be subscribed to for web and email notifications.
static let Subscribable = ApolloAPI.Interface(name: "Subscribable")
static let Subscribable = ApolloAPI.Interface(name: "Subscribable", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Metadata for an audit entry with action team.*
static let TeamAuditEntryData = ApolloAPI.Interface(name: "TeamAuditEntryData")
static let TeamAuditEntryData = ApolloAPI.Interface(name: "TeamAuditEntryData", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Metadata for an audit entry with a topic.
static let TopicAuditEntryData = ApolloAPI.Interface(name: "TopicAuditEntryData")
static let TopicAuditEntryData = ApolloAPI.Interface(name: "TopicAuditEntryData", keyFields: nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import ApolloAPI

public extension Interfaces {
/// Represents a type that can be retrieved by a URL.
static let UniformResourceLocatable = ApolloAPI.Interface(name: "UniformResourceLocatable")
static let UniformResourceLocatable = ApolloAPI.Interface(name: "UniformResourceLocatable", keyFields: nil)
}
Loading
Loading