Instantly share code, notes, and snippets.

Embed
What would you like to do?
query Airings {
Airings(channelId: $channelId) @paginate(startIndex: 1, maxResults: 5) {
contentId, mediaId, eventId, programId, partnerProgramId
startDate, endDate, expires
linear, runTime
playbackUrls {
rel
href
}
titles {
title
}
photos {
uri
}
}
}
// This file was automatically generated and should not be edited.
import Apollo
public final class AiringsQuery: GraphQLQuery {
public static let operationString =
"query Airings {" +
" Airings(channelId: $channelId) @paginate(startIndex: 1, maxResults: 5) {" +
" __typename" +
" contentId" +
" mediaId" +
" eventId" +
" programId" +
" partnerProgramId" +
" startDate" +
" endDate" +
" expires" +
" linear" +
" runTime" +
" playbackUrls {" +
" __typename" +
" rel" +
" href" +
" }" +
" titles {" +
" __typename" +
" title" +
" }" +
" photos {" +
" __typename" +
" uri" +
" }" +
" }" +
"}"
public init() {
}
public struct Data: GraphQLSelectionSet {
public static let possibleTypes = ["SearchQuery"]
public static let selections: [Selection] = [
Field("Airings", arguments: ["channelId": Variable("channelId")], type: .list(.object(Data.Airing.self))),
]
public var snapshot: Snapshot
public init(snapshot: Snapshot) {
self.snapshot = snapshot
}
public init(airings: [Airing?]? = nil) {
self.init(snapshot: ["__typename": "SearchQuery", "airings": airings])
}
/// Retrieve live, onAir, linear, or once-live video metadata sourced from EPG Metadata Service.
public var airings: [Airing?]? {
get {
return (snapshot["Airings"]! as! [Snapshot?]?).flatMap { $0.map { $0.flatMap { Airing(snapshot: $0) } } }
}
set {
snapshot.updateValue(newValue.flatMap { $0.map { $0.flatMap { $0.snapshot } } }, forKey: "Airings")
}
}
public struct Airing: GraphQLSelectionSet {
public static let possibleTypes = ["Airing"]
public static let selections: [Selection] = [
Field("__typename", type: .nonNull(.scalar(String.self))),
Field("contentId", type: .nonNull(.scalar(GraphQLID.self))),
Field("mediaId", type: .scalar(GraphQLID.self)),
Field("eventId", type: .scalar(GraphQLID.self)),
Field("programId", type: .scalar(GraphQLID.self)),
Field("partnerProgramId", type: .scalar(GraphQLID.self)),
Field("startDate", type: .scalar(String.self)),
Field("endDate", type: .scalar(String.self)),
Field("expires", type: .scalar(String.self)),
Field("linear", type: .scalar(Bool.self)),
Field("runTime", type: .scalar(String.self)),
Field("playbackUrls", type: .list(.object(Airing.PlaybackUrl.self))),
Field("titles", type: .list(.object(Airing.Title.self))),
Field("photos", type: .list(.object(Airing.Photo.self))),
]
public var snapshot: Snapshot
public init(snapshot: Snapshot) {
self.snapshot = snapshot
}
public init(contentId: GraphQLID, mediaId: GraphQLID? = nil, eventId: GraphQLID? = nil, programId: GraphQLID? = nil, partnerProgramId: GraphQLID? = nil, startDate: String? = nil, endDate: String? = nil, expires: String? = nil, linear: Bool? = nil, runTime: String? = nil, playbackUrls: [PlaybackUrl?]? = nil, titles: [Title?]? = nil, photos: [Photo?]? = nil) {
self.init(snapshot: ["__typename": "Airing", "contentId": contentId, "mediaId": mediaId, "eventId": eventId, "programId": programId, "partnerProgramId": partnerProgramId, "startDate": startDate, "endDate": endDate, "expires": expires, "linear": linear, "runTime": runTime, "playbackUrls": playbackUrls, "titles": titles, "photos": photos])
}
public var __typename: String {
get {
return snapshot["__typename"]! as! String
}
set {
snapshot.updateValue(newValue, forKey: "__typename")
}
}
public var contentId: GraphQLID {
get {
return snapshot["contentId"]! as! GraphQLID
}
set {
snapshot.updateValue(newValue, forKey: "contentId")
}
}
public var mediaId: GraphQLID? {
get {
return snapshot["mediaId"]! as! GraphQLID?
}
set {
snapshot.updateValue(newValue, forKey: "mediaId")
}
}
public var eventId: GraphQLID? {
get {
return snapshot["eventId"]! as! GraphQLID?
}
set {
snapshot.updateValue(newValue, forKey: "eventId")
}
}
public var programId: GraphQLID? {
get {
return snapshot["programId"]! as! GraphQLID?
}
set {
snapshot.updateValue(newValue, forKey: "programId")
}
}
public var partnerProgramId: GraphQLID? {
get {
return snapshot["partnerProgramId"]! as! GraphQLID?
}
set {
snapshot.updateValue(newValue, forKey: "partnerProgramId")
}
}
public var startDate: String? {
get {
return snapshot["startDate"]! as! String?
}
set {
snapshot.updateValue(newValue, forKey: "startDate")
}
}
public var endDate: String? {
get {
return snapshot["endDate"]! as! String?
}
set {
snapshot.updateValue(newValue, forKey: "endDate")
}
}
public var expires: String? {
get {
return snapshot["expires"]! as! String?
}
set {
snapshot.updateValue(newValue, forKey: "expires")
}
}
public var linear: Bool? {
get {
return snapshot["linear"]! as! Bool?
}
set {
snapshot.updateValue(newValue, forKey: "linear")
}
}
public var runTime: String? {
get {
return snapshot["runTime"]! as! String?
}
set {
snapshot.updateValue(newValue, forKey: "runTime")
}
}
public var playbackUrls: [PlaybackUrl?]? {
get {
return (snapshot["playbackUrls"]! as! [Snapshot?]?).flatMap { $0.map { $0.flatMap { PlaybackUrl(snapshot: $0) } } }
}
set {
snapshot.updateValue(newValue.flatMap { $0.map { $0.flatMap { $0.snapshot } } }, forKey: "playbackUrls")
}
}
public var titles: [Title?]? {
get {
return (snapshot["titles"]! as! [Snapshot?]?).flatMap { $0.map { $0.flatMap { Title(snapshot: $0) } } }
}
set {
snapshot.updateValue(newValue.flatMap { $0.map { $0.flatMap { $0.snapshot } } }, forKey: "titles")
}
}
public var photos: [Photo?]? {
get {
return (snapshot["photos"]! as! [Snapshot?]?).flatMap { $0.map { $0.flatMap { Photo(snapshot: $0) } } }
}
set {
snapshot.updateValue(newValue.flatMap { $0.map { $0.flatMap { $0.snapshot } } }, forKey: "photos")
}
}
public struct PlaybackUrl: GraphQLSelectionSet {
public static let possibleTypes = ["HypermediaLink"]
public static let selections: [Selection] = [
Field("__typename", type: .nonNull(.scalar(String.self))),
Field("rel", type: .scalar(String.self)),
Field("href", type: .scalar(String.self)),
]
public var snapshot: Snapshot
public init(snapshot: Snapshot) {
self.snapshot = snapshot
}
public init(rel: String? = nil, href: String? = nil) {
self.init(snapshot: ["__typename": "HypermediaLink", "rel": rel, "href": href])
}
public var __typename: String {
get {
return snapshot["__typename"]! as! String
}
set {
snapshot.updateValue(newValue, forKey: "__typename")
}
}
public var rel: String? {
get {
return snapshot["rel"]! as! String?
}
set {
snapshot.updateValue(newValue, forKey: "rel")
}
}
public var href: String? {
get {
return snapshot["href"]! as! String?
}
set {
snapshot.updateValue(newValue, forKey: "href")
}
}
}
public struct Title: GraphQLSelectionSet {
public static let possibleTypes = ["EpgTitle"]
public static let selections: [Selection] = [
Field("__typename", type: .nonNull(.scalar(String.self))),
Field("title", type: .scalar(String.self)),
]
public var snapshot: Snapshot
public init(snapshot: Snapshot) {
self.snapshot = snapshot
}
public init(title: String? = nil) {
self.init(snapshot: ["__typename": "EpgTitle", "title": title])
}
public var __typename: String {
get {
return snapshot["__typename"]! as! String
}
set {
snapshot.updateValue(newValue, forKey: "__typename")
}
}
public var title: String? {
get {
return snapshot["title"]! as! String?
}
set {
snapshot.updateValue(newValue, forKey: "title")
}
}
}
public struct Photo: GraphQLSelectionSet {
public static let possibleTypes = ["EpgPhoto"]
public static let selections: [Selection] = [
Field("__typename", type: .nonNull(.scalar(String.self))),
Field("uri", type: .scalar(String.self)),
]
public var snapshot: Snapshot
public init(snapshot: Snapshot) {
self.snapshot = snapshot
}
public init(uri: String? = nil) {
self.init(snapshot: ["__typename": "EpgPhoto", "uri": uri])
}
public var __typename: String {
get {
return snapshot["__typename"]! as! String
}
set {
snapshot.updateValue(newValue, forKey: "__typename")
}
}
public var uri: String? {
get {
return snapshot["uri"]! as! String?
}
set {
snapshot.updateValue(newValue, forKey: "uri")
}
}
}
}
}
}
git clone https://github.com/apollographql/apollo-codegen
mkdir BAM
apollo-codegen introspect-schema https://search-api-wwe-mock.bamgrid.com/svc/search/v2/graphql --output BAM/schema.json
#add the Airings.graphql into BAM folder.
apollo-codegen generate BAM/*.graphql --schema BAM/schema.json --output API.swift
// apollogen will complain - Apollo does not support anonymous operations / needs to be nested
{
query(index: "wwe_global", type: "Airing") {
hits {
hit {
... on Airing {
contentId
programId
partnerProgramId
mediaId
playbackUrls {
rel
href
templated
}
liveBroadcast
programType
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment