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

fix: DocumentType namespacing #2679

Merged
merged 3 commits into from
Nov 18, 2022
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
3 changes: 2 additions & 1 deletion Sources/AnimalKingdomAPI/AnimalKingdomAPI/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.6

import PackageDescription

Expand All @@ -12,6 +12,7 @@ let package = Package(
],
products: [
.library(name: "AnimalKingdomAPI", targets: ["AnimalKingdomAPI"]),
.library(name: "AnimalKingdomAPITestMocks", targets: ["AnimalKingdomAPITestMocks"]),
],
dependencies: [
.package(url: "https://github.com/apollographql/apollo-ios.git", from: "1.0.0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class PetAdoptionMutation: GraphQLMutation {
public static let operationName: String = "PetAdoptionMutation"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
mutation PetAdoptionMutation($input: PetAdoptionInput!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class AllAnimalsCCNQuery: GraphQLQuery {
public static let operationName: String = "AllAnimalsCCN"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
query AllAnimalsCCN {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class AllAnimalsIncludeSkipQuery: GraphQLQuery {
public static let operationName: String = "AllAnimalsIncludeSkipQuery"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
query AllAnimalsIncludeSkipQuery($includeSpecies: Boolean!, $skipHeightInMeters: Boolean!, $getCat: Boolean!, $getWarmBlooded: Boolean!, $varA: Boolean!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class AllAnimalsQuery: GraphQLQuery {
public static let operationName: String = "AllAnimalsQuery"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
query AllAnimalsQuery {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class ClassroomPetsCCNQuery: GraphQLQuery {
public static let operationName: String = "ClassroomPetsCCN"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
query ClassroomPetsCCN {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class ClassroomPetsQuery: GraphQLQuery {
public static let operationName: String = "ClassroomPets"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
query ClassroomPets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class DogQuery: GraphQLQuery {
public static let operationName: String = "DogQuery"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
query DogQuery {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class PetSearchQuery: GraphQLQuery {
public static let operationName: String = "PetSearch"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
query PetSearch($filters: PetSearchFilters = {species: ["Dog", "Cat"], size: SMALL, measurements: {height: 10.5, weight: 5.0}}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ struct OperationDefinitionTemplate: OperationTemplateRenderer {
operation.definition,
identifier: operation.operationIdentifier,
fragments: operation.referencedFragments,
apq: config.options.apqs,
queryStringLiteralFormat: config.options.queryStringLiteralFormat
config: config
))

\(section: VariableProperties(operation.definition.variables))
Expand Down Expand Up @@ -49,20 +48,19 @@ struct OperationDefinitionTemplate: OperationTemplateRenderer {
_ operation: CompilationResult.OperationDefinition,
identifier: @autoclosure () -> String,
fragments: OrderedSet<IR.NamedFragment>,
apq: ApolloCodegenConfiguration.APQConfig,
queryStringLiteralFormat: ApolloCodegenConfiguration.QueryStringLiteralFormat
config: ApolloCodegen.ConfigurationContext
) -> TemplateString {
let includeFragments = !fragments.isEmpty
let includeDefinition = apq != .persistedOperationsOnly
let includeDefinition = config.options.apqs != .persistedOperationsOnly

return TemplateString("""
public static let document: DocumentType = .\(apq.rendered)(
\(if: apq != .disabled, """
public static let document: \(config.ApolloAPITargetName).DocumentType = .\(config.options.apqs.rendered)(
\(if: config.options.apqs != .disabled, """
operationIdentifier: \"\(identifier())\"\(if: includeDefinition, ",")
""")
\(if: includeDefinition, """
definition: .init(
\(operation.source.formatted(for: queryStringLiteralFormat))\(if: includeFragments, ",")
\(operation.source.formatted(for: config.options.queryStringLiteralFormat))\(if: includeFragments, ",")
\(if: includeFragments,
"fragments: [\(fragments.map { "\($0.name.firstUppercased).self" }, separator: ", ")]")
))
Expand Down
2 changes: 1 addition & 1 deletion Sources/GitHubAPI/GitHubAPI/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.6

import PackageDescription

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class IssuesAndCommentsForRepositoryQuery: GraphQLQuery {
public static let operationName: String = "IssuesAndCommentsForRepository"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
query IssuesAndCommentsForRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class RepoURLQuery: GraphQLQuery {
public static let operationName: String = "RepoURL"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
query RepoURL {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class RepositoryQuery: GraphQLQuery {
public static let operationName: String = "Repository"
public static let document: DocumentType = .notPersisted(
public static let document: ApolloAPI.DocumentType = .notPersisted(
definition: .init(
"""
query Repository {
Expand Down
2 changes: 1 addition & 1 deletion Sources/StarWarsAPI/StarWarsAPI/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.6

import PackageDescription

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class CreateAwesomeReviewMutation: GraphQLMutation {
public static let operationName: String = "CreateAwesomeReview"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "4a1250de93ebcb5cad5870acf15001112bf27bb963e8709555b5ff67a1405374",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class CreateReviewForEpisodeMutation: GraphQLMutation {
public static let operationName: String = "CreateReviewForEpisode"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "9bbf5b4074d0635fb19d17c621b7b04ebfb1920d468a94266819e149841e7d5d",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class CreateReviewWithNullFieldMutation: GraphQLMutation {
public static let operationName: String = "CreateReviewWithNullField"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "a9600d176cd7e4671b8689f1d01fe79ea896932bfafb8a925af673f0e4111828",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class DroidDetailsWithFragmentQuery: GraphQLQuery {
public static let operationName: String = "DroidDetailsWithFragment"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "7277e97563e911ac8f5c91d401028d218aae41f38df014d7fa0b037bb2a2e739",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroAndFriendsIDsQuery: GraphQLQuery {
public static let operationName: String = "HeroAndFriendsIDs"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "117d0f6831d8f4abe5b61ed1dbb8071b0825e19649916c0fe0906a6f578bb088",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroAndFriendsNamesQuery: GraphQLQuery {
public static let operationName: String = "HeroAndFriendsNames"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "fe3f21394eb861aa515c4d582e645469045793c9cbbeca4b5d4ce4d7dd617556",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroAndFriendsNamesWithFragmentQuery: GraphQLQuery {
public static let operationName: String = "HeroAndFriendsNamesWithFragment"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "1d3ad903dad146ff9d7aa09813fc01becd017489bfc1af8ffd178498730a5a26",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroAndFriendsNamesWithFragmentTwiceQuery: GraphQLQuery {
public static let operationName: String = "HeroAndFriendsNamesWithFragmentTwice"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "b5f4eca712a136f0d5d9f96203ef7d03cd119d8388f093f4b78ae124acb904cb",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroAndFriendsNamesWithIDForParentOnlyQuery: GraphQLQuery {
public static let operationName: String = "HeroAndFriendsNamesWithIDForParentOnly"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "f091468a629f3b757c03a1b7710c6ede8b5c8f10df7ba3238f2bbcd71c56f90f",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroAndFriendsNamesWithIDsQuery: GraphQLQuery {
public static let operationName: String = "HeroAndFriendsNamesWithIDs"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "8e4ca76c63660898cfd5a3845e3709027750b5f0151c7f9be65759b869c5486d",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroAppearsInQuery: GraphQLQuery {
public static let operationName: String = "HeroAppearsIn"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "22d772c0fc813281705e8f0a55fc70e71eeff6e98f3f9ef96cf67fb896914522",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroAppearsInWithFragmentQuery: GraphQLQuery {
public static let operationName: String = "HeroAppearsInWithFragment"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "1756158bd7736d58db45a48d74a724fa1b6fdac735376df8afac8318ba5431fb",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroDetailsFragmentConditionalInclusionQuery: GraphQLQuery {
public static let operationName: String = "HeroDetailsFragmentConditionalInclusion"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "b0fa7927ff93b4a579c3460fb04d093072d34c8018e41197c7e080aeeec5e19b",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroDetailsInlineConditionalInclusionQuery: GraphQLQuery {
public static let operationName: String = "HeroDetailsInlineConditionalInclusion"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "3091d9d3f1d2374e2f835ce05d332e50b3fe61502d73213b9aa511f0f94f091c",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroDetailsQuery: GraphQLQuery {
public static let operationName: String = "HeroDetails"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "207d29944f5822bff08a07db4a55274ea14035bacfe20699da41a47454f1181e",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroDetailsWithFragmentQuery: GraphQLQuery {
public static let operationName: String = "HeroDetailsWithFragment"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "b55bd9d56d1b5972345412b6adb88ceb64d6086c8051d2588d8ab701f0ee7c2f",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroFriendsDetailsConditionalInclusionQuery: GraphQLQuery {
public static let operationName: String = "HeroFriendsDetailsConditionalInclusion"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "8cada231691ff2f5a0a07c54b7332114588f11b947795da345c5b054211fbcfd",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroFriendsDetailsUnconditionalAndConditionalInclusionQuery: GraphQLQuery {
public static let operationName: String = "HeroFriendsDetailsUnconditionalAndConditionalInclusion"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "65381a20574db4b458a0821328252deb0da1a107f9ab77c99fb2467e66a5f12d",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroFriendsOfFriendsNamesQuery: GraphQLQuery {
public static let operationName: String = "HeroFriendsOfFriendsNames"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "37cd5626048e7243716ffda9e56503939dd189772124a1c21b0e0b87e69aae01",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroNameAndAppearsInQuery: GraphQLQuery {
public static let operationName: String = "HeroNameAndAppearsIn"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "f714414a2002404f9943490c8cc9c1a7b8ecac3ca229fa5a326186b43c1385ce",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroNameAndAppearsInWithFragmentQuery: GraphQLQuery {
public static let operationName: String = "HeroNameAndAppearsInWithFragment"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "0664fed3eb4f9fbdb44e8691d9e8fd11f2b3c097ba11327592054f602bd3ba1a",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroNameConditionalBothQuery: GraphQLQuery {
public static let operationName: String = "HeroNameConditionalBoth"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "66f4dc124b6374b1912b22a2a208e34a4b1997349402a372b95bcfafc7884064",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroNameConditionalBothSeparateQuery: GraphQLQuery {
public static let operationName: String = "HeroNameConditionalBothSeparate"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "d0f9e9205cdc09320035662f528a177654d3275b0bf94cf0e259a65fde33e7e5",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroNameConditionalExclusionQuery: GraphQLQuery {
public static let operationName: String = "HeroNameConditionalExclusion"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "3dd42259adf2d0598e89e0279bee2c128a7913f02b1da6aa43f3b5def6a8a1f8",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroNameConditionalInclusionQuery: GraphQLQuery {
public static let operationName: String = "HeroNameConditionalInclusion"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "338081aea3acc83d04af0741ecf0da1ec2ee8e6468a88383476b681015905ef8",
definition: .init(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class HeroNameQuery: GraphQLQuery {
public static let operationName: String = "HeroName"
public static let document: DocumentType = .automaticallyPersisted(
public static let document: ApolloAPI.DocumentType = .automaticallyPersisted(
operationIdentifier: "f6e76545cd03aa21368d9969cb39447f6e836a16717823281803778e7805d671",
definition: .init(
"""
Expand Down
Loading