Skip to content

Commit

Permalink
Support ID scalar as a custom scalar (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMDev authored and gh-action-runner committed May 20, 2024
1 parent 78c5f55 commit ccfb72e
Show file tree
Hide file tree
Showing 58 changed files with 270 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AllAnimalsQuery: GraphQLQuery {
public static let operationName: String = "AllAnimalsQuery"
public static let operationDocument: ApolloAPI.OperationDocument = .init(
definition: .init(
#"query AllAnimalsQuery { allAnimals { __typename height { __typename feet inches } ...HeightInMeters ...WarmBloodedDetails species skinCovering ... on Pet { ...PetDetails ...WarmBloodedDetails ... on Animal { height { __typename relativeSize centimeters } } } ... on Cat { isJellicle } ... on ClassroomPet { ... on Bird { wingspan } } ... on Dog { favoriteToy birthdate } predators { __typename species ... on WarmBlooded { predators { __typename species } ...WarmBloodedDetails laysEggs } } } }"#,
#"query AllAnimalsQuery { allAnimals { __typename id height { __typename feet inches } ...HeightInMeters ...WarmBloodedDetails species skinCovering ... on Pet { ...PetDetails ...WarmBloodedDetails ... on Animal { height { __typename relativeSize centimeters } } } ... on Cat { isJellicle } ... on ClassroomPet { ... on Bird { wingspan } } ... on Dog { favoriteToy birthdate } predators { __typename species ... on WarmBlooded { predators { __typename species } ...WarmBloodedDetails laysEggs } } } }"#,
fragments: [HeightInMeters.self, PetDetails.self, WarmBloodedDetails.self]
))

Expand Down Expand Up @@ -48,6 +48,7 @@ public class AllAnimalsQuery: GraphQLQuery {
public static var __parentType: ApolloAPI.ParentType { AnimalKingdomAPI.Interfaces.Animal }
public static var __selections: [ApolloAPI.Selection] { [
.field("__typename", String.self),
.field("id", AnimalKingdomAPI.ID.self),
.field("height", Height.self),
.field("species", String.self),
.field("skinCovering", GraphQLEnum<AnimalKingdomAPI.SkinCovering>?.self),
Expand All @@ -60,6 +61,7 @@ public class AllAnimalsQuery: GraphQLQuery {
.fragment(HeightInMeters.self),
] }

public var id: AnimalKingdomAPI.ID { __data["id"] }
public var height: Height { __data["height"] }
public var species: String { __data["species"] }
public var skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? { __data["skinCovering"] }
Expand All @@ -80,6 +82,7 @@ public class AllAnimalsQuery: GraphQLQuery {

public init(
__typename: String,
id: AnimalKingdomAPI.ID,
height: Height,
species: String,
skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? = nil,
Expand All @@ -88,6 +91,7 @@ public class AllAnimalsQuery: GraphQLQuery {
self.init(_dataDict: DataDict(
data: [
"__typename": __typename,
"id": id,
"height": height._fieldData,
"species": species,
"skinCovering": skinCovering,
Expand Down Expand Up @@ -273,6 +277,7 @@ public class AllAnimalsQuery: GraphQLQuery {
.fragment(WarmBloodedDetails.self),
] }

public var id: AnimalKingdomAPI.ID { __data["id"] }
public var height: Height { __data["height"] }
public var species: String { __data["species"] }
public var skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? { __data["skinCovering"] }
Expand All @@ -289,6 +294,7 @@ public class AllAnimalsQuery: GraphQLQuery {

public init(
__typename: String,
id: AnimalKingdomAPI.ID,
height: Height,
species: String,
skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? = nil,
Expand All @@ -298,6 +304,7 @@ public class AllAnimalsQuery: GraphQLQuery {
self.init(_dataDict: DataDict(
data: [
"__typename": __typename,
"id": id,
"height": height._fieldData,
"species": species,
"skinCovering": skinCovering,
Expand Down Expand Up @@ -364,6 +371,7 @@ public class AllAnimalsQuery: GraphQLQuery {
] }

public var height: Height { __data["height"] }
public var id: AnimalKingdomAPI.ID { __data["id"] }
public var species: String { __data["species"] }
public var skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? { __data["skinCovering"] }
public var predators: [Predator] { __data["predators"] }
Expand All @@ -384,6 +392,7 @@ public class AllAnimalsQuery: GraphQLQuery {
public init(
__typename: String,
height: Height,
id: AnimalKingdomAPI.ID,
species: String,
skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? = nil,
predators: [Predator],
Expand All @@ -395,6 +404,7 @@ public class AllAnimalsQuery: GraphQLQuery {
data: [
"__typename": __typename,
"height": height._fieldData,
"id": id,
"species": species,
"skinCovering": skinCovering,
"predators": predators._fieldData,
Expand Down Expand Up @@ -470,6 +480,7 @@ public class AllAnimalsQuery: GraphQLQuery {
.fragment(WarmBloodedDetails.self),
] }

public var id: AnimalKingdomAPI.ID { __data["id"] }
public var height: Height { __data["height"] }
public var species: String { __data["species"] }
public var skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? { __data["skinCovering"] }
Expand All @@ -490,6 +501,7 @@ public class AllAnimalsQuery: GraphQLQuery {

public init(
__typename: String,
id: AnimalKingdomAPI.ID,
height: Height,
species: String,
skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? = nil,
Expand All @@ -502,6 +514,7 @@ public class AllAnimalsQuery: GraphQLQuery {
self.init(_dataDict: DataDict(
data: [
"__typename": __typename,
"id": id,
"height": height._fieldData,
"species": species,
"skinCovering": skinCovering,
Expand Down Expand Up @@ -581,6 +594,7 @@ public class AllAnimalsQuery: GraphQLQuery {
] }

public var isJellicle: Bool { __data["isJellicle"] }
public var id: AnimalKingdomAPI.ID { __data["id"] }
public var height: Height { __data["height"] }
public var species: String { __data["species"] }
public var skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? { __data["skinCovering"] }
Expand All @@ -601,6 +615,7 @@ public class AllAnimalsQuery: GraphQLQuery {

public init(
isJellicle: Bool,
id: AnimalKingdomAPI.ID,
height: Height,
species: String,
skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? = nil,
Expand All @@ -614,6 +629,7 @@ public class AllAnimalsQuery: GraphQLQuery {
data: [
"__typename": AnimalKingdomAPI.Objects.Cat.typename,
"isJellicle": isJellicle,
"id": id,
"height": height._fieldData,
"species": species,
"skinCovering": skinCovering,
Expand Down Expand Up @@ -693,6 +709,7 @@ public class AllAnimalsQuery: GraphQLQuery {
.inlineFragment(AsBird.self),
] }

public var id: AnimalKingdomAPI.ID { __data["id"] }
public var height: Height { __data["height"] }
public var species: String { __data["species"] }
public var skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? { __data["skinCovering"] }
Expand All @@ -709,6 +726,7 @@ public class AllAnimalsQuery: GraphQLQuery {

public init(
__typename: String,
id: AnimalKingdomAPI.ID,
height: Height,
species: String,
skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? = nil,
Expand All @@ -717,6 +735,7 @@ public class AllAnimalsQuery: GraphQLQuery {
self.init(_dataDict: DataDict(
data: [
"__typename": __typename,
"id": id,
"height": height._fieldData,
"species": species,
"skinCovering": skinCovering,
Expand Down Expand Up @@ -778,6 +797,7 @@ public class AllAnimalsQuery: GraphQLQuery {
] }

public var wingspan: Double { __data["wingspan"] }
public var id: AnimalKingdomAPI.ID { __data["id"] }
public var height: Height { __data["height"] }
public var species: String { __data["species"] }
public var skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? { __data["skinCovering"] }
Expand All @@ -798,6 +818,7 @@ public class AllAnimalsQuery: GraphQLQuery {

public init(
wingspan: Double,
id: AnimalKingdomAPI.ID,
height: Height,
species: String,
skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? = nil,
Expand All @@ -811,6 +832,7 @@ public class AllAnimalsQuery: GraphQLQuery {
data: [
"__typename": AnimalKingdomAPI.Objects.Bird.typename,
"wingspan": wingspan,
"id": id,
"height": height._fieldData,
"species": species,
"skinCovering": skinCovering,
Expand Down Expand Up @@ -895,6 +917,7 @@ public class AllAnimalsQuery: GraphQLQuery {

public var favoriteToy: String { __data["favoriteToy"] }
public var birthdate: AnimalKingdomAPI.CustomDate? { __data["birthdate"] }
public var id: AnimalKingdomAPI.ID { __data["id"] }
public var height: Height { __data["height"] }
public var species: String { __data["species"] }
public var skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? { __data["skinCovering"] }
Expand All @@ -915,6 +938,7 @@ public class AllAnimalsQuery: GraphQLQuery {
public init(
favoriteToy: String,
birthdate: AnimalKingdomAPI.CustomDate? = nil,
id: AnimalKingdomAPI.ID,
height: Height,
species: String,
skinCovering: GraphQLEnum<AnimalKingdomAPI.SkinCovering>? = nil,
Expand All @@ -928,6 +952,7 @@ public class AllAnimalsQuery: GraphQLQuery {
"__typename": AnimalKingdomAPI.Objects.Dog.typename,
"favoriteToy": favoriteToy,
"birthdate": birthdate,
"id": id,
"height": height._fieldData,
"species": species,
"skinCovering": skinCovering,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @generated
// This file was automatically generated and can be edited to
// implement advanced custom scalar functionality.
//
// Any changes to this file will not be overwritten by future
// code generation execution.

import ApolloAPI

/// The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.
public typealias ID = String
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public struct PetAdoptionInput: InputObject {
petID: ID,
humanName: GraphQLNullable<String> = nil,
favoriteToy: String,
isSpayedOrNeutered: Bool?,
isSpayedOrNeutered: Bool? = nil,
measurements: GraphQLNullable<MeasurementsInput> = nil
) {
__data = InputDict([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
import ApolloAPI

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

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

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

public extension Interfaces {
static let WarmBlooded = Interface(name: "WarmBlooded")
static let WarmBlooded = ApolloAPI.Interface(name: "WarmBlooded")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import ApolloAPI

public typealias ID = String

public protocol SelectionSet: ApolloAPI.SelectionSet & ApolloAPI.RootSelectionSet
where Schema == AnimalKingdomAPI.SchemaMetadata {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
query AllAnimalsQuery {
allAnimals {
__typename
id
height {
feet
inches
Expand Down
11 changes: 11 additions & 0 deletions Sources/GitHubAPI/GitHubAPI/Sources/Schema/CustomScalars/ID.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @generated
// This file was automatically generated and can be edited to
// implement advanced custom scalar functionality.
//
// Any changes to this file will not be overwritten by future
// code generation execution.

import ApolloAPI

/// The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.
public typealias ID = String
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 = Interface(name: "Actor")
static let Actor = ApolloAPI.Interface(name: "Actor")
}
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 = Interface(name: "Assignable")
static let Assignable = ApolloAPI.Interface(name: "Assignable")
}
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 = Interface(name: "AuditEntry")
static let AuditEntry = ApolloAPI.Interface(name: "AuditEntry")
}
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 = Interface(name: "Closable")
static let Closable = ApolloAPI.Interface(name: "Closable")
}
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 = Interface(name: "Comment")
static let Comment = ApolloAPI.Interface(name: "Comment")
}
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 = Interface(name: "Deletable")
static let Deletable = ApolloAPI.Interface(name: "Deletable")
}
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 = Interface(name: "EnterpriseAuditEntryData")
static let EnterpriseAuditEntryData = ApolloAPI.Interface(name: "EnterpriseAuditEntryData")
}
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 = Interface(name: "GitObject")
static let GitObject = ApolloAPI.Interface(name: "GitObject")
}
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 = Interface(name: "Labelable")
static let Labelable = ApolloAPI.Interface(name: "Labelable")
}
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 = Interface(name: "Lockable")
static let Lockable = ApolloAPI.Interface(name: "Lockable")
}
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 = Interface(name: "MemberStatusable")
static let MemberStatusable = ApolloAPI.Interface(name: "MemberStatusable")
}
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 = Interface(name: "Minimizable")
static let Minimizable = ApolloAPI.Interface(name: "Minimizable")
}
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 = Interface(name: "Node")
static let Node = ApolloAPI.Interface(name: "Node")
}
Loading

0 comments on commit ccfb72e

Please sign in to comment.