diff --git a/.gitignore b/.gitignore index faa5046b21..47f06525d4 100644 --- a/.gitignore +++ b/.gitignore @@ -58,7 +58,9 @@ scripts/apollo.tar.gz SwiftScripts/ApolloCLI Tests/ApolloCodegenTests/scripts Tests/ApolloCodegenTests/scripts directory +Tests/ApolloCodegenTests/Schema +Tests/ApolloCodegenTests/Output SwiftScripts/.build-** # Local Netlify folder -.netlify \ No newline at end of file +.netlify diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj index fd0bb919ff..36935d4cd7 100644 --- a/Apollo.xcodeproj/project.pbxproj +++ b/Apollo.xcodeproj/project.pbxproj @@ -69,7 +69,7 @@ 9B9F16B82601532500FB2F31 /* SQLiteDotSwiftDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B9F16B72601532500FB2F31 /* SQLiteDotSwiftDatabase.swift */; }; 9BA1244A22D8A8EA00BF1D24 /* JSONSerialization+Sorting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BA1244922D8A8EA00BF1D24 /* JSONSerialization+Sorting.swift */; }; 9BA3130E2302BEA5007B7FC5 /* DispatchQueue+Optional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BA3130D2302BEA5007B7FC5 /* DispatchQueue+Optional.swift */; }; - 9BAEEBEE2346644600808306 /* ApolloSchemaOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAEEBED2346644600808306 /* ApolloSchemaOptions.swift */; }; + 9BAEEBEE2346644600808306 /* ApolloSchemaDownloadConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAEEBED2346644600808306 /* ApolloSchemaDownloadConfiguration.swift */; }; 9BAEEBEF2346644B00808306 /* ApolloSchemaDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAEEBEB234663F200808306 /* ApolloSchemaDownloader.swift */; }; 9BAEEBF123467E0A00808306 /* ApolloCLI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAEEBF023467E0A00808306 /* ApolloCLI.swift */; }; 9BAEEBF32346DDAD00808306 /* CodegenLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAEEBF22346DDAD00808306 /* CodegenLogger.swift */; }; @@ -86,6 +86,7 @@ 9BC2D9D3233C6EF0007BD083 /* Basher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BC2D9D1233C6DC0007BD083 /* Basher.swift */; }; 9BC742AC24CFB2FF0029282C /* ApolloErrorInterceptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BC742AB24CFB2FF0029282C /* ApolloErrorInterceptor.swift */; }; 9BC742AE24CFB6450029282C /* CacheWriteInterceptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BC742AD24CFB6450029282C /* CacheWriteInterceptor.swift */; }; + 9BCA8C0926618226004FF2F6 /* UntypedGraphQLRequestBodyCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BCA8C0826618226004FF2F6 /* UntypedGraphQLRequestBodyCreator.swift */; }; 9BCF0CE023FC9CA50031D2A2 /* TestCacheProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BCF0CD923FC9CA50031D2A2 /* TestCacheProvider.swift */; }; 9BCF0CE323FC9CA50031D2A2 /* XCTAssertHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BCF0CDC23FC9CA50031D2A2 /* XCTAssertHelpers.swift */; }; 9BCF0CE423FC9CA50031D2A2 /* MockURLSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BCF0CDD23FC9CA50031D2A2 /* MockURLSession.swift */; }; @@ -106,6 +107,7 @@ 9BF6C94325194DE2000D5B93 /* MultipartFormData+Testing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BF6C91725194D7B000D5B93 /* MultipartFormData+Testing.swift */; }; 9BF6C97025194ED7000D5B93 /* MultipartFormDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BF6C95225194EA5000D5B93 /* MultipartFormDataTests.swift */; }; 9BF6C99C25195019000D5B93 /* String+IncludesForTesting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BF6C99B25195019000D5B93 /* String+IncludesForTesting.swift */; }; + 9BFE8DA9265D5D8F000BBF81 /* URLDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BFE8DA8265D5D8F000BBF81 /* URLDownloader.swift */; }; 9F1A966B258F34BB00A06EEB /* ApolloCodegenFrontend.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F1A9665258F34BB00A06EEB /* ApolloCodegenFrontend.swift */; }; 9F1A966C258F34BB00A06EEB /* GraphQLSchema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F1A9667258F34BB00A06EEB /* GraphQLSchema.swift */; }; 9F1A966D258F34BB00A06EEB /* CompilationResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F1A9668258F34BB00A06EEB /* CompilationResult.swift */; }; @@ -248,6 +250,10 @@ DED46051261CEAD20086EF63 /* StarWarsAPI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9FCE2CFA1E6C213D00E34457 /* StarWarsAPI.framework */; }; E616B6D126C3335600DB049E /* ExecutionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E616B6D026C3335600DB049E /* ExecutionTests.swift */; }; E61DD76526D60C1800C41614 /* SQLiteDotSwiftDatabaseBehaviorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E61DD76426D60C1800C41614 /* SQLiteDotSwiftDatabaseBehaviorTests.swift */; }; + E6630B8C26F0639B002D9E41 /* MockNetworkSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D79AB926EC05290094434A /* MockNetworkSession.swift */; }; + E6630B8E26F071F9002D9E41 /* SchemaRegistryApolloSchemaDownloaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6630B8D26F071F9002D9E41 /* SchemaRegistryApolloSchemaDownloaderTests.swift */; }; + E6C4267B26F16CB400904AD2 /* introspection_response.json in Resources */ = {isa = PBXBuildFile; fileRef = E6C4267A26F16CB400904AD2 /* introspection_response.json */; }; + E6D79AB826E9D59C0094434A /* URLDownloaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D79AB626E97D0D0094434A /* URLDownloaderTests.swift */; }; E86D8E05214B32FD0028EFE1 /* JSONTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E86D8E03214B32DA0028EFE1 /* JSONTests.swift */; }; F16D083C21EF6F7300C458B8 /* QueryFromJSONBuildingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F16D083B21EF6F7300C458B8 /* QueryFromJSONBuildingTests.swift */; }; F82E62E122BCD223000C311B /* AutomaticPersistedQueriesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F82E62E022BCD223000C311B /* AutomaticPersistedQueriesTests.swift */; }; @@ -623,7 +629,7 @@ 9BA1244922D8A8EA00BF1D24 /* JSONSerialization+Sorting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "JSONSerialization+Sorting.swift"; sourceTree = ""; }; 9BA3130D2302BEA5007B7FC5 /* DispatchQueue+Optional.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DispatchQueue+Optional.swift"; sourceTree = ""; }; 9BAEEBEB234663F200808306 /* ApolloSchemaDownloader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApolloSchemaDownloader.swift; sourceTree = ""; }; - 9BAEEBED2346644600808306 /* ApolloSchemaOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApolloSchemaOptions.swift; sourceTree = ""; }; + 9BAEEBED2346644600808306 /* ApolloSchemaDownloadConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApolloSchemaDownloadConfiguration.swift; sourceTree = ""; }; 9BAEEBF023467E0A00808306 /* ApolloCLI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApolloCLI.swift; sourceTree = ""; }; 9BAEEBF22346DDAD00808306 /* CodegenLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodegenLogger.swift; sourceTree = ""; }; 9BAEEBF42346E90700808306 /* CLIExtractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLIExtractor.swift; sourceTree = ""; }; @@ -642,6 +648,7 @@ 9BC2D9D1233C6DC0007BD083 /* Basher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Basher.swift; sourceTree = ""; }; 9BC742AB24CFB2FF0029282C /* ApolloErrorInterceptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApolloErrorInterceptor.swift; sourceTree = ""; }; 9BC742AD24CFB6450029282C /* CacheWriteInterceptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CacheWriteInterceptor.swift; sourceTree = ""; }; + 9BCA8C0826618226004FF2F6 /* UntypedGraphQLRequestBodyCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UntypedGraphQLRequestBodyCreator.swift; sourceTree = ""; }; 9BCF0CD923FC9CA50031D2A2 /* TestCacheProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestCacheProvider.swift; sourceTree = ""; }; 9BCF0CDA23FC9CA50031D2A2 /* ApolloTestSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApolloTestSupport.h; sourceTree = ""; }; 9BCF0CDC23FC9CA50031D2A2 /* XCTAssertHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCTAssertHelpers.swift; sourceTree = ""; }; @@ -666,6 +673,7 @@ 9BF6C91725194D7B000D5B93 /* MultipartFormData+Testing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MultipartFormData+Testing.swift"; sourceTree = ""; }; 9BF6C95225194EA5000D5B93 /* MultipartFormDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultipartFormDataTests.swift; sourceTree = ""; }; 9BF6C99B25195019000D5B93 /* String+IncludesForTesting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+IncludesForTesting.swift"; sourceTree = ""; }; + 9BFE8DA8265D5D8F000BBF81 /* URLDownloader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLDownloader.swift; sourceTree = ""; }; 9F1A9665258F34BB00A06EEB /* ApolloCodegenFrontend.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApolloCodegenFrontend.swift; sourceTree = ""; }; 9F1A9667258F34BB00A06EEB /* GraphQLSchema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphQLSchema.swift; sourceTree = ""; }; 9F1A9668258F34BB00A06EEB /* CompilationResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompilationResult.swift; sourceTree = ""; }; @@ -810,6 +818,10 @@ DED45FB3261CDEC60086EF63 /* Apollo-CodegenTestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = "Apollo-CodegenTestPlan.xctestplan"; sourceTree = ""; }; E616B6D026C3335600DB049E /* ExecutionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExecutionTests.swift; sourceTree = ""; }; E61DD76426D60C1800C41614 /* SQLiteDotSwiftDatabaseBehaviorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLiteDotSwiftDatabaseBehaviorTests.swift; sourceTree = ""; }; + E6630B8D26F071F9002D9E41 /* SchemaRegistryApolloSchemaDownloaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SchemaRegistryApolloSchemaDownloaderTests.swift; sourceTree = ""; }; + E6C4267A26F16CB400904AD2 /* introspection_response.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = introspection_response.json; sourceTree = ""; }; + E6D79AB626E97D0D0094434A /* URLDownloaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLDownloaderTests.swift; sourceTree = ""; }; + E6D79AB926EC05290094434A /* MockNetworkSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockNetworkSession.swift; sourceTree = ""; }; E86D8E03214B32DA0028EFE1 /* JSONTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONTests.swift; sourceTree = ""; }; F16D083B21EF6F7300C458B8 /* QueryFromJSONBuildingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryFromJSONBuildingTests.swift; sourceTree = ""; }; F82E62E022BCD223000C311B /* AutomaticPersistedQueriesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutomaticPersistedQueriesTests.swift; sourceTree = ""; }; @@ -1171,6 +1183,8 @@ 9BAEEBF22346DDAD00808306 /* CodegenLogger.swift */, 9BE74D3C23FB4A8E006D354F /* FileFinder.swift */, 9B7B6F51233C26E400F32205 /* Info.plist */, + 9BFE8DA8265D5D8F000BBF81 /* URLDownloader.swift */, + 9BCA8C0826618226004FF2F6 /* UntypedGraphQLRequestBodyCreator.swift */, ); name = ApolloCodegenLib; path = Sources/ApolloCodegenLib; @@ -1226,6 +1240,7 @@ children = ( 9F1A96AE258F367100A06EEB /* Frontend */, 9B8110A623A1994000688AC4 /* SourcePackages */, + E6BE04ED26F11B3500CF858D /* Resources */, 9BAEEC16234C275600808306 /* ApolloSchemaTests.swift */, 9BAEEC18234C297800808306 /* ApolloCodegenTests.swift */, 9B518C88235F8AD4004C426D /* CLIDownloaderTests.swift */, @@ -1234,6 +1249,7 @@ 9B68F0542416B33300E97318 /* LineByLineComparison.swift */, 9B8C3FB4248DA3E000707B13 /* URLExtensionsTests.swift */, 9BAEEC0C234BB95B00808306 /* Info.plist */, + E6D79AB626E97D0D0094434A /* URLDownloaderTests.swift */, ); path = ApolloCodegenTests; sourceTree = ""; @@ -1322,7 +1338,7 @@ isa = PBXGroup; children = ( 9BAEEBEB234663F200808306 /* ApolloSchemaDownloader.swift */, - 9BAEEBED2346644600808306 /* ApolloSchemaOptions.swift */, + 9BAEEBED2346644600808306 /* ApolloSchemaDownloadConfiguration.swift */, ); name = SchemaDownload; sourceTree = ""; @@ -1647,6 +1663,7 @@ DE6B15B026152BE10068D642 /* Info.plist */, DED45F49261CDBFC0086EF63 /* UploadTests.swift */, DECD46CF262F64D000924527 /* StarWarsApolloSchemaDownloaderTests.swift */, + E6630B8D26F071F9002D9E41 /* SchemaRegistryApolloSchemaDownloaderTests.swift */, ); path = ApolloServerIntegrationTests; sourceTree = ""; @@ -1686,6 +1703,7 @@ children = ( DECD490D262F81BF00924527 /* ApolloCodegenTestSupport.h */, 9BAEEC11234BBA9200808306 /* CodegenTestHelper.swift */, + E6D79AB926EC05290094434A /* MockNetworkSession.swift */, DECD490E262F81BF00924527 /* Info.plist */, ); name = ApolloCodegenTestSupport; @@ -1749,6 +1767,14 @@ path = DefaultImplementation; sourceTree = ""; }; + E6BE04ED26F11B3500CF858D /* Resources */ = { + isa = PBXGroup; + children = ( + E6C4267A26F16CB400904AD2 /* introspection_response.json */, + ); + path = Resources; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -2294,6 +2320,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + E6C4267B26F16CB400904AD2 /* introspection_response.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2435,18 +2462,20 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 9BAEEBEE2346644600808306 /* ApolloSchemaOptions.swift in Sources */, + 9BAEEBEE2346644600808306 /* ApolloSchemaDownloadConfiguration.swift in Sources */, 9BC2D9D3233C6EF0007BD083 /* Basher.swift in Sources */, 9B8C3FB3248DA2FE00707B13 /* URL+Apollo.swift in Sources */, 9BAEEBEF2346644B00808306 /* ApolloSchemaDownloader.swift in Sources */, 9F1A966F258F34BB00A06EEB /* JavaScriptBridge.swift in Sources */, 9BAEEBF72346F0A000808306 /* StaticString+Apollo.swift in Sources */, + 9BCA8C0926618226004FF2F6 /* UntypedGraphQLRequestBodyCreator.swift in Sources */, 9F62DFD02590710E00E6E808 /* GraphQLSource.swift in Sources */, 9BAEEBF32346DDAD00808306 /* CodegenLogger.swift in Sources */, 9F628EB52593651B00F94F9D /* GraphQLValue.swift in Sources */, 9B518C8C235F8B5F004C426D /* ApolloFilePathHelper.swift in Sources */, 9F628E9525935BE600F94F9D /* GraphQLType.swift in Sources */, 9B518C87235F819E004C426D /* CLIDownloader.swift in Sources */, + 9BFE8DA9265D5D8F000BBF81 /* URLDownloader.swift in Sources */, 9F1A966D258F34BB00A06EEB /* CompilationResult.swift in Sources */, 9BAEEBF123467E0A00808306 /* ApolloCLI.swift in Sources */, 9B7B6F69233C2C0C00F32205 /* FileManager+Apollo.swift in Sources */, @@ -2502,6 +2531,7 @@ 9B8C3FB5248DA3E000707B13 /* URLExtensionsTests.swift in Sources */, 9B518C8D235F8B9E004C426D /* CLIDownloaderTests.swift in Sources */, 9FDE0731258F3AA100DC0CA5 /* SchemaLoadingTests.swift in Sources */, + E6D79AB826E9D59C0094434A /* URLDownloaderTests.swift in Sources */, 9F62DF8E2590539A00E6E808 /* SchemaIntrospectionTests.swift in Sources */, 9B68F0552416B33300E97318 /* LineByLineComparison.swift in Sources */, 9BAEEC15234C132600808306 /* CLIExtractorTests.swift in Sources */, @@ -2703,6 +2733,7 @@ DE6B15AF26152BE10068D642 /* DefaultInterceptorProviderIntegrationTests.swift in Sources */, DED46000261CE9080086EF63 /* HTTPBinAPI.swift in Sources */, DED45F4A261CDBFC0086EF63 /* UploadTests.swift in Sources */, + E6630B8E26F071F9002D9E41 /* SchemaRegistryApolloSchemaDownloaderTests.swift in Sources */, DED45F17261CDA360086EF63 /* StarWarsWebSocketTests.swift in Sources */, DED45D73261675890086EF63 /* StarWarsServerTests.swift in Sources */, DED45F30261CDB560086EF63 /* URLSessionClientTests.swift in Sources */, @@ -2714,6 +2745,7 @@ buildActionMask = 2147483647; files = ( DECD4921262F81CE00924527 /* CodegenTestHelper.swift in Sources */, + E6630B8C26F0639B002D9E41 /* MockNetworkSession.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Sources/ApolloCodegenLib/ApolloCLI.swift b/Sources/ApolloCodegenLib/ApolloCLI.swift index 36385d5b57..341bc9940a 100644 --- a/Sources/ApolloCodegenLib/ApolloCLI.swift +++ b/Sources/ApolloCodegenLib/ApolloCLI.swift @@ -20,11 +20,11 @@ public struct ApolloCLI { let lock = try waitForCLIFolderLock(cliFolderURL: cliFolderURL, timeout: timeout) defer { lock.unlock() } - try CLIDownloader.downloadIfNeeded(cliFolderURL: cliFolderURL, timeout: timeout) + try CLIDownloader.downloadIfNeeded(to: cliFolderURL, timeout: timeout) if !(try CLIExtractor.validateSHASUMOfDownloadedFile(in: cliFolderURL)) { CodegenLogger.log("Downloaded zip file has incorrect SHASUM, forcing redownload") - try CLIDownloader.forceRedownload(cliFolderURL: cliFolderURL, timeout: timeout) + try CLIDownloader.forceRedownload(to: cliFolderURL, timeout: timeout) } let binaryFolderURL = try CLIExtractor.extractCLIIfNeeded(from: cliFolderURL) diff --git a/Sources/ApolloCodegenLib/ApolloSchemaDownloadConfiguration.swift b/Sources/ApolloCodegenLib/ApolloSchemaDownloadConfiguration.swift new file mode 100644 index 0000000000..08a0802928 --- /dev/null +++ b/Sources/ApolloCodegenLib/ApolloSchemaDownloadConfiguration.swift @@ -0,0 +1,97 @@ +import Foundation + +/// A configuration object that defines behavior for schema download. +public struct ApolloSchemaDownloadConfiguration { + + /// How to attempt to download your schema + public enum DownloadMethod: Equatable { + + /// The Apollo Schema Registry, which serves as a central hub for managing your data graph. + case apolloRegistry(_ settings: ApolloRegistrySettings) + /// GraphQL Introspection connecting to the specified URL. + case introspection(endpointURL: URL) + + public struct ApolloRegistrySettings: Equatable { + /// The API key to use when retrieving your schema from the Apollo Registry. + public let apiKey: String + /// The identifier of the graph to fetch. Can be found in Apollo Studio. + public let graphID: String + /// The variant of the graph in the registry. + public let variant: String? + + /// Designated initializer + /// + /// - Parameters: + /// - apiKey: The API key to use when retrieving your schema. + /// - graphID: The identifier of the graph to fetch. Can be found in Apollo Studio. + /// - variant: The variant of the graph to fetch. Defaults to "current", which will return whatever is set to the current variant. + public init(apiKey: String, + graphID: String, + variant: String = "current") { + self.apiKey = apiKey + self.graphID = graphID + self.variant = variant + } + } + + public static func == (lhs: DownloadMethod, rhs: DownloadMethod) -> Bool { + switch (lhs, rhs) { + case (.introspection(let lhsURL), introspection(let rhsURL)): + return lhsURL == rhsURL + case (.apolloRegistry(let lhsSettings), .apolloRegistry(let rhsSettings)): + return lhsSettings == rhsSettings + default: + return false + } + } + + } + + public struct HTTPHeader: Equatable, CustomDebugStringConvertible { + let key: String + let value: String + + public var debugDescription: String { + "\(key): \(value)" + } + } + + /// How to download your schema. Supports the Apollo Registry and GraphQL Introspection methods. + let downloadMethod: DownloadMethod + /// The maximum time to wait before indicating that the download timed out, in seconds. Defaults to 30 seconds. + let downloadTimeout: Double + /// Any additional headers to include when retrieving your schema. Defaults to nil. + let headers: [HTTPHeader] + /// The URL of the folder in which the downloaded schema should be written. + let outputURL: URL + + /// Designated Initializer + /// + /// - Parameters: + /// - downloadMethod: How to download your schema. + /// - downloadTimeout: The maximum time to wait before indicating that the download timed out, in seconds. Defaults to 30 seconds. + /// - headers: [optional] Any additional headers to include when retrieving your schema. Defaults to nil + /// - outputFolderURL: The URL of the folder in which the downloaded schema should be written + /// - schemaFilename: The name, without an extension, for your schema file. Defaults to `"schema" + public init(using downloadMethod: DownloadMethod, + timeout downloadTimeout: Double = 30.0, + headers: [HTTPHeader] = [], + outputFolderURL: URL, + schemaFilename: String = "schema") { + self.downloadMethod = downloadMethod + self.downloadTimeout = downloadTimeout + self.headers = headers + self.outputURL = outputFolderURL.appendingPathComponent("\(schemaFilename).graphqls") + } +} + +extension ApolloSchemaDownloadConfiguration: CustomDebugStringConvertible { + public var debugDescription: String { + return """ + downloadMethod: \(self.downloadMethod) + downloadTimeout: \(self.downloadTimeout) + headers: \(self.headers) + outputURL: \(self.outputURL) + """ + } +} diff --git a/Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift b/Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift index 13de73c727..d3bdf66978 100644 --- a/Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift +++ b/Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift @@ -1,25 +1,285 @@ import Foundation - // Only available on macOS #if os(macOS) /// A wrapper to facilitate downloading a schema with the Apollo node CLI public struct ApolloSchemaDownloader { - /// Runs code generation from the given folder with the passed-in options + public enum SchemaDownloadError: Error, LocalizedError { + case downloadedRegistryJSONFileNotFound(underlying: Error) + case downloadedIntrospectionJSONFileNotFound(underlying: Error) + case couldNotParseRegistryJSON(underlying: Error) + case unexpectedRegistryJSONType + case couldNotExtractSDLFromRegistryJSON + case couldNotCreateSDLDataToWrite(schema: String) + case couldNotConvertIntrospectionJSONToSDL(underlying: Error) + + public var errorDescription: String? { + switch self { + case .downloadedRegistryJSONFileNotFound(let underlying): + return "Could not load the JSON file downloaded from the registry. Underlying error: \(underlying)" + case .downloadedIntrospectionJSONFileNotFound(let underlying): + return "Could not load the JSON file downloaded from your server via introspection. Underlying error: \(underlying)" + case .couldNotParseRegistryJSON(let underlying): + return "Could not parse JSON returned by the registry. Underlying error: \(underlying)" + case .unexpectedRegistryJSONType: + return "Root type in the registry JSON was not a dictionary." + case .couldNotExtractSDLFromRegistryJSON: + return "Could not extract the SDL schema from JSON sent by the registry." + case .couldNotCreateSDLDataToWrite(let schema): + return "Could not convert SDL schema into data to write to the filesystem. Schema: \(schema)" + case .couldNotConvertIntrospectionJSONToSDL(let underlying): + return "Could not convert downloaded introspection JSON into SDL format. Underlying error: \(underlying)" + } + } + } + + /// Downloads your schema using the specified configuration object. /// /// - Parameters: - /// - cliFolderURL: The folder where the Apollo CLI is/should be downloaded. - /// - options: The `ApolloSchemaOptions` object to use to download the schema. + /// - configuration: The `ApolloSchemaDownloadConfiguration` object to use to download the schema. /// - Returns: Output from a successful run - @discardableResult - public static func run(with cliFolderURL: URL, - options: ApolloSchemaOptions) throws -> String { - try FileManager.default.apollo.createContainingFolderIfNeeded(for: options.outputURL) + public static func fetch(with configuration: ApolloSchemaDownloadConfiguration) throws { + try FileManager.default.apollo.createContainingFolderIfNeeded(for: configuration.outputURL) + + switch configuration.downloadMethod { + case .introspection(let endpointURL): + try self.downloadViaIntrospection(from: endpointURL, configuration: configuration) + case .apolloRegistry(let settings): + try self.downloadFromRegistry(with: settings, configuration: configuration) + } + } + + // MARK: - Schema Registry + + static let RegistryEndpoint = URL(string: "https://graphql.api.apollographql.com/api/graphql")! + + private static let RegistryDownloadQuery = """ + query DownloadSchema($graphID: ID!, $variant: String!) { + service(id: $graphID) { + variant(name: $variant) { + activeSchemaPublish { + schema { + document + } + } + } + } + } + """ - let cli = try ApolloCLI.createCLI(cliFolderURL: cliFolderURL, timeout: options.downloadTimeout) - return try cli.runApollo(with: options.arguments) + + static func downloadFromRegistry(with settings: ApolloSchemaDownloadConfiguration.DownloadMethod.ApolloRegistrySettings, + configuration: ApolloSchemaDownloadConfiguration) throws { + + CodegenLogger.log("Downloading schema from registry", logLevel: .debug) + + var variables = [String: String]() + variables["graphID"] = settings.graphID + + if let variant = settings.variant { + variables["variant"] = variant + } + + let body = UntypedGraphQLRequestBodyCreator.requestBody(for: self.RegistryDownloadQuery, + variables: variables, + operationName: "DownloadSchema") + + var urlRequest = URLRequest(url: self.RegistryEndpoint) + urlRequest.addValue("application/json", forHTTPHeaderField: "Content-Type") + urlRequest.addValue(settings.apiKey, forHTTPHeaderField: "x-api-key") + for header in configuration.headers { + urlRequest.addValue(header.value, forHTTPHeaderField: header.key) + } + urlRequest.httpMethod = "POST" + urlRequest.httpBody = try JSONSerialization.data(withJSONObject: body, options: [.sortedKeys]) + let jsonOutputURL = configuration.outputURL.apollo.parentFolderURL().appendingPathComponent("registry_response.json") + + try URLDownloader().downloadSynchronously(with: urlRequest, + to: jsonOutputURL, + timeout: configuration.downloadTimeout) + + try self.convertFromRegistryJSONToSDLFile(jsonFileURL: jsonOutputURL, configuration: configuration) + + CodegenLogger.log("Successfully downloaded schema from registry", logLevel: .debug) } -} + static func convertFromRegistryJSONToSDLFile(jsonFileURL: URL, configuration: ApolloSchemaDownloadConfiguration) throws { + let jsonData: Data + + do { + jsonData = try Data(contentsOf: jsonFileURL) + } catch { + throw SchemaDownloadError.downloadedRegistryJSONFileNotFound(underlying: error) + } + + let json: Any + do { + json = try JSONSerialization.jsonObject(with: jsonData) + } catch { + throw SchemaDownloadError.couldNotParseRegistryJSON(underlying: error) + } + + guard let dict = json as? [String: Any] else { + throw SchemaDownloadError.unexpectedRegistryJSONType + } + + guard + let data = dict["data"] as? [String: Any], + let service = data["service"] as? [String: Any], + let variant = service["variant"] as? [String: Any], + let asp = variant["activeSchemaPublish"] as? [String: Any], + let schemaDict = asp["schema"] as? [String: Any], + let sdlSchema = schemaDict["document"] as? String else { + throw SchemaDownloadError.couldNotExtractSDLFromRegistryJSON + } + + guard let sdlData = sdlSchema.data(using: .utf8) else { + throw SchemaDownloadError.couldNotCreateSDLDataToWrite(schema: sdlSchema) + } + + try sdlData.write(to: configuration.outputURL) + } + + // MARK: - Schema Introspection + + private static let IntrospectionQuery = """ + query IntrospectionQuery { + __schema { + queryType { name } + mutationType { name } + subscriptionType { name } + types { + ...FullType + } + directives { + name + description + locations + args { + ...InputValue + } + } + } + } + fragment FullType on __Type { + kind + name + description + fields(includeDeprecated: true) { + name + description + args { + ...InputValue + } + type { + ...TypeRef + } + isDeprecated + deprecationReason + } + inputFields { + ...InputValue + } + interfaces { + ...TypeRef + } + enumValues(includeDeprecated: true) { + name + description + isDeprecated + deprecationReason + } + possibleTypes { + ...TypeRef + } + } + fragment InputValue on __InputValue { + name + description + type { ...TypeRef } + defaultValue + } + fragment TypeRef on __Type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } + } + """ + + + static func downloadViaIntrospection(from endpointURL: URL, configuration: ApolloSchemaDownloadConfiguration) throws { + CodegenLogger.log("Downloading schema via introspection from \(endpointURL)", logLevel: .debug) + + var urlRequest = URLRequest(url: endpointURL) + urlRequest.addValue("application/json", forHTTPHeaderField: "Content-Type") + + for header in configuration.headers { + urlRequest.addValue(header.value, forHTTPHeaderField: header.key) + } + + let body = UntypedGraphQLRequestBodyCreator.requestBody(for: self.IntrospectionQuery, + variables: nil, + operationName: "IntrospectionQuery") + urlRequest.httpMethod = "POST" + urlRequest.httpBody = try JSONSerialization.data(withJSONObject: body, options: [.sortedKeys]) + let jsonOutputURL = configuration.outputURL.apollo.parentFolderURL().appendingPathComponent("introspection_response.json") + + try URLDownloader().downloadSynchronously(with: urlRequest, + to: jsonOutputURL, + timeout: configuration.downloadTimeout) + + try convertFromIntrospectionJSONToSDLFile(jsonFileURL: jsonOutputURL, configuration: configuration) + + CodegenLogger.log("Successfully downloaded schema via introspection", logLevel: .debug) + } + + static func convertFromIntrospectionJSONToSDLFile(jsonFileURL: URL, configuration: ApolloSchemaDownloadConfiguration) throws { + let frontend = try ApolloCodegenFrontend() + let schema: GraphQLSchema + do { + schema = try frontend.loadSchema(from: jsonFileURL) + } catch { + throw SchemaDownloadError.downloadedIntrospectionJSONFileNotFound(underlying: error) + } + + let sdlSchema: String + do { + sdlSchema = try frontend.printSchemaAsSDL(schema: schema) + } catch { + throw SchemaDownloadError.couldNotConvertIntrospectionJSONToSDL(underlying: error) + } + + try sdlSchema.write(to: configuration.outputURL, + atomically: true, + encoding: .utf8) + } +} #endif diff --git a/Sources/ApolloCodegenLib/ApolloSchemaOptions.swift b/Sources/ApolloCodegenLib/ApolloSchemaOptions.swift deleted file mode 100644 index 05cd300e3e..0000000000 --- a/Sources/ApolloCodegenLib/ApolloSchemaOptions.swift +++ /dev/null @@ -1,113 +0,0 @@ -import Foundation - -/// Options for running the Apollo Schema Downloader. -public struct ApolloSchemaOptions { - - /// The type of schema file to download - public enum SchemaFileType: String { - case json - case schemaDefinitionLanguage = "graphql" - } - - /// How to attempt to download your schema - public enum DownloadMethod: Equatable { - - case registry(_ settings: RegistrySettings) - /// - endpointURL: The endpoint to hit to download your schema. - case introspection(endpointURL: URL) - - public struct RegistrySettings: Equatable { - public let apiKey: String - public let graphID: String - public let variant: String? - - /// Designated initializer - /// - /// - Parameters: - /// - apiKey: The API key to use when retrieving your schema. - /// - graphID: The identifier of the graph to fetch. Can be found in Apollo Studio. - /// - variant: [Optional] The variant of the graph to fetch. Defaults to nil, which will return whatever is set to the current variant. - public init(apiKey: String, - graphID: String, - variant: String? = nil) { - self.apiKey = apiKey - self.graphID = graphID - self.variant = variant - } - } - - public static func == (lhs: DownloadMethod, rhs: DownloadMethod) -> Bool { - switch (lhs, rhs) { - case (.introspection(let lhsURL), introspection(let rhsURL)): - return lhsURL == rhsURL - case (.registry(let lhsSettings), - .registry(let rhsSettings)): - return lhsSettings == rhsSettings - default: - return false - } - } - - } - - let downloadMethod: DownloadMethod - let headers: [String] - let outputURL: URL - - let downloadTimeout: Double - - /// Designated Initializer - /// - /// - Parameters: - /// - schemaFileName: The name, without an extension, for your schema file. Defaults to `"schema"` - /// - schemaFileType: The `SchemaFileType` to download the schema as. Defaults to `.json`. - /// - downloadMethod: How to download your schema. - /// - headers: [optional] Any additional headers to include when retrieving your schema. Defaults to nil - /// - outputFolderURL: The URL of the folder in which the downloaded schema should be written - /// - downloadTimeout: The maximum time to wait before indicating that the download timed out, in seconds. Defaults to 30 seconds. - public init(schemaFileName: String = "schema", - schemaFileType: SchemaFileType = .json, - downloadMethod: DownloadMethod, - headers: [String] = [], - outputFolderURL: URL, - downloadTimeout: Double = 30.0) { - self.downloadMethod = downloadMethod - self.headers = headers - self.outputURL = outputFolderURL.appendingPathComponent("\(schemaFileName).\(schemaFileType.rawValue)") - - self.downloadTimeout = downloadTimeout - } - - var arguments: [String] { - var arguments = [ - "client:download-schema", - ] - - switch self.downloadMethod { - case .introspection(let endpointURL): - arguments.append("--endpoint=\(endpointURL.absoluteString)") - case .registry(let settings): - arguments.append("--key=\(settings.apiKey)") - arguments.append("--graph=\(settings.graphID)") - if let providedVariant = settings.variant { - arguments.append("--variant=\(providedVariant)") - } - } - - arguments.append("'\(outputURL.path)'") - - // Header argument must be last in the CLI command due to an underlying issue in the Oclif framework. - // See: https://github.com/apollographql/apollo-tooling/issues/844#issuecomment-547143805 - for header in headers { - arguments.append("--header='\(header)'") - } - - return arguments - } -} - -extension ApolloSchemaOptions: CustomDebugStringConvertible { - public var debugDescription: String { - self.arguments.joined(separator: "\n") - } -} diff --git a/Sources/ApolloCodegenLib/CLIDownloader.swift b/Sources/ApolloCodegenLib/CLIDownloader.swift index 2a91970898..22eed1847d 100644 --- a/Sources/ApolloCodegenLib/CLIDownloader.swift +++ b/Sources/ApolloCodegenLib/CLIDownloader.swift @@ -5,30 +5,6 @@ import Foundation /// Helper for downloading the CLI Zip file so we don't have to include it in the repo. struct CLIDownloader { - - enum CLIDownloaderError: Error, LocalizedError { - case badResponse(code: Int, response: String?) - case emptyDataReceived - case noDataReceived - case downloadTimedOut(after: Double) - case responseNotHTTPResponse - - var errorDescription: String? { - switch self { - case .badResponse(let code, let response): - return "Received bad response from server (code \(code)): \(String(describing: response))" - case .emptyDataReceived: - return "Empty data was received from the server." - case .noDataReceived: - return "No data was received from the server." - case .downloadTimedOut(let seconds): - return "Download timed out after \(seconds) seconds." - case .responseNotHTTPResponse: - return "The response was not an HTTP Response, something's gone very wonky." - } - } - } - /// The URL string for getting the current version of the CLI static let downloadURLString = "https://install.apollographql.com/legacy-cli/darwin/2.33.6" @@ -37,8 +13,9 @@ struct CLIDownloader { /// - Parameters: /// - cliFolderURL: The folder URL to download the zip file to. /// - timeout: The maximum time to wait before indicating that the download timed out, in seconds. - static func downloadIfNeeded(cliFolderURL: URL, timeout: Double) throws { + static func downloadIfNeeded(to cliFolderURL: URL, timeout: Double) throws { let zipFileURL = ApolloFilePathHelper.zipFileURL(fromCLIFolder: cliFolderURL) + guard !FileManager.default.apollo.fileExists(at: zipFileURL) else { CodegenLogger.log("Zip file with the CLI is already downloaded!") return @@ -52,7 +29,7 @@ struct CLIDownloader { /// - Parameters: /// - cliFolderURL: The folder where the zip file lives. /// - timeout: The maximum time to wait before indicating that the download timed out, in seconds. - static func forceRedownload(cliFolderURL: URL, timeout: Double) throws { + static func forceRedownload(to cliFolderURL: URL, timeout: Double) throws { let zipFileURL = ApolloFilePathHelper.zipFileURL(fromCLIFolder: cliFolderURL) try FileManager.default.apollo.deleteFile(at: zipFileURL) let apolloFolderURL = ApolloFilePathHelper.apolloFolderURL(fromCLIFolder: cliFolderURL) @@ -68,60 +45,15 @@ struct CLIDownloader { /// - timeout: The maximum time to wait before indicating that the download timed out, in seconds. private static func download(to zipFileURL: URL, timeout: Double) throws { try FileManager.default.apollo.createContainingFolderIfNeeded(for: zipFileURL) - + CodegenLogger.log("Downloading zip file with the CLI...") - let semaphore = DispatchSemaphore(value: 0) - var errorToThrow: Error? = CLIDownloaderError.downloadTimedOut(after: timeout) - URLSession.shared.dataTask(with: URL(string: CLIDownloader.downloadURLString)!) { data, response, error in - func finished(with finalError: Error?) { - errorToThrow = finalError - semaphore.signal() - } - - if let error = error { - finished(with: error) - return - } - - guard let httpResponse = response as? HTTPURLResponse else { - finished(with: CLIDownloaderError.responseNotHTTPResponse) - return - } - - guard httpResponse.statusCode == 200 else { - let dataAsString = String(bytes: data ?? Data(), encoding: .utf8) - finished(with: CLIDownloaderError.badResponse(code: httpResponse.statusCode, response: dataAsString)) - return - } - - guard let data = data else { - finished(with: CLIDownloaderError.noDataReceived) - return - } - - guard !data.isEmpty else { - finished(with: CLIDownloaderError.emptyDataReceived) - return - } - - do { - try data.write(to: zipFileURL) - } catch (let writeError) { - finished(with: writeError) - return - } - - // If we got here, it all worked and it's good to go! - finished(with: nil) - }.resume() - - _ = semaphore.wait(timeout: .now() + timeout) - - if let throwMe = errorToThrow { - throw throwMe - } else { - CodegenLogger.log("CLI zip file successfully downloaded!") - } + + let urlRequest = URLRequest(url: URL(string: CLIDownloader.downloadURLString)!) + try URLDownloader().downloadSynchronously(with: urlRequest, + to: zipFileURL, + timeout: timeout) + + CodegenLogger.log("CLI zip file successfully downloaded!") } } diff --git a/Sources/ApolloCodegenLib/Frontend/ApolloCodegenFrontend.swift b/Sources/ApolloCodegenLib/Frontend/ApolloCodegenFrontend.swift index fda3ba5ff2..2e528e5e2b 100644 --- a/Sources/ApolloCodegenLib/Frontend/ApolloCodegenFrontend.swift +++ b/Sources/ApolloCodegenLib/Frontend/ApolloCodegenFrontend.swift @@ -69,6 +69,11 @@ public final class ApolloCodegenFrontend { return try library.call("loadSchemaFromSDL", with: source) } + /// Take a loaded GQL schema and print it as SDL. + public func printSchemaAsSDL(schema: GraphQLSchema) throws -> String { + return try library.call("printSchemaToSDL", with: schema) + } + private lazy var sourceConstructor: JavaScriptObject = bridge.fromJSValue(library["Source"]) /// Create a `GraphQLSource` object from a string. diff --git a/Sources/ApolloCodegenLib/Frontend/JavaScript/package.json b/Sources/ApolloCodegenLib/Frontend/JavaScript/package.json index 6548914906..7e59af86e9 100644 --- a/Sources/ApolloCodegenLib/Frontend/JavaScript/package.json +++ b/Sources/ApolloCodegenLib/Frontend/JavaScript/package.json @@ -13,7 +13,8 @@ "npm": ">=7" }, "dependencies": { - "graphql": "file:./vendor/graphql-16.0.0-pre+modern-js.tgz" + "graphql": "file:./vendor/graphql-16.0.0-pre+modern-js.tgz", + "tslib": "^2.3.0" }, "devDependencies": { "@rollup/plugin-node-resolve": "^11.0.1", diff --git a/Sources/ApolloCodegenLib/Frontend/JavaScript/src/index.ts b/Sources/ApolloCodegenLib/Frontend/JavaScript/src/index.ts index 1fde2f9a5f..acaaae402d 100644 --- a/Sources/ApolloCodegenLib/Frontend/JavaScript/src/index.ts +++ b/Sources/ApolloCodegenLib/Frontend/JavaScript/src/index.ts @@ -8,6 +8,7 @@ import { GraphQLError, validate, buildASTSchema, + printSchema, } from "graphql"; import { defaultValidationRules } from "./validationRules"; import { compileToIR, CompilationResult } from "./compiler"; @@ -56,6 +57,10 @@ export function loadSchemaFromSDL(source: Source): GraphQLSchema { return schema; } +export function printSchemaToSDL(schema: GraphQLSchema): string { + return printSchema(schema) +} + export function parseDocument(source: Source): DocumentNode { return parse(source); } diff --git a/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js b/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js index f20e244905..0ad3ba6364 100644 --- a/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js +++ b/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js @@ -1,2 +1,2 @@ -var ApolloCodegenFrontend=function(e){"use strict";function t(e){return"object"==typeof e&&null!==e}function n(e,t){const n=/\r\n|[\n\r]/g;let r,i=1,o=t+1;for(;(r=n.exec(e.body))&&r.index120){const e=Math.floor(p/80),t=p%80,n=[];for(let e=0;e["",e])),[" ",s(t-1)+"^"],["",n[e+1]]])}return l+o([[""+(c-1),d[i-1]],[`${c}`,f],["",s(p-1)+"^"],[`${c+1}`,d[i+1]]])}function o(e){const t=e.filter((([e,t])=>void 0!==t)),n=Math.max(...t.map((([e])=>e.length)));return t.map((([e,t])=>{return s(n-(r=e).length)+r+(t?" | "+t:" |");var r})).join("\n")}function s(e){return Array(e+1).join(" ")}class GraphQLError extends Error{constructor(e,r,i,o,s,a,c){super(e);const u=Array.isArray(r)?0!==r.length?r:void 0:r?[r]:void 0;let p=i;!p&&u&&(p=u[0].loc?.source);let l,d=o;!d&&u&&(d=u.reduce(((e,t)=>(t.loc&&e.push(t.loc.start),e)),[])),d&&0===d.length&&(d=void 0),o&&i?l=o.map((e=>n(i,e))):u&&(l=u.reduce(((e,t)=>(t.loc&&e.push(n(t.loc.source,t.loc.start)),e)),[]));let f=c;if(null==f&&null!=a){const e=a.extensions;t(e)&&(f=e)}Object.defineProperties(this,{name:{value:"GraphQLError"},message:{value:e,enumerable:!0,writable:!0},locations:{value:l??void 0,enumerable:null!=l},path:{value:s??void 0,enumerable:null!=s},nodes:{value:u??void 0},source:{value:p??void 0},positions:{value:d??void 0},originalError:{value:a},extensions:{value:f??void 0,enumerable:null!=f}}),a?.stack?Object.defineProperty(this,"stack",{value:a.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,GraphQLError):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}toString(){return function(e){let t=e.message;if(e.nodes)for(const n of e.nodes)n.loc&&(t+="\n\n"+r(n.loc));else if(e.source&&e.locations)for(const n of e.locations)t+="\n\n"+i(e.source,n);return t}(this)}get[Symbol.toStringTag](){return"Object"}}function a(e,t,n){return new GraphQLError(`Syntax Error: ${n}`,void 0,e,[t])}const c=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"});class Location{constructor(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}toJSON(){return{start:this.start,end:this.end}}[Symbol.for("nodejs.util.inspect.custom")](){return this.toJSON()}}class Token{constructor(e,t,n,r,i,o,s){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=s,this.prev=o,this.next=null}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}[Symbol.for("nodejs.util.inspect.custom")](){return this.toJSON()}}function u(e){return null!=e&&"string"==typeof e.kind}const p=Object.freeze({SOF:"",EOF:"",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function l(e){return d(e,[])}function d(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return null===e?"null":function(e,t){if(-1!==t.indexOf(e))return"[Circular]";const n=[...t,e];if("function"==typeof e.toJSON){const t=e.toJSON(e);if(t!==e)return"string"==typeof t?t:d(t,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>2)return"[Array]";const n=Math.min(10,e.length),r=e.length-n,i=[];for(let r=0;r1&&i.push(`... ${r} more items`);return"["+i.join(", ")+"]"}(e,n);return function(e,t){const n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";return"{ "+n.map((n=>n+": "+d(e[n],t))).join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}function f(e,t){if(!Boolean(e))throw new Error(t)}var h=function(e,t){return e instanceof t};class Source{constructor(e,t="GraphQL request",n={line:1,column:1}){"string"==typeof e||f(0,`Body must be a string. Received: ${l(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||f(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||f(0,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}const m=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function y(e){const t=e.split(/\r\n|[\n\r]/g),n=function(e){let t=!0,n=!0,r=0,i=null;for(let o=0;or&&E(t[i-1]);)--i;return t.slice(r,i).join("\n")}function E(e){for(let t=0;t31||9===s));return new Token(p.COMMENT,t,a,n,r,i,o.slice(t+1,a))}function g(e,t,n,r,i,o){const s=e.body;let c=n,u=t,l=!1;if(45===c&&(c=s.charCodeAt(++u)),48===c){if(c=s.charCodeAt(++u),c>=48&&c<=57)throw a(e,u,`Invalid number, unexpected digit after 0: ${T(c)}.`)}else u=_(e,u,c),c=s.charCodeAt(u);if(46===c&&(l=!0,c=s.charCodeAt(++u),u=_(e,u,c),c=s.charCodeAt(u)),69!==c&&101!==c||(l=!0,c=s.charCodeAt(++u),43!==c&&45!==c||(c=s.charCodeAt(++u)),u=_(e,u,c),c=s.charCodeAt(u)),46===c||function(e){return 95===e||e>=65&&e<=90||e>=97&&e<=122}(c))throw a(e,u,`Invalid number, expected digit but got: ${T(c)}.`);return new Token(l?p.FLOAT:p.INT,t,u,r,i,o,s.slice(t,u))}function _(e,t,n){const r=e.body;let i=t,o=n;if(o>=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw a(e,i,`Invalid number, expected digit but got: ${T(o)}.`)}function O(e,t,n,r,i){const o=e.body;let s=t+1,c=s,u=0,l="";for(;s=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function S(e,t,n,r,i){const o=e.body,s=o.length;let a=t+1,c=0;for(;a!==s&&!isNaN(c=o.charCodeAt(a))&&(95===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122);)++a;return new Token(p.NAME,t,a,n,r,i,o.slice(t,a))}function A(e,t){return new Parser(e,t).parseDocument()}class Parser{constructor(e,t){const n=function(e){return h(e,Source)}(e)?e:new Source(e);this._lexer=new Lexer(n),this._options=t}parseName(){const e=this.expectToken(p.NAME);return{kind:c.NAME,value:e.value,loc:this.loc(e)}}parseDocument(){const e=this._lexer.token;return{kind:c.DOCUMENT,definitions:this.many(p.SOF,this.parseDefinition,p.EOF),loc:this.loc(e)}}parseDefinition(){if(this.peek(p.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(p.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(p.BRACE_L))return{kind:c.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};const t=this.parseOperationType();let n;return this.peek(p.NAME)&&(n=this.parseName()),{kind:c.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}}parseOperationType(){const e=this.expectToken(p.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(p.PAREN_L,this.parseVariableDefinition,p.PAREN_R)}parseVariableDefinition(){const e=this._lexer.token;return{kind:c.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(p.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(p.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}}parseVariable(){const e=this._lexer.token;return this.expectToken(p.DOLLAR),{kind:c.VARIABLE,name:this.parseName(),loc:this.loc(e)}}parseSelectionSet(){const e=this._lexer.token;return{kind:c.SELECTION_SET,selections:this.many(p.BRACE_L,this.parseSelection,p.BRACE_R),loc:this.loc(e)}}parseSelection(){return this.peek(p.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(p.COLON)?(n=t,r=this.parseName()):r=t,{kind:c.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(p.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(e)}}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(p.PAREN_L,t,p.PAREN_R)}parseArgument(){const e=this._lexer.token,t=this.parseName();return this.expectToken(p.COLON),{kind:c.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}}parseConstArgument(){const e=this._lexer.token;return{kind:c.ARGUMENT,name:this.parseName(),value:(this.expectToken(p.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}}parseFragment(){const e=this._lexer.token;this.expectToken(p.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(p.NAME)?{kind:c.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:c.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}}parseFragmentDefinition(){const e=this._lexer.token;return this.expectKeyword("fragment"),!0===this._options?.experimentalFragmentVariables?{kind:c.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:c.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}}parseFragmentName(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()}parseValueLiteral(e){const t=this._lexer.token;switch(t.kind){case p.BRACKET_L:return this.parseList(e);case p.BRACE_L:return this.parseObject(e);case p.INT:return this._lexer.advance(),{kind:c.INT,value:t.value,loc:this.loc(t)};case p.FLOAT:return this._lexer.advance(),{kind:c.FLOAT,value:t.value,loc:this.loc(t)};case p.STRING:case p.BLOCK_STRING:return this.parseStringLiteral();case p.NAME:switch(this._lexer.advance(),t.value){case"true":return{kind:c.BOOLEAN,value:!0,loc:this.loc(t)};case"false":return{kind:c.BOOLEAN,value:!1,loc:this.loc(t)};case"null":return{kind:c.NULL,loc:this.loc(t)};default:return{kind:c.ENUM,value:t.value,loc:this.loc(t)}}case p.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()}parseStringLiteral(){const e=this._lexer.token;return this._lexer.advance(),{kind:c.STRING,value:e.value,block:e.kind===p.BLOCK_STRING,loc:this.loc(e)}}parseList(e){const t=this._lexer.token;return{kind:c.LIST,values:this.any(p.BRACKET_L,(()=>this.parseValueLiteral(e)),p.BRACKET_R),loc:this.loc(t)}}parseObject(e){const t=this._lexer.token;return{kind:c.OBJECT,fields:this.any(p.BRACE_L,(()=>this.parseObjectField(e)),p.BRACE_R),loc:this.loc(t)}}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(p.COLON),{kind:c.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}}parseDirectives(e){const t=[];for(;this.peek(p.AT);)t.push(this.parseDirective(e));return t}parseDirective(e){const t=this._lexer.token;return this.expectToken(p.AT),{kind:c.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}}parseTypeReference(){const e=this._lexer.token;let t;return this.expectOptionalToken(p.BRACKET_L)?(t=this.parseTypeReference(),this.expectToken(p.BRACKET_R),t={kind:c.LIST_TYPE,type:t,loc:this.loc(e)}):t=this.parseNamedType(),this.expectOptionalToken(p.BANG)?{kind:c.NON_NULL_TYPE,type:t,loc:this.loc(e)}:t}parseNamedType(){const e=this._lexer.token;return{kind:c.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}}parseTypeSystemDefinition(){const e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===p.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)}peekDescription(){return this.peek(p.STRING)||this.peek(p.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");const n=this.parseDirectives(!0),r=this.many(p.BRACE_L,this.parseOperationTypeDefinition,p.BRACE_R);return{kind:c.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r,loc:this.loc(e)}}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(p.COLON);const n=this.parseNamedType();return{kind:c.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}}parseScalarTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");const n=this.parseName(),r=this.parseDirectives(!0);return{kind:c.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}}parseObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:c.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(p.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(p.BRACE_L,this.parseFieldDefinition,p.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(p.COLON);const i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:c.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}}parseArgumentDefs(){return this.optionalMany(p.PAREN_L,this.parseInputValueDef,p.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(p.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(p.EQUALS)&&(i=this.parseValueLiteral(!0));const o=this.parseDirectives(!0);return{kind:c.INPUT_VALUE_DEFINITION,description:t,name:n,type:r,defaultValue:i,directives:o,loc:this.loc(e)}}parseInterfaceTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:c.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}}parseUnionTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");const n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:c.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}}parseUnionMemberTypes(){return this.expectOptionalToken(p.EQUALS)?this.delimitedMany(p.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");const n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:c.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}}parseEnumValuesDefinition(){return this.optionalMany(p.BRACE_L,this.parseEnumValueDefinition,p.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:c.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}}parseInputObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");const n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:c.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}}parseInputFieldsDefinition(){return this.optionalMany(p.BRACE_L,this.parseInputValueDef,p.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===p.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)}parseSchemaExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const t=this.parseDirectives(!0),n=this.optionalMany(p.BRACE_L,this.parseOperationTypeDefinition,p.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:c.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:c.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:c.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:c.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:c.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:c.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:c.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(p.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const o=this.parseDirectiveLocations();return{kind:c.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}}parseDirectiveLocations(){return this.delimitedMany(p.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(void 0!==m[t.value])return t;throw this.unexpected(e)}loc(e){if(!0!==this._options?.noLocation)return new Location(e,this._lexer.lastToken,this._lexer.source)}peek(e){return this._lexer.token.kind===e}expectToken(e){const t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw a(this._lexer.source,t.start,`Expected ${w(e)}, found ${D(t)}.`)}expectOptionalToken(e){const t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t}expectKeyword(e){const t=this._lexer.token;if(t.kind!==p.NAME||t.value!==e)throw a(this._lexer.source,t.start,`Expected "${e}", found ${D(t)}.`);this._lexer.advance()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===p.NAME&&t.value===e&&(this._lexer.advance(),!0)}unexpected(e){const t=e??this._lexer.token;return a(this._lexer.source,t.start,`Unexpected ${D(t)}.`)}any(e,t,n){this.expectToken(e);const r=[];for(;!this.expectOptionalToken(n);)r.push(t.call(this));return r}optionalMany(e,t,n){if(this.expectOptionalToken(e)){const e=[];do{e.push(t.call(this))}while(!this.expectOptionalToken(n));return e}return[]}many(e,t,n){this.expectToken(e);const r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}delimitedMany(e,t){this.expectOptionalToken(e);const n=[];do{n.push(t.call(this))}while(this.expectOptionalToken(e));return n}}function D(e){const t=e.value;return w(e.kind)+(null!=t?` "${t}"`:"")}function w(e){return function(e){return e===p.BANG||e===p.DOLLAR||e===p.AMP||e===p.PAREN_L||e===p.PAREN_R||e===p.SPREAD||e===p.COLON||e===p.EQUALS||e===p.AT||e===p.BRACKET_L||e===p.BRACKET_R||e===p.BRACE_L||e===p.PIPE||e===p.BRACE_R}(e)?`"${e}"`:e}const k={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},x=Object.freeze({});function F(e,t,n=k){let r,i,o,s,a=Array.isArray(e),c=[e],p=-1,d=[];const f=[],h=[];let m=e;do{p++;const e=p===c.length,y=e&&0!==d.length;if(e){if(o=0===h.length?void 0:f[f.length-1],i=s,s=h.pop(),y){if(a)i=i.slice();else{const e={};for(const t of Object.keys(i))e[t]=i[t];i=e}let e=0;for(let t=0;tObject.keys(e).map((t=>e[t])));const $=/^[_a-zA-Z][_a-zA-Z0-9]*$/;const Q=Object.entries||(e=>Object.keys(e).map((t=>[t,e[t]])));function V(e,t){return e.reduce(((e,n)=>(e[t(n)]=n,e)),Object.create(null))}function U(e,t){const n=Object.create(null);for(const[r,i]of Q(e))n[r]=t(i,r);return n}function j(e){if(null===Object.getPrototypeOf(e))return e;const t=Object.create(null);for(const[n,r]of Q(e))t[n]=r;return t}function M(e,t,n){return e.reduce(((e,r)=>(e[t(r)]=n(r),e)),Object.create(null))}function P(e,t){const[n,r]="string"==typeof e?[e,t]:[void 0,e];let i=" Did you mean ";n&&(i+=n+" ");const o=r.map((e=>`"${e}"`));switch(o.length){case 0:return"";case 1:return i+o[0]+"?";case 2:return i+o[0]+" or "+o[1]+"?"}const s=o.slice(0,5),a=s.pop();return i+s.join(", ")+", or "+a+"?"}function B(e){return e}function Y(e,t){const n=Object.create(null),r=new LexicalDistance(e),i=Math.floor(.4*e.length)+1;for(const e of t){const t=r.measure(e,i);void 0!==t&&(n[e]=t)}return Object.keys(n).sort(((e,t)=>{const r=n[e]-n[t];return 0!==r?r:e.localeCompare(t)}))}class LexicalDistance{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=J(this._inputLowerCase),this._rows=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)]}measure(e,t){if(this._input===e)return 0;const n=e.toLowerCase();if(this._inputLowerCase===n)return 1;let r=J(n),i=this._inputArray;if(r.lengtht)return;const a=this._rows;for(let e=0;e<=s;e++)a[0][e]=e;for(let e=1;e<=o;e++){const n=a[(e-1)%3],o=a[e%3];let c=o[0]=e;for(let t=1;t<=s;t++){const s=r[e-1]===i[t-1]?0:1;let u=Math.min(n[t]+1,o[t-1]+1,n[t-1]+s);if(e>1&&t>1&&r[e-1]===i[t-2]&&r[e-2]===i[t-1]){const n=a[(e-2)%3][t-2];u=Math.min(u,n+1)}ut)return}const c=a[o%3][s];return c<=t?c:void 0}}function J(e){const t=e.length,n=new Array(t);for(let r=0;re.value,Variable:e=>"$"+e.name,Document:e=>z(e.definitions,"\n\n")+"\n",OperationDefinition(e){const t=e.operation,n=e.name,r=Z("(",z(e.variableDefinitions,", "),")"),i=z(e.directives," "),o=e.selectionSet;return n||i||r||"query"!==t?z([t,z([n,r]),i,o]," "):o},VariableDefinition:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+Z(" = ",n)+Z(" ",z(r," ")),SelectionSet:({selections:e})=>H(e),Field:({alias:e,name:t,arguments:n,directives:r,selectionSet:i})=>{const o=Z("",e,": ")+t;let s=o+Z("(",z(n,", "),")");return s.length>80&&(s=o+Z("(\n",W(z(n,"\n")),"\n)")),z([s,z(r," "),i]," ")},Argument:({name:e,value:t})=>e+": "+t,FragmentSpread:({name:e,directives:t})=>"..."+e+Z(" ",z(t," ")),InlineFragment:({typeCondition:e,directives:t,selectionSet:n})=>z(["...",Z("on ",e),z(t," "),n]," "),FragmentDefinition:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${Z("(",z(n,", "),")")} on ${t} ${Z("",z(r," ")," ")}`+i,IntValue:({value:e})=>e,FloatValue:({value:e})=>e,StringValue:({value:e,block:t},n)=>t?function(e,t="",n=!1){const r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],s="\\"===e[e.length-1],a=!r||o||s||n;let c="";return!a||r&&i||(c+="\n"+t),c+=t?e.replace(/\n/g,"\n"+t):e,a&&(c+="\n"),'"""'+c.replace(/"""/g,'\\"""')+'"""'}(e,"description"===n?"":" "):JSON.stringify(e),BooleanValue:({value:e})=>e?"true":"false",NullValue:()=>"null",EnumValue:({value:e})=>e,ListValue:({values:e})=>"["+z(e,", ")+"]",ObjectValue:({fields:e})=>"{"+z(e,", ")+"}",ObjectField:({name:e,value:t})=>e+": "+t,Directive:({name:e,arguments:t})=>"@"+e+Z("(",z(t,", "),")"),NamedType:({name:e})=>e,ListType:({type:e})=>"["+e+"]",NonNullType:({type:e})=>e+"!",SchemaDefinition:X((({directives:e,operationTypes:t})=>z(["schema",z(e," "),H(t)]," "))),OperationTypeDefinition:({operation:e,type:t})=>e+": "+t,ScalarTypeDefinition:X((({name:e,directives:t})=>z(["scalar",e,z(t," ")]," "))),ObjectTypeDefinition:X((({name:e,interfaces:t,directives:n,fields:r})=>z(["type",e,Z("implements ",z(t," & ")),z(n," "),H(r)]," "))),FieldDefinition:X((({name:e,arguments:t,type:n,directives:r})=>e+(te(t)?Z("(\n",W(z(t,"\n")),"\n)"):Z("(",z(t,", "),")"))+": "+n+Z(" ",z(r," ")))),InputValueDefinition:X((({name:e,type:t,defaultValue:n,directives:r})=>z([e+": "+t,Z("= ",n),z(r," ")]," "))),InterfaceTypeDefinition:X((({name:e,interfaces:t,directives:n,fields:r})=>z(["interface",e,Z("implements ",z(t," & ")),z(n," "),H(r)]," "))),UnionTypeDefinition:X((({name:e,directives:t,types:n})=>z(["union",e,z(t," "),n&&0!==n.length?"= "+z(n," | "):""]," "))),EnumTypeDefinition:X((({name:e,directives:t,values:n})=>z(["enum",e,z(t," "),H(n)]," "))),EnumValueDefinition:X((({name:e,directives:t})=>z([e,z(t," ")]," "))),InputObjectTypeDefinition:X((({name:e,directives:t,fields:n})=>z(["input",e,z(t," "),H(n)]," "))),DirectiveDefinition:X((({name:e,arguments:t,repeatable:n,locations:r})=>"directive @"+e+(te(t)?Z("(\n",W(z(t,"\n")),"\n)"):Z("(",z(t,", "),")"))+(n?" repeatable":"")+" on "+z(r," | "))),SchemaExtension:({directives:e,operationTypes:t})=>z(["extend schema",z(e," "),H(t)]," "),ScalarTypeExtension:({name:e,directives:t})=>z(["extend scalar",e,z(t," ")]," "),ObjectTypeExtension:({name:e,interfaces:t,directives:n,fields:r})=>z(["extend type",e,Z("implements ",z(t," & ")),z(n," "),H(r)]," "),InterfaceTypeExtension:({name:e,interfaces:t,directives:n,fields:r})=>z(["extend interface",e,Z("implements ",z(t," & ")),z(n," "),H(r)]," "),UnionTypeExtension:({name:e,directives:t,types:n})=>z(["extend union",e,z(t," "),n&&0!==n.length?"= "+z(n," | "):""]," "),EnumTypeExtension:({name:e,directives:t,values:n})=>z(["extend enum",e,z(t," "),H(n)]," "),InputObjectTypeExtension:({name:e,directives:t,fields:n})=>z(["extend input",e,z(t," "),H(n)]," ")};function X(e){return t=>z([t.description,e(t)],"\n")}function z(e,t=""){return e?.filter((e=>e)).join(t)??""}function H(e){return Z("{\n",W(z(e,"\n")),"\n}")}function Z(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function W(e){return Z(" ",e.replace(/\n/g,"\n "))}function ee(e){return-1!==e.indexOf("\n")}function te(e){return null!=e&&e.some(ee)}function ne(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}function re(e,t){switch(e.kind){case c.NULL:return null;case c.INT:return parseInt(e.value,10);case c.FLOAT:return parseFloat(e.value);case c.STRING:case c.ENUM:case c.BOOLEAN:return e.value;case c.LIST:return e.values.map((e=>re(e,t)));case c.OBJECT:return M(e.fields,(e=>e.name.value),(e=>re(e.value,t)));case c.VARIABLE:return t?.[e.name.value]}ne(0,"Unexpected value node: "+l(e))}function ie(e){return oe(e)||se(e)||ae(e)||ce(e)||ue(e)||pe(e)||le(e)||de(e)}function oe(e){return h(e,GraphQLScalarType)}function se(e){return h(e,GraphQLObjectType)}function ae(e){return h(e,GraphQLInterfaceType)}function ce(e){return h(e,GraphQLUnionType)}function ue(e){return h(e,GraphQLEnumType)}function pe(e){return h(e,GraphQLInputObjectType)}function le(e){return h(e,GraphQLList)}function de(e){return h(e,GraphQLNonNull)}function fe(e){return oe(e)||ue(e)||pe(e)||Te(e)&&fe(e.ofType)}function he(e){return oe(e)||se(e)||ae(e)||ce(e)||ue(e)||Te(e)&&he(e.ofType)}function me(e){return oe(e)||ue(e)}function ye(e){return se(e)||ae(e)||ce(e)}function Ee(e){return ae(e)||ce(e)}class GraphQLList{constructor(e){ie(e)||f(0,`Expected ${l(e)} to be a GraphQL type.`),this.ofType=e}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLList"}}class GraphQLNonNull{constructor(e){Ne(e)||f(0,`Expected ${l(e)} to be a GraphQL nullable type.`),this.ofType=e}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLNonNull"}}function Te(e){return le(e)||de(e)}function Ne(e){return ie(e)&&!de(e)}function ve(e){if(e)return de(e)?e.ofType:e}function Ie(e){return oe(e)||se(e)||ae(e)||ce(e)||ue(e)||pe(e)}function ge(e){if(e){let t=e;for(;Te(t);)t=t.ofType;return t}}function _e(e){return"function"==typeof e?e():e}function Oe(e){return e&&e.length>0?e:void 0}class GraphQLScalarType{constructor(e){const t=e.parseValue??B;this.name=e.name,this.description=e.description,this.specifiedByUrl=e.specifiedByUrl,this.serialize=e.serialize??B,this.parseValue=t,this.parseLiteral=e.parseLiteral??((e,n)=>t(re(e,n))),this.extensions=e.extensions&&j(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=Oe(e.extensionASTNodes),"string"==typeof e.name||f(0,"Must provide name."),null==e.specifiedByUrl||"string"==typeof e.specifiedByUrl||f(0,`${this.name} must provide "specifiedByUrl" as a string, but got: ${l(e.specifiedByUrl)}.`),null==e.serialize||"function"==typeof e.serialize||f(0,`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`),e.parseLiteral&&("function"==typeof e.parseValue&&"function"==typeof e.parseLiteral||f(0,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`))}toConfig(){return{name:this.name,description:this.description,specifiedByUrl:this.specifiedByUrl,serialize:this.serialize,parseValue:this.parseValue,parseLiteral:this.parseLiteral,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLScalarType"}}class GraphQLObjectType{constructor(e){this.name=e.name,this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=e.extensions&&j(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=Oe(e.extensionASTNodes),this._fields=Le.bind(void 0,e),this._interfaces=be.bind(void 0,e),"string"==typeof e.name||f(0,"Must provide name."),null==e.isTypeOf||"function"==typeof e.isTypeOf||f(0,`${this.name} must provide "isTypeOf" as a function, but got: ${l(e.isTypeOf)}.`)}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:Ae(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes||[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLObjectType"}}function be(e){const t=_e(e.interfaces)??[];return Array.isArray(t)||f(0,`${e.name} interfaces must be an Array or a function which returns an Array.`),t}function Le(e){const t=_e(e.fields);return Se(t)||f(0,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),U(t,((t,n)=>{Se(t)||f(0,`${e.name}.${n} field config must be an object.`),null==t.resolve||"function"==typeof t.resolve||f(0,`${e.name}.${n} field resolver must be a function if provided, but got: ${l(t.resolve)}.`);const r=t.args??{};Se(r)||f(0,`${e.name}.${n} args must be an object with argument names as keys.`);const i=Q(r).map((([e,t])=>({name:e,description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:t.extensions&&j(t.extensions),astNode:t.astNode})));return{name:n,description:t.description,type:t.type,args:i,resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:t.extensions&&j(t.extensions),astNode:t.astNode}}))}function Se(e){return t(e)&&!Array.isArray(e)}function Ae(e){return U(e,(e=>({description:e.description,type:e.type,args:De(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function De(e){return M(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function we(e){return de(e.type)&&void 0===e.defaultValue}class GraphQLInterfaceType{constructor(e){this.name=e.name,this.description=e.description,this.resolveType=e.resolveType,this.extensions=e.extensions&&j(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=Oe(e.extensionASTNodes),this._fields=Le.bind(void 0,e),this._interfaces=be.bind(void 0,e),"string"==typeof e.name||f(0,"Must provide name."),null==e.resolveType||"function"==typeof e.resolveType||f(0,`${this.name} must provide "resolveType" as a function, but got: ${l(e.resolveType)}.`)}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:Ae(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}}class GraphQLUnionType{constructor(e){this.name=e.name,this.description=e.description,this.resolveType=e.resolveType,this.extensions=e.extensions&&j(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=Oe(e.extensionASTNodes),this._types=ke.bind(void 0,e),"string"==typeof e.name||f(0,"Must provide name."),null==e.resolveType||"function"==typeof e.resolveType||f(0,`${this.name} must provide "resolveType" as a function, but got: ${l(e.resolveType)}.`)}getTypes(){return"function"==typeof this._types&&(this._types=this._types()),this._types}toConfig(){return{name:this.name,description:this.description,types:this.getTypes(),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLUnionType"}}function ke(e){const t=_e(e.types);return Array.isArray(t)||f(0,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class GraphQLEnumType{constructor(e){var t,n;this.name=e.name,this.description=e.description,this.extensions=e.extensions&&j(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=Oe(e.extensionASTNodes),this._values=(t=this.name,Se(n=e.values)||f(0,`${t} values must be an object with value names as keys.`),Q(n).map((([e,n])=>(Se(n)||f(0,`${t}.${e} must refer to an object with a "value" key representing an internal value but got: ${l(n)}.`),{name:e,description:n.description,value:void 0!==n.value?n.value:e,deprecationReason:n.deprecationReason,extensions:n.extensions&&j(n.extensions),astNode:n.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=V(this._values,(e=>e.name)),"string"==typeof e.name||f(0,"Must provide name.")}getValues(){return this._values}getValue(e){return this._nameLookup[e]}serialize(e){const t=this._valueLookup.get(e);if(void 0===t)throw new GraphQLError(`Enum "${this.name}" cannot represent value: ${l(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=l(e);throw new GraphQLError(`Enum "${this.name}" cannot represent non-string value: ${t}.`+xe(this,t))}const t=this.getValue(e);if(null==t)throw new GraphQLError(`Value "${e}" does not exist in "${this.name}" enum.`+xe(this,e));return t.value}parseLiteral(e,t){if(e.kind!==c.ENUM){const t=q(e);throw new GraphQLError(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+xe(this,t),e)}const n=this.getValue(e.value);if(null==n){const t=q(e);throw new GraphQLError(`Value "${t}" does not exist in "${this.name}" enum.`+xe(this,t),e)}return n.value}toConfig(){const e=M(this.getValues(),(e=>e.name),(e=>({description:e.description,value:e.value,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,values:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLEnumType"}}function xe(e,t){return P("the enum value",Y(t,e.getValues().map((e=>e.name))))}class GraphQLInputObjectType{constructor(e){this.name=e.name,this.description=e.description,this.extensions=e.extensions&&j(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=Oe(e.extensionASTNodes),this._fields=Fe.bind(void 0,e),"string"==typeof e.name||f(0,"Must provide name.")}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=U(this.getFields(),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,fields:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}}function Fe(e){const t=_e(e.fields);return Se(t)||f(0,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),U(t,((t,n)=>(!("resolve"in t)||f(0,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:n,description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:t.extensions&&j(t.extensions),astNode:t.astNode})))}function Re(e){return de(e.type)&&void 0===e.defaultValue}function Ge(e,t){return e===t||(de(e)&&de(t)||!(!le(e)||!le(t)))&&Ge(e.ofType,t.ofType)}function Ce(e,t,n){return t===n||(de(n)?!!de(t)&&Ce(e,t.ofType,n.ofType):de(t)?Ce(e,t.ofType,n):le(n)?!!le(t)&&Ce(e,t.ofType,n.ofType):!le(t)&&(Ee(n)&&(ae(t)||se(t))&&e.isSubType(n,t)))}function $e(e,t,n){return t===n||(Ee(t)?Ee(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!Ee(n)&&e.isSubType(n,t))}const Qe=2147483647,Ve=-2147483648;const Ue=new GraphQLScalarType({name:"Int",description:"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",serialize:function(e){const t=Me(e);if("boolean"==typeof t)return t?1:0;let n=t;if("string"==typeof t&&""!==t&&(n=Number(t)),"number"!=typeof n||!Number.isInteger(n))throw new GraphQLError(`Int cannot represent non-integer value: ${l(t)}`);if(n>Qe||nQe||eQe||t=0&&t%1==0||"function"==typeof e[Symbol.iterator]}(e)){const n=[];for(const r of Array.from(e)){const e=qe(r,t);null!=e&&n.push(e)}return{kind:c.LIST,values:n}}return qe(e,t)}if(pe(n)){if(!t(e))return null;const r=[];for(const t of C(n.getFields())){const n=qe(e[t.name],t.type);n&&r.push({kind:c.OBJECT_FIELD,name:{kind:c.NAME,value:t.name},value:n})}return{kind:c.OBJECT,fields:r}}if(me(n)){const t=n.serialize(e);if(null==t)return null;if("boolean"==typeof t)return{kind:c.BOOLEAN,value:t};if("number"==typeof t&&Number.isFinite(t)){const e=String(t);return Ke.test(e)?{kind:c.INT,value:e}:{kind:c.FLOAT,value:e}}if("string"==typeof t)return ue(n)?{kind:c.ENUM,value:t}:n===Ye&&Ke.test(t)?{kind:c.INT,value:t}:{kind:c.STRING,value:t};throw new TypeError(`Cannot convert value to AST: ${l(t)}.`)}ne(0,"Unexpected input type: "+l(n))}const Ke=/^-?(?:0|[1-9][0-9]*)$/,Xe=new GraphQLObjectType({name:"__Schema",description:"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",fields:()=>({description:{type:Pe,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(Ze))),resolve:e=>C(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new GraphQLNonNull(Ze),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:Ze,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:Ze,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(ze))),resolve:e=>e.getDirectives()}})}),ze=new GraphQLObjectType({name:"__Directive",description:"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.",fields:()=>({name:{type:new GraphQLNonNull(Pe),resolve:e=>e.name},description:{type:Pe,resolve:e=>e.description},isRepeatable:{type:new GraphQLNonNull(Be),resolve:e=>e.isRepeatable},locations:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(He))),resolve:e=>e.locations},args:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(et))),resolve:e=>e.args}})}),He=new GraphQLEnumType({name:"__DirectiveLocation",description:"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",values:{QUERY:{value:m.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:m.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:m.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:m.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:m.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:m.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:m.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:m.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:m.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:m.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:m.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:m.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:m.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:m.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:m.UNION,description:"Location adjacent to a union definition."},ENUM:{value:m.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:m.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:m.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:m.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),Ze=new GraphQLObjectType({name:"__Type",description:"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByUrl`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",fields:()=>({kind:{type:new GraphQLNonNull(rt),resolve:e=>oe(e)?nt.SCALAR:se(e)?nt.OBJECT:ae(e)?nt.INTERFACE:ce(e)?nt.UNION:ue(e)?nt.ENUM:pe(e)?nt.INPUT_OBJECT:le(e)?nt.LIST:de(e)?nt.NON_NULL:void ne(0,`Unexpected type: "${l(e)}".`)},name:{type:Pe,resolve:e=>void 0!==e.name?e.name:void 0},description:{type:Pe,resolve:e=>void 0!==e.description?e.description:void 0},specifiedByUrl:{type:Pe,resolve:e=>void 0!==e.specifiedByUrl?e.specifiedByUrl:void 0},fields:{type:new GraphQLList(new GraphQLNonNull(We)),args:{includeDeprecated:{type:Be,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(se(e)||ae(e)){const n=C(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new GraphQLList(new GraphQLNonNull(Ze)),resolve(e){if(se(e)||ae(e))return e.getInterfaces()}},possibleTypes:{type:new GraphQLList(new GraphQLNonNull(Ze)),resolve(e,t,n,{schema:r}){if(Ee(e))return r.getPossibleTypes(e)}},enumValues:{type:new GraphQLList(new GraphQLNonNull(tt)),args:{includeDeprecated:{type:Be,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(ue(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new GraphQLList(new GraphQLNonNull(et)),args:{includeDeprecated:{type:Be,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(pe(e)){const n=C(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:Ze,resolve:e=>void 0!==e.ofType?e.ofType:void 0}})}),We=new GraphQLObjectType({name:"__Field",description:"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",fields:()=>({name:{type:new GraphQLNonNull(Pe),resolve:e=>e.name},description:{type:Pe,resolve:e=>e.description},args:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(et))),args:{includeDeprecated:{type:Be,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new GraphQLNonNull(Ze),resolve:e=>e.type},isDeprecated:{type:new GraphQLNonNull(Be),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Pe,resolve:e=>e.deprecationReason}})}),et=new GraphQLObjectType({name:"__InputValue",description:"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",fields:()=>({name:{type:new GraphQLNonNull(Pe),resolve:e=>e.name},description:{type:Pe,resolve:e=>e.description},type:{type:new GraphQLNonNull(Ze),resolve:e=>e.type},defaultValue:{type:Pe,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=qe(n,t);return r?q(r):null}},isDeprecated:{type:new GraphQLNonNull(Be),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Pe,resolve:e=>e.deprecationReason}})}),tt=new GraphQLObjectType({name:"__EnumValue",description:"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",fields:()=>({name:{type:new GraphQLNonNull(Pe),resolve:e=>e.name},description:{type:Pe,resolve:e=>e.description},isDeprecated:{type:new GraphQLNonNull(Be),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Pe,resolve:e=>e.deprecationReason}})}),nt=Object.freeze({SCALAR:"SCALAR",OBJECT:"OBJECT",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",INPUT_OBJECT:"INPUT_OBJECT",LIST:"LIST",NON_NULL:"NON_NULL"}),rt=new GraphQLEnumType({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:nt.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:nt.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:nt.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:nt.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:nt.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:nt.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:nt.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:nt.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),it={name:"__schema",type:new GraphQLNonNull(Xe),description:"Access the current type schema of this server.",args:[],resolve:(e,t,n,{schema:r})=>r,deprecationReason:void 0,extensions:void 0,astNode:void 0},ot={name:"__type",type:Ze,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new GraphQLNonNull(Pe),defaultValue:void 0,deprecationReason:void 0,extensions:void 0,astNode:void 0}],resolve:(e,{name:t},n,{schema:r})=>r.getType(t),deprecationReason:void 0,extensions:void 0,astNode:void 0},st={name:"__typename",type:new GraphQLNonNull(Pe),description:"The name of the current Object type at runtime.",args:[],resolve:(e,t,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:void 0,astNode:void 0},at=Object.freeze([Xe,ze,He,Ze,We,et,tt,rt]);function ct(e){return at.some((({name:t})=>e.name===t))}function ut(e){return h(e,GraphQLDirective)}class GraphQLDirective{constructor(e){this.name=e.name,this.description=e.description,this.locations=e.locations,this.isRepeatable=e.isRepeatable??!1,this.extensions=e.extensions&&j(e.extensions),this.astNode=e.astNode,e.name||f(0,"Directive must be named."),Array.isArray(e.locations)||f(0,`@${e.name} locations must be an Array.`);const n=e.args??{};t(n)&&!Array.isArray(n)||f(0,`@${e.name} args must be an object with argument names as keys.`),this.args=Q(n).map((([e,t])=>({name:e,description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:t.extensions&&j(t.extensions),astNode:t.astNode})))}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:De(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLDirective"}}const pt=new GraphQLDirective({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[m.FIELD,m.FRAGMENT_SPREAD,m.INLINE_FRAGMENT],args:{if:{type:new GraphQLNonNull(Be),description:"Included when true."}}}),lt=new GraphQLDirective({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[m.FIELD,m.FRAGMENT_SPREAD,m.INLINE_FRAGMENT],args:{if:{type:new GraphQLNonNull(Be),description:"Skipped when true."}}}),dt=new GraphQLDirective({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[m.FIELD_DEFINITION,m.ARGUMENT_DEFINITION,m.INPUT_FIELD_DEFINITION,m.ENUM_VALUE],args:{reason:{type:Pe,description:"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",defaultValue:"No longer supported"}}}),ft=new GraphQLDirective({name:"specifiedBy",description:"Exposes a URL that specifies the behaviour of this scalar.",locations:[m.SCALAR],args:{url:{type:new GraphQLNonNull(Pe),description:"The URL that specifies the behaviour of this scalar."}}}),ht=Object.freeze([pt,lt,dt,ft]);function mt(e){if(!function(e){return h(e,GraphQLSchema)}(e))throw new Error(`Expected ${l(e)} to be a GraphQL schema.`);return e}class GraphQLSchema{constructor(e){this.__validationErrors=!0===e.assumeValid?[]:void 0,t(e)||f(0,"Must provide configuration object."),!e.types||Array.isArray(e.types)||f(0,`"types" must be Array if provided but got: ${l(e.types)}.`),!e.directives||Array.isArray(e.directives)||f(0,`"directives" must be Array if provided but got: ${l(e.directives)}.`),this.description=e.description,this.extensions=e.extensions&&j(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=e.extensionASTNodes,this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=e.directives??ht;const n=new Set(e.types);if(null!=e.types)for(const t of e.types)n.delete(t),yt(t,n);null!=this._queryType&&yt(this._queryType,n),null!=this._mutationType&&yt(this._mutationType,n),null!=this._subscriptionType&&yt(this._subscriptionType,n);for(const e of this._directives)if(ut(e))for(const t of e.args)yt(t.type,n);yt(Xe,n),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const e of Array.from(n)){if(null==e)continue;const t=e.name;if(t||f(0,"One of the provided types for building the Schema is missing a name."),void 0!==this._typeMap[t])throw new Error(`Schema must contain uniquely named types but contains multiple types named "${t}".`);if(this._typeMap[t]=e,ae(e)){for(const t of e.getInterfaces())if(ae(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(se(e))for(const t of e.getInterfaces())if(ae(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.objects.push(e)}}}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return ce(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){return this._implementationsMap[e.name]??{objects:[],interfaces:[]}}isSubType(e,t){let n=this._subTypeMap[e.name];if(void 0===n){if(n=Object.create(null),ce(e))for(const t of e.getTypes())n[t.name]=!0;else{const t=this.getImplementations(e);for(const e of t.objects)n[e.name]=!0;for(const e of t.interfaces)n[e.name]=!0}this._subTypeMap[e.name]=n}return void 0!==n[t.name]}getDirectives(){return this._directives}getDirective(e){return this.getDirectives().find((t=>t.name===e))}toConfig(){return{description:this.description,query:this.getQueryType(),mutation:this.getMutationType(),subscription:this.getSubscriptionType(),types:C(this.getTypeMap()),directives:this.getDirectives().slice(),extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[],assumeValid:void 0!==this.__validationErrors}}get[Symbol.toStringTag](){return"GraphQLSchema"}}function yt(e,t){const n=ge(e);if(!t.has(n))if(t.add(n),ce(n))for(const e of n.getTypes())yt(e,t);else if(se(n)||ae(n)){for(const e of n.getInterfaces())yt(e,t);for(const e of C(n.getFields())){yt(e.type,t);for(const n of e.args)yt(n.type,t)}}else if(pe(n))for(const e of C(n.getFields()))yt(e.type,t);return t}function Et(e){if(mt(e),e.__validationErrors)return e.__validationErrors;const t=new SchemaValidationContext(e);!function(e){const t=e.schema,n=t.getQueryType();n?se(n)||e.reportError(`Query root type must be Object type, it cannot be ${l(n)}.`,Tt(t,"query")??n.astNode):e.reportError("Query root type must be provided.",t.astNode);const r=t.getMutationType();r&&!se(r)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${l(r)}.`,Tt(t,"mutation")??r.astNode);const i=t.getSubscriptionType();i&&!se(i)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${l(i)}.`,Tt(t,"subscription")??i.astNode)}(t),function(e){for(const t of e.schema.getDirectives())if(ut(t)){Nt(e,t);for(const n of t.args)Nt(e,n),fe(n.type)||e.reportError(`The type of @${t.name}(${n.name}:) must be Input Type but got: ${l(n.type)}.`,n.astNode),we(n)&&null!=n.deprecationReason&&e.reportError(`Required argument @${t.name}(${n.name}:) cannot be deprecated.`,[kt(n.astNode),n.astNode?.type])}else e.reportError(`Expected directive but got: ${l(t)}.`,t?.astNode)}(t),function(e){const t=function(e){const t=Object.create(null),n=[],r=Object.create(null);return i;function i(o){if(t[o.name])return;t[o.name]=!0,r[o.name]=n.length;const s=C(o.getFields());for(const t of s)if(de(t.type)&&pe(t.type.ofType)){const o=t.type.ofType,s=r[o.name];if(n.push(t),void 0===s)i(o);else{const t=n.slice(s),r=t.map((e=>e.name)).join(".");e.reportError(`Cannot reference Input Object "${o.name}" within itself through a series of non-null fields: "${r}".`,t.map((e=>e.astNode)))}n.pop()}r[o.name]=void 0}}(e),n=e.schema.getTypeMap();for(const r of C(n))Ie(r)?(ct(r)||Nt(e,r),se(r)||ae(r)?(vt(e,r),It(e,r)):ce(r)?Ot(e,r):ue(r)?bt(e,r):pe(r)&&(Lt(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${l(r)}.`,r.astNode)}(t);const n=t.getErrors();return e.__validationErrors=n,n}class SchemaValidationContext{constructor(e){this._errors=[],this.schema=e}reportError(e,t){const n=Array.isArray(t)?t.filter(Boolean):t;this.addError(new GraphQLError(e,n))}addError(e){this._errors.push(e)}getErrors(){return this._errors}}function Tt(e,t){const n=At(e,(e=>e.operationTypes));for(const e of n)if(e.operation===t)return e.type}function Nt(e,t){const n=("string"==typeof(r=t.name)||f(0,"Expected name to be a string."),r.length>1&&"_"===r[0]&&"_"===r[1]?new GraphQLError(`Name "${r}" must not begin with "__", which is reserved by GraphQL introspection.`):$.test(r)?void 0:new GraphQLError(`Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "${r}" does not.`));var r;n&&e.addError(function(e,t,n){const r=e instanceof Error?e:new Error("Unexpected error value: "+l(e));return Array.isArray(r.path)?r:new GraphQLError(r.message,r.nodes??t,r.source,r.positions,n,r)}(n,t.astNode))}function vt(e,t){const n=C(t.getFields());0===n.length&&e.reportError(`Type ${t.name} must define one or more fields.`,St(t));for(const r of n){Nt(e,r),he(r.type)||e.reportError(`The type of ${t.name}.${r.name} must be Output Type but got: ${l(r.type)}.`,r.astNode?.type);for(const n of r.args){const i=n.name;Nt(e,n),fe(n.type)||e.reportError(`The type of ${t.name}.${r.name}(${i}:) must be Input Type but got: ${l(n.type)}.`,n.astNode?.type),we(n)&&null!=n.deprecationReason&&e.reportError(`Required argument ${t.name}.${r.name}(${i}:) cannot be deprecated.`,[kt(n.astNode),n.astNode?.type])}}}function It(e,t){const n=Object.create(null);for(const r of t.getInterfaces())ae(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,Dt(t,r)):(n[r.name]=!0,_t(e,t,r),gt(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,Dt(t,r)):e.reportError(`Type ${l(t)} must only implement Interface types, it cannot implement ${l(r)}.`,Dt(t,r))}function gt(e,t,n){const r=t.getFields();for(const i of C(n.getFields())){const o=i.name,s=r[o];if(s){Ce(e.schema,s.type,i.type)||e.reportError(`Interface field ${n.name}.${o} expects type ${l(i.type)} but ${t.name}.${o} is type ${l(s.type)}.`,[i.astNode?.type,s.astNode?.type]);for(const r of i.args){const i=r.name,a=s.args.find((e=>e.name===i));a?Ge(r.type,a.type)||e.reportError(`Interface field argument ${n.name}.${o}(${i}:) expects type ${l(r.type)} but ${t.name}.${o}(${i}:) is type ${l(a.type)}.`,[r.astNode?.type,a.astNode?.type]):e.reportError(`Interface field argument ${n.name}.${o}(${i}:) expected but ${t.name}.${o} does not provide it.`,[r.astNode,s.astNode])}for(const r of s.args){const s=r.name;!i.args.find((e=>e.name===s))&&we(r)&&e.reportError(`Object field ${t.name}.${o} includes required argument ${s} that is missing from the Interface field ${n.name}.${o}.`,[r.astNode,i.astNode])}}else e.reportError(`Interface field ${n.name}.${o} expected but ${t.name} does not provide it.`,[i.astNode,...St(t)])}}function _t(e,t,n){const r=t.getInterfaces();for(const i of n.getInterfaces())-1===r.indexOf(i)&&e.reportError(i===t?`Type ${t.name} cannot implement ${n.name} because it would create a circular reference.`:`Type ${t.name} must implement ${i.name} because it is implemented by ${n.name}.`,[...Dt(n,i),...Dt(t,n)])}function Ot(e,t){const n=t.getTypes();0===n.length&&e.reportError(`Union type ${t.name} must define one or more member types.`,St(t));const r=Object.create(null);for(const i of n)r[i.name]?e.reportError(`Union type ${t.name} can only include type ${i.name} once.`,wt(t,i.name)):(r[i.name]=!0,se(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${l(i)}.`,wt(t,String(i))))}function bt(e,t){const n=t.getValues();0===n.length&&e.reportError(`Enum type ${t.name} must define one or more values.`,St(t));for(const r of n){const n=r.name;Nt(e,r),"true"!==n&&"false"!==n&&"null"!==n||e.reportError(`Enum type ${t.name} cannot include value: ${n}.`,r.astNode)}}function Lt(e,t){const n=C(t.getFields());0===n.length&&e.reportError(`Input Object type ${t.name} must define one or more fields.`,St(t));for(const r of n)Nt(e,r),fe(r.type)||e.reportError(`The type of ${t.name}.${r.name} must be Input Type but got: ${l(r.type)}.`,r.astNode?.type),Re(r)&&null!=r.deprecationReason&&e.reportError(`Required input field ${t.name}.${r.name} cannot be deprecated.`,[kt(r.astNode),r.astNode?.type])}function St(e){const{astNode:t,extensionASTNodes:n}=e;return t?n?[t].concat(n):[t]:n??[]}function At(e,t){let n=[];for(const r of St(e))n=n.concat(t(r)??[]);return n}function Dt(e,t){return At(e,(e=>e.interfaces)).filter((e=>e.name.value===t.name))}function wt(e,t){return At(e,(e=>e.types)).filter((e=>e.name.value===t))}function kt(e){return e?.directives?.find((e=>e.name.value===dt.name))}function xt(e,t){let n;return t.kind===c.LIST_TYPE?(n=xt(e,t.type),n&&new GraphQLList(n)):t.kind===c.NON_NULL_TYPE?(n=xt(e,t.type),n&&new GraphQLNonNull(n)):t.kind===c.NAMED_TYPE?e.getType(t.name.value):void ne(0,"Unexpected type node: "+l(t))}class TypeInfo{constructor(e,t,n){this._schema=e,this._typeStack=[],this._parentTypeStack=[],this._inputTypeStack=[],this._fieldDefStack=[],this._defaultValueStack=[],this._directive=null,this._argument=null,this._enumValue=null,this._getFieldDef=t??Ft,n&&(fe(n)&&this._inputTypeStack.push(n),ye(n)&&this._parentTypeStack.push(n),he(n)&&this._typeStack.push(n))}getType(){if(this._typeStack.length>0)return this._typeStack[this._typeStack.length-1]}getParentType(){if(this._parentTypeStack.length>0)return this._parentTypeStack[this._parentTypeStack.length-1]}getInputType(){if(this._inputTypeStack.length>0)return this._inputTypeStack[this._inputTypeStack.length-1]}getParentInputType(){if(this._inputTypeStack.length>1)return this._inputTypeStack[this._inputTypeStack.length-2]}getFieldDef(){if(this._fieldDefStack.length>0)return this._fieldDefStack[this._fieldDefStack.length-1]}getDefaultValue(){if(this._defaultValueStack.length>0)return this._defaultValueStack[this._defaultValueStack.length-1]}getDirective(){return this._directive}getArgument(){return this._argument}getEnumValue(){return this._enumValue}enter(e){const t=this._schema;switch(e.kind){case c.SELECTION_SET:{const e=ge(this.getType());this._parentTypeStack.push(ye(e)?e:void 0);break}case c.FIELD:{const n=this.getParentType();let r,i;n&&(r=this._getFieldDef(t,n,e),r&&(i=r.type)),this._fieldDefStack.push(r),this._typeStack.push(he(i)?i:void 0);break}case c.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case c.OPERATION_DEFINITION:{let n;switch(e.operation){case"query":n=t.getQueryType();break;case"mutation":n=t.getMutationType();break;case"subscription":n=t.getSubscriptionType()}this._typeStack.push(se(n)?n:void 0);break}case c.INLINE_FRAGMENT:case c.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?xt(t,n):ge(this.getType());this._typeStack.push(he(r)?r:void 0);break}case c.VARIABLE_DEFINITION:{const n=xt(t,e.type);this._inputTypeStack.push(fe(n)?n:void 0);break}case c.ARGUMENT:{let t,n;const r=this.getDirective()??this.getFieldDef();r&&(t=r.args.find((t=>t.name===e.name.value)),t&&(n=t.type)),this._argument=t,this._defaultValueStack.push(t?t.defaultValue:void 0),this._inputTypeStack.push(fe(n)?n:void 0);break}case c.LIST:{const e=ve(this.getInputType()),t=le(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(fe(t)?t:void 0);break}case c.OBJECT_FIELD:{const t=ge(this.getInputType());let n,r;pe(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(fe(n)?n:void 0);break}case c.ENUM:{const t=ge(this.getInputType());let n;ue(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case c.SELECTION_SET:this._parentTypeStack.pop();break;case c.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case c.DIRECTIVE:this._directive=null;break;case c.OPERATION_DEFINITION:case c.INLINE_FRAGMENT:case c.FRAGMENT_DEFINITION:this._typeStack.pop();break;case c.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case c.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case c.LIST:case c.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case c.ENUM:this._enumValue=null}}}function Ft(e,t,n){const r=n.name.value;return r===it.name&&e.getQueryType()===t?it:r===ot.name&&e.getQueryType()===t?ot:r===st.name&&ye(t)?st:se(t)||ae(t)?t.getFields()[r]:void 0}function Rt(e,t){return{enter(n){e.enter(n);const r=G(t,n.kind,!1);if(r){const i=r.apply(t,arguments);return void 0!==i&&(e.leave(n),u(i)&&e.enter(i)),i}},leave(n){const r=G(t,n.kind,!0);let i;return r&&(i=r.apply(t,arguments)),e.leave(n),i}}}function Gt(e){return e.kind===c.OPERATION_DEFINITION||e.kind===c.FRAGMENT_DEFINITION}function Ct(e){return e.kind===c.SCALAR_TYPE_DEFINITION||e.kind===c.OBJECT_TYPE_DEFINITION||e.kind===c.INTERFACE_TYPE_DEFINITION||e.kind===c.UNION_TYPE_DEFINITION||e.kind===c.ENUM_TYPE_DEFINITION||e.kind===c.INPUT_OBJECT_TYPE_DEFINITION}function $t(e){return e.kind===c.SCALAR_TYPE_EXTENSION||e.kind===c.OBJECT_TYPE_EXTENSION||e.kind===c.INTERFACE_TYPE_EXTENSION||e.kind===c.UNION_TYPE_EXTENSION||e.kind===c.ENUM_TYPE_EXTENSION||e.kind===c.INPUT_OBJECT_TYPE_EXTENSION}function Qt(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);for(const t of e.getDocument().definitions)Ct(t)&&(r[t.name.value]=!0);const i=Object.keys(n).concat(Object.keys(r));return{NamedType(t,o,s,a,u){const p=t.name.value;if(!n[p]&&!r[p]){const n=u[2]??s,r=null!=n&&(l=n,!Array.isArray(l)&&(function(e){return e.kind===c.SCHEMA_DEFINITION||Ct(e)||e.kind===c.DIRECTIVE_DEFINITION}(l)||function(e){return e.kind===c.SCHEMA_EXTENSION||$t(e)}(l)));if(r&&function(e){return-1!==Vt.indexOf(e)}(p))return;const o=Y(p,r?Vt.concat(i):i);e.reportError(new GraphQLError(`Unknown type "${p}".`+P(o),t))}var l}}}const Vt=[...Je,...at].map((e=>e.name));function Ut(e){const t=[],n=[];return{OperationDefinition:e=>(t.push(e),!1),FragmentDefinition:e=>(n.push(e),!1),Document:{leave(){const r=Object.create(null);for(const n of t)for(const t of e.getRecursivelyReferencedFragments(n))r[t.name.value]=!0;for(const t of n){const n=t.name.value;!0!==r[n]&&e.reportError(new GraphQLError(`Fragment "${n}" is never used.`,t))}}}}}function jt(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():ht;for(const e of r)t[e.name]=e.locations;const i=e.getDocument().definitions;for(const e of i)e.kind===c.DIRECTIVE_DEFINITION&&(t[e.name.value]=e.locations.map((e=>e.value)));return{Directive(n,r,i,o,s){const a=n.name.value,u=t[a];if(!u)return void e.reportError(new GraphQLError(`Unknown directive "@${a}".`,n));const p=function(e){const t=e[e.length-1];switch(!Array.isArray(t)||ne(0),t.kind){case c.OPERATION_DEFINITION:return function(e){switch(e){case"query":return m.QUERY;case"mutation":return m.MUTATION;case"subscription":return m.SUBSCRIPTION}ne(0,"Unexpected operation: "+l(e))}(t.operation);case c.FIELD:return m.FIELD;case c.FRAGMENT_SPREAD:return m.FRAGMENT_SPREAD;case c.INLINE_FRAGMENT:return m.INLINE_FRAGMENT;case c.FRAGMENT_DEFINITION:return m.FRAGMENT_DEFINITION;case c.VARIABLE_DEFINITION:return m.VARIABLE_DEFINITION;case c.SCHEMA_DEFINITION:case c.SCHEMA_EXTENSION:return m.SCHEMA;case c.SCALAR_TYPE_DEFINITION:case c.SCALAR_TYPE_EXTENSION:return m.SCALAR;case c.OBJECT_TYPE_DEFINITION:case c.OBJECT_TYPE_EXTENSION:return m.OBJECT;case c.FIELD_DEFINITION:return m.FIELD_DEFINITION;case c.INTERFACE_TYPE_DEFINITION:case c.INTERFACE_TYPE_EXTENSION:return m.INTERFACE;case c.UNION_TYPE_DEFINITION:case c.UNION_TYPE_EXTENSION:return m.UNION;case c.ENUM_TYPE_DEFINITION:case c.ENUM_TYPE_EXTENSION:return m.ENUM;case c.ENUM_VALUE_DEFINITION:return m.ENUM_VALUE;case c.INPUT_OBJECT_TYPE_DEFINITION:case c.INPUT_OBJECT_TYPE_EXTENSION:return m.INPUT_OBJECT;case c.INPUT_VALUE_DEFINITION:return e[e.length-3].kind===c.INPUT_OBJECT_TYPE_DEFINITION?m.INPUT_FIELD_DEFINITION:m.ARGUMENT_DEFINITION}}(s);p&&-1===u.indexOf(p)&&e.reportError(new GraphQLError(`Directive "@${a}" may not be used on ${p}.`,n))}}}function Mt(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():ht;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===c.DIRECTIVE_DEFINITION&&(t[e.name.value]=!e.repeatable);const o=Object.create(null),s=Object.create(null);return{enter(n){if(null==n.directives)return;let r;if(n.kind===c.SCHEMA_DEFINITION||n.kind===c.SCHEMA_EXTENSION)r=o;else if(Ct(n)||$t(n)){const e=n.name.value;r=s[e],void 0===r&&(s[e]=r=Object.create(null))}else r=Object.create(null);for(const i of n.directives){const n=i.name.value;t[n]&&(r[n]?e.reportError(new GraphQLError(`The directive "@${n}" can only be used once at this location.`,[r[n],i])):r[n]=i)}}}}function Pt(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():ht;for(const e of r)t[e.name]=e.args.map((e=>e.name));const i=e.getDocument().definitions;for(const e of i)if(e.kind===c.DIRECTIVE_DEFINITION){const n=e.arguments??[];t[e.name.value]=n.map((e=>e.name.value))}return{Directive(n){const r=n.name.value,i=t[r];if(n.arguments&&i)for(const t of n.arguments){const n=t.name.value;if(-1===i.indexOf(n)){const o=Y(n,i);e.reportError(new GraphQLError(`Unknown argument "${n}" on directive "@${r}".`+P(o),t))}}return!1}}}function Bt(e){let t=Object.create(null);return{Field(){t=Object.create(null)},Directive(){t=Object.create(null)},Argument(n){const r=n.name.value;return t[r]?e.reportError(new GraphQLError(`There can be only one argument named "${r}".`,[t[r],n.name])):t[r]=n.name,!1}}}function Yt(e,t){const n=e.getInputType();if(!n)return;const r=ge(n);if(me(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=l(n);e.reportError(new GraphQLError(`Expected value of type "${r}", found ${q(t)}.`,t))}}catch(r){const i=l(n);r instanceof GraphQLError?e.reportError(r):e.reportError(new GraphQLError(`Expected value of type "${i}", found ${q(t)}; `+r.message,t,void 0,void 0,void 0,r))}else{const r=l(n);e.reportError(new GraphQLError(`Expected value of type "${r}", found ${q(t)}.`,t))}}function Jt(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():ht;for(const e of r)t[e.name]=V(e.args.filter(we),(e=>e.name));const i=e.getDocument().definitions;for(const e of i)if(e.kind===c.DIRECTIVE_DEFINITION){const n=e.arguments??[];t[e.name.value]=V(n.filter(qt),(e=>e.name.value))}return{Directive:{leave(n){const r=n.name.value,i=t[r];if(i){const t=V(n.arguments??[],(e=>e.name.value));for(const o of Object.keys(i))if(!t[o]){const t=i[o].type,s=ie(t)?l(t):q(t);e.reportError(new GraphQLError(`Directive "@${r}" argument "${o}" of type "${s}" is required, but it was not provided.`,n))}}}}}}function qt(e){return e.type.kind===c.NON_NULL_TYPE&&null==e.defaultValue}function Kt(e,t,n,r,i){if(de(r)&&!de(t)){const o=void 0!==i;if(!(null!=n&&n.kind!==c.NULL)&&!o)return!1;return Ce(e,t,r.ofType)}return Ce(e,t,r)}function Xt(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+Xt(t))).join(" and "):e}function zt(e,t,n,r,i,o,s){const a=e.getFragment(s);if(!a)return;const[c,u]=nn(e,n,a);if(o!==c){Zt(e,t,n,r,i,o,c);for(let s=0;s{const n=t.find((t=>t.name.value===e.name.value));return!!n&&(r=e.value,i=n.value,q(r)===q(i));var r,i}))}(c.arguments??[],d.arguments??[]))return[[i,"they have differing arguments"],[c],[d]]}const m=u?.type,y=f?.type;if(m&&y&&en(m,y))return[[i,`they return conflicting types "${l(m)}" and "${l(y)}"`],[c],[d]];const E=c.selectionSet,T=d.selectionSet;if(E&&T){return function(e,t,n,r){if(e.length>0)return[[t,e.map((([e])=>e))],e.reduce(((e,[,t])=>e.concat(t)),[n]),e.reduce(((e,[,,t])=>e.concat(t)),[r])]}(function(e,t,n,r,i,o,s,a){const c=[],[u,p]=tn(e,t,i,o),[l,d]=tn(e,t,s,a);if(Zt(e,c,t,n,r,u,l),0!==d.length)for(let i=0;i!1}},function(e){let t=0;return{Document(e){t=e.definitions.filter((e=>e.kind===c.OPERATION_DEFINITION)).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new GraphQLError("This anonymous operation must be the only defined operation.",n))}}},function(e){return{OperationDefinition(t){"subscription"===t.operation&&1!==t.selectionSet.selections.length&&e.reportError(new GraphQLError(t.name?`Subscription "${t.name.value}" must select only one top level field.`:"Anonymous Subscription must select only one top level field.",t.selectionSet.selections.slice(1)))}}},Qt,function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=xt(e.getSchema(),n);if(t&&!ye(t)){const t=q(n);e.reportError(new GraphQLError(`Fragment cannot condition on non composite type "${t}".`,n))}}},FragmentDefinition(t){const n=xt(e.getSchema(),t.typeCondition);if(n&&!ye(n)){const n=q(t.typeCondition);e.reportError(new GraphQLError(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,t.typeCondition))}}}},function(e){return{VariableDefinition(t){const n=xt(e.getSchema(),t.type);if(n&&!fe(n)){const n=t.variable.name.value,r=q(t.type);e.reportError(new GraphQLError(`Variable "$${n}" cannot be non-input type "${r}".`,t.type))}}}},function(e){return{Field(t){const n=e.getType(),r=t.selectionSet;if(n)if(me(ge(n))){if(r){const i=t.name.value,o=l(n);e.reportError(new GraphQLError(`Field "${i}" must not have a selection since type "${o}" has no subfields.`,r))}}else if(!r){const r=t.name.value,i=l(n);e.reportError(new GraphQLError(`Field "${r}" of type "${i}" must have a selection of subfields. Did you mean "${r} { ... }"?`,t))}}}},function(e){return{Field(t){const n=e.getParentType();if(n){if(!e.getFieldDef()){const r=e.getSchema(),i=t.name.value;let o=P("to use an inline fragment on",function(e,t,n){if(!Ee(t))return[];const r=new Set,i=Object.create(null);for(const o of e.getPossibleTypes(t))if(o.getFields()[n]){r.add(o),i[o.name]=1;for(const e of o.getInterfaces())e.getFields()[n]&&(r.add(e),i[e.name]=(i[e.name]??0)+1)}return Array.from(r).sort(((t,n)=>{const r=i[n.name]-i[t.name];return 0!==r?r:ae(t)&&e.isSubType(t,n)?-1:ae(n)&&e.isSubType(n,t)?1:t.name.localeCompare(n.name)})).map((e=>e.name))}(r,n,i));""===o&&(o=P(function(e,t){if(se(e)||ae(e)){return Y(t,Object.keys(e.getFields()))}return[]}(n,i))),e.reportError(new GraphQLError(`Cannot query field "${i}" on type "${n.name}".`+o,t))}}}}},function(e){const t=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(n){const r=n.name.value;return t[r]?e.reportError(new GraphQLError(`There can be only one fragment named "${r}".`,[t[r],n.name])):t[r]=n.name,!1}}},function(e){return{FragmentSpread(t){const n=t.name.value;e.getFragment(n)||e.reportError(new GraphQLError(`Unknown fragment "${n}".`,t.name))}}},Ut,function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(ye(n)&&ye(r)&&!$e(e.getSchema(),n,r)){const i=l(r),o=l(n);e.reportError(new GraphQLError(`Fragment cannot be spread here as objects of type "${i}" can never be of type "${o}".`,t))}},FragmentSpread(t){const n=t.name.value,r=function(e,t){const n=e.getFragment(t);if(n){const t=xt(e.getSchema(),n.typeCondition);if(ye(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!$e(e.getSchema(),r,i)){const o=l(i),s=l(r);e.reportError(new GraphQLError(`Fragment "${n}" cannot be spread here as objects of type "${o}" can never be of type "${s}".`,t))}}}},function(e){const t=Object.create(null),n=[],r=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition:e=>(i(e),!1)};function i(o){if(t[o.name.value])return;const s=o.name.value;t[s]=!0;const a=e.getFragmentSpreads(o.selectionSet);if(0!==a.length){r[s]=n.length;for(const t of a){const o=t.name.value,s=r[o];if(n.push(t),void 0===s){const t=e.getFragment(o);t&&i(t)}else{const t=n.slice(s),r=t.slice(0,-1).map((e=>'"'+e.name.value+'"')).join(", ");e.reportError(new GraphQLError(`Cannot spread fragment "${o}" within itself`+(""!==r?` via ${r}.`:"."),t))}n.pop()}r[s]=void 0}}},function(e){let t=Object.create(null);return{OperationDefinition(){t=Object.create(null)},VariableDefinition(n){const r=n.variable.name.value;t[r]?e.reportError(new GraphQLError(`There can be only one variable named "$${r}".`,[t[r],n.variable.name])):t[r]=n.variable.name}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:i}of r){const r=i.name.value;!0!==t[r]&&e.reportError(new GraphQLError(n.name?`Variable "$${r}" is not defined by operation "${n.name.value}".`:`Variable "$${r}" is not defined.`,[i,n]))}}},VariableDefinition(e){t[e.variable.name.value]=!0}}},function(e){let t=[];return{OperationDefinition:{enter(){t=[]},leave(n){const r=Object.create(null),i=e.getRecursiveVariableUsages(n);for(const{node:e}of i)r[e.name.value]=!0;for(const i of t){const t=i.variable.name.value;!0!==r[t]&&e.reportError(new GraphQLError(n.name?`Variable "$${t}" is never used in operation "${n.name.value}".`:`Variable "$${t}" is never used.`,i))}}},VariableDefinition(e){t.push(e)}}},jt,Mt,function(e){return{...Pt(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,o=Y(n,r.args.map((e=>e.name)));e.reportError(new GraphQLError(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+P(o),t))}}}},Bt,function(e){return{ListValue(t){if(!le(ve(e.getParentInputType())))return Yt(e,t),!1},ObjectValue(t){const n=ge(e.getInputType());if(!pe(n))return Yt(e,t),!1;const r=V(t.fields,(e=>e.name.value));for(const i of C(n.getFields())){if(!r[i.name]&&Re(i)){const r=l(i.type);e.reportError(new GraphQLError(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,t))}}},ObjectField(t){const n=ge(e.getParentInputType());if(!e.getInputType()&&pe(n)){const r=Y(t.name.value,Object.keys(n.getFields()));e.reportError(new GraphQLError(`Field "${t.name.value}" is not defined by type "${n.name}".`+P(r),t))}},NullValue(t){const n=e.getInputType();de(n)&&e.reportError(new GraphQLError(`Expected value of type "${l(n)}", found ${q(t)}.`,t))},EnumValue:t=>Yt(e,t),IntValue:t=>Yt(e,t),FloatValue:t=>Yt(e,t),StringValue:t=>Yt(e,t),BooleanValue:t=>Yt(e,t)}},function(e){return{...Jt(e),Field:{leave(t){const n=e.getFieldDef();if(!n)return!1;const r=V(t.arguments??[],(e=>e.name.value));for(const i of n.args){if(!r[i.name]&&we(i)){const r=l(i.type);e.reportError(new GraphQLError(`Field "${n.name}" argument "${i.name}" of type "${r}" is required, but it was not provided.`,t))}}}}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:n,type:i,defaultValue:o}of r){const r=n.name.value,s=t[r];if(s&&i){const t=e.getSchema(),a=xt(t,s.type);if(a&&!Kt(t,a,s.defaultValue,i,o)){const t=l(a),o=l(i);e.reportError(new GraphQLError(`Variable "$${r}" of type "${t}" used in position expecting type "${o}".`,[s,n]))}}}}},VariableDefinition(e){t[e.variable.name.value]=e}}},function(e){const t=new PairSet,n=new Map;return{SelectionSet(r){const i=function(e,t,n,r,i){const o=[],[s,a]=tn(e,t,r,i);if(function(e,t,n,r,i){for(const[o,s]of Q(i))if(s.length>1)for(let i=0;i0&&e.reportError(new GraphQLError("Must provide only one schema definition.",t)),++r)}}},function(e){const t=e.getSchema(),n=Object.create(null),r=t?{query:t.getQueryType(),mutation:t.getMutationType(),subscription:t.getSubscriptionType()}:{};return{SchemaDefinition:i,SchemaExtension:i};function i(t){const i=t.operationTypes??[];for(const t of i){const i=t.operation,o=n[i];r[i]?e.reportError(new GraphQLError(`Type for ${i} already defined in the schema. It cannot be redefined.`,t)):o?e.reportError(new GraphQLError(`There can be only one ${i} type in schema.`,[o,t])):n[i]=t}return!1}},function(e){const t=Object.create(null),n=e.getSchema();return{ScalarTypeDefinition:r,ObjectTypeDefinition:r,InterfaceTypeDefinition:r,UnionTypeDefinition:r,EnumTypeDefinition:r,InputObjectTypeDefinition:r};function r(r){const i=r.name.value;if(!n?.getType(i))return t[i]?e.reportError(new GraphQLError(`There can be only one type named "${i}".`,[t[i],r.name])):t[i]=r.name,!1;e.reportError(new GraphQLError(`Type "${i}" already exists in the schema. It cannot also be defined in this type definition.`,r.name))}},function(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);return{EnumTypeDefinition:i,EnumTypeExtension:i};function i(t){const i=t.name.value;r[i]||(r[i]=Object.create(null));const o=t.values??[],s=r[i];for(const t of o){const r=t.name.value,o=n[i];ue(o)&&o.getValue(r)?e.reportError(new GraphQLError(`Enum value "${i}.${r}" already exists in the schema. It cannot also be defined in this type extension.`,t.name)):s[r]?e.reportError(new GraphQLError(`Enum value "${i}.${r}" can only be defined once.`,[s[r],t.name])):s[r]=t.name}return!1}},function(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);return{InputObjectTypeDefinition:i,InputObjectTypeExtension:i,InterfaceTypeDefinition:i,InterfaceTypeExtension:i,ObjectTypeDefinition:i,ObjectTypeExtension:i};function i(t){const i=t.name.value;r[i]||(r[i]=Object.create(null));const o=t.fields??[],s=r[i];for(const t of o){const r=t.name.value;sn(n[i],r)?e.reportError(new GraphQLError(`Field "${i}.${r}" already exists in the schema. It cannot also be defined in this type extension.`,t.name)):s[r]?e.reportError(new GraphQLError(`Field "${i}.${r}" can only be defined once.`,[s[r],t.name])):s[r]=t.name}return!1}},function(e){const t=Object.create(null),n=e.getSchema();return{DirectiveDefinition(r){const i=r.name.value;if(!n?.getDirective(i))return t[i]?e.reportError(new GraphQLError(`There can be only one directive named "@${i}".`,[t[i],r.name])):t[i]=r.name,!1;e.reportError(new GraphQLError(`Directive "@${i}" already exists in the schema. It cannot be redefined.`,r.name))}}},Qt,jt,Mt,function(e){const t=e.getSchema(),n=Object.create(null);for(const t of e.getDocument().definitions)Ct(t)&&(n[t.name.value]=t);return{ScalarTypeExtension:r,ObjectTypeExtension:r,InterfaceTypeExtension:r,UnionTypeExtension:r,EnumTypeExtension:r,InputObjectTypeExtension:r};function r(r){const i=r.name.value,o=n[i],s=t?.getType(i);let a;if(o?a=an[o.kind]:s&&(a=function(e){if(oe(e))return c.SCALAR_TYPE_EXTENSION;if(se(e))return c.OBJECT_TYPE_EXTENSION;if(ae(e))return c.INTERFACE_TYPE_EXTENSION;if(ce(e))return c.UNION_TYPE_EXTENSION;if(ue(e))return c.ENUM_TYPE_EXTENSION;if(pe(e))return c.INPUT_OBJECT_TYPE_EXTENSION;ne(0,"Unexpected type: "+l(e))}(s)),a){if(a!==r.kind){const t=function(e){switch(e){case c.SCALAR_TYPE_EXTENSION:return"scalar";case c.OBJECT_TYPE_EXTENSION:return"object";case c.INTERFACE_TYPE_EXTENSION:return"interface";case c.UNION_TYPE_EXTENSION:return"union";case c.ENUM_TYPE_EXTENSION:return"enum";case c.INPUT_OBJECT_TYPE_EXTENSION:return"input object"}ne(0,"Unexpected kind: "+l(e))}(r.kind);e.reportError(new GraphQLError(`Cannot extend non-${t} type "${i}".`,o?[o,r]:r))}}else{let o=Object.keys(n);t&&(o=o.concat(Object.keys(t.getTypeMap())));const s=Y(i,o);e.reportError(new GraphQLError(`Cannot extend type "${i}" because it is not defined.`+P(s),r.name))}}},Pt,Bt,on,Jt]);class ASTValidationContext{constructor(e,t){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=t}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let t=this._fragments;return t||(this._fragments=t=this.getDocument().definitions.reduce(((e,t)=>(t.kind===c.FRAGMENT_DEFINITION&&(e[t.name.value]=t),e)),Object.create(null))),t[e]}getFragmentSpreads(e){let t=this._fragmentSpreads.get(e);if(!t){t=[];const n=[e];for(;0!==n.length;){const e=n.pop();for(const r of e.selections)r.kind===c.FRAGMENT_SPREAD?t.push(r):r.selectionSet&&n.push(r.selectionSet)}this._fragmentSpreads.set(e,t)}return t}getRecursivelyReferencedFragments(e){let t=this._recursivelyReferencedFragments.get(e);if(!t){t=[];const n=Object.create(null),r=[e.selectionSet];for(;0!==r.length;){const e=r.pop();for(const i of this.getFragmentSpreads(e)){const e=i.name.value;if(!0!==n[e]){n[e]=!0;const i=this.getFragment(e);i&&(t.push(i),r.push(i.selectionSet))}}}this._recursivelyReferencedFragments.set(e,t)}return t}}class SDLValidationContext extends ASTValidationContext{constructor(e,t,n){super(e,n),this._schema=t}getSchema(){return this._schema}}class ValidationContext extends ASTValidationContext{constructor(e,t,n,r){super(t,r),this._schema=e,this._typeInfo=n,this._variableUsages=new Map,this._recursiveVariableUsages=new Map}getSchema(){return this._schema}getVariableUsages(e){let t=this._variableUsages.get(e);if(!t){const n=[],r=new TypeInfo(this._schema);F(e,Rt(r,{VariableDefinition:()=>!1,Variable(e){n.push({node:e,type:r.getInputType(),defaultValue:r.getDefaultValue()})}})),t=n,this._variableUsages.set(e,t)}return t}getRecursiveVariableUsages(e){let t=this._recursiveVariableUsages.get(e);if(!t){t=this.getVariableUsages(e);for(const n of this.getRecursivelyReferencedFragments(e))t=t.concat(this.getVariableUsages(n));this._recursiveVariableUsages.set(e,t)}return t}getType(){return this._typeInfo.getType()}getParentType(){return this._typeInfo.getParentType()}getInputType(){return this._typeInfo.getInputType()}getParentInputType(){return this._typeInfo.getParentInputType()}getFieldDef(){return this._typeInfo.getFieldDef()}getDirective(){return this._typeInfo.getDirective()}getArgument(){return this._typeInfo.getArgument()}getEnumValue(){return this._typeInfo.getEnumValue()}}function pn(e,t,n=cn,r=new TypeInfo(e),i={maxErrors:void 0}){t||f(0,"Must provide document."),function(e){const t=Et(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}(e);const o=Object.freeze({}),s=[],a=new ValidationContext(e,t,r,(e=>{if(null!=i.maxErrors&&s.length>=i.maxErrors)throw s.push(new GraphQLError("Too many validation errors, error limit reached. Validation aborted.")),o;s.push(e)})),c=R(n.map((e=>e(a))));try{F(t,Rt(r,c))}catch(e){if(e!==o)throw e}return s}function ln(e,t,n=un){const r=[],i=new SDLValidationContext(e,t,(e=>{r.push(e)}));return F(e,R(n.map((e=>e(i))))),r}function dn(e,t,n){if(e){if(e.kind===c.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&de(t))return;return i}if(de(t)){if(e.kind===c.NULL)return;return dn(e,t.ofType,n)}if(e.kind===c.NULL)return null;if(le(t)){const r=t.ofType;if(e.kind===c.LIST){const t=[];for(const i of e.values)if(fn(i,n)){if(de(r))return;t.push(null)}else{const e=dn(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=dn(e,r,n);if(void 0===i)return;return[i]}if(pe(t)){if(e.kind!==c.OBJECT)return;const r=Object.create(null),i=V(e.fields,(e=>e.name.value));for(const e of C(t.getFields())){const t=i[e.name];if(!t||fn(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(de(e.type))return;continue}const o=dn(t.value,e.type,n);if(void 0===o)return;r[e.name]=o}return r}if(me(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}ne(0,"Unexpected input type: "+l(t))}}function fn(e,t){return e.kind===c.VARIABLE&&(null==t||void 0===t[e.name.value])}function hn(e,t,n){const r=t.directives?.find((t=>t.name.value===e.name));if(r)return function(e,t,n){const r={},i=V(t.arguments??[],(e=>e.name.value));for(const a of e.args){const e=a.name,u=a.type,p=i[e];if(!p){if(void 0!==a.defaultValue)r[e]=a.defaultValue;else if(de(u))throw new GraphQLError(`Argument "${e}" of required type "${l(u)}" was not provided.`,t);continue}const d=p.value;let f=d.kind===c.NULL;if(d.kind===c.VARIABLE){const t=d.name.value;if(null==n||(o=n,s=t,!Object.prototype.hasOwnProperty.call(o,s))){if(void 0!==a.defaultValue)r[e]=a.defaultValue;else if(de(u))throw new GraphQLError(`Argument "${e}" of required type "${l(u)}" was provided the variable "$${t}" which was not provided a runtime value.`,d);continue}f=null==n[t]}if(f&&de(u))throw new GraphQLError(`Argument "${e}" of non-null type "${l(u)}" must not be null.`,d);const h=dn(d,u,n);if(void 0===h)throw new GraphQLError(`Argument "${e}" has invalid value ${q(d)}.`,d);r[e]=h}var o,s;return r}(e,r,n)}function mn(e,n){t(e)&&t(e.__schema)||f(0,`Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${l(e)}.`);const r=e.__schema,i=M(r.types,(e=>e.name),(e=>function(e){if(null!=e&&null!=e.name&&null!=e.kind)switch(e.kind){case nt.SCALAR:return new GraphQLScalarType({name:(r=e).name,description:r.description,specifiedByUrl:r.specifiedByUrl});case nt.OBJECT:return new GraphQLObjectType({name:(n=e).name,description:n.description,interfaces:()=>y(n),fields:()=>E(n)});case nt.INTERFACE:return new GraphQLInterfaceType({name:(t=e).name,description:t.description,interfaces:()=>y(t),fields:()=>E(t)});case nt.UNION:return function(e){if(!e.possibleTypes){const t=l(e);throw new Error(`Introspection result missing possibleTypes: ${t}.`)}return new GraphQLUnionType({name:e.name,description:e.description,types:()=>e.possibleTypes.map(h)})}(e);case nt.ENUM:return function(e){if(!e.enumValues){const t=l(e);throw new Error(`Introspection result missing enumValues: ${t}.`)}return new GraphQLEnumType({name:e.name,description:e.description,values:M(e.enumValues,(e=>e.name),(e=>({description:e.description,deprecationReason:e.deprecationReason})))})}(e);case nt.INPUT_OBJECT:return function(e){if(!e.inputFields){const t=l(e);throw new Error(`Introspection result missing inputFields: ${t}.`)}return new GraphQLInputObjectType({name:e.name,description:e.description,fields:()=>N(e.inputFields)})}(e)}var t;var n;var r;const i=l(e);throw new Error(`Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${i}.`)}(e)));for(const e of[...Je,...at])i[e.name]&&(i[e.name]=e);const o=r.queryType?h(r.queryType):null,s=r.mutationType?h(r.mutationType):null,a=r.subscriptionType?h(r.subscriptionType):null,c=r.directives?r.directives.map((function(e){if(!e.args){const t=l(e);throw new Error(`Introspection result missing directive args: ${t}.`)}if(!e.locations){const t=l(e);throw new Error(`Introspection result missing directive locations: ${t}.`)}return new GraphQLDirective({name:e.name,description:e.description,isRepeatable:e.isRepeatable,locations:e.locations.slice(),args:N(e.args)})})):[];return new GraphQLSchema({description:r.description,query:o,mutation:s,subscription:a,types:C(i),directives:c,assumeValid:n?.assumeValid});function u(e){if(e.kind===nt.LIST){const t=e.ofType;if(!t)throw new Error("Decorated type deeper than introspection query.");return new GraphQLList(u(t))}if(e.kind===nt.NON_NULL){const t=e.ofType;if(!t)throw new Error("Decorated type deeper than introspection query.");const n=u(t);return new GraphQLNonNull(function(e){if(!Ne(e))throw new Error(`Expected ${l(e)} to be a GraphQL nullable type.`);return e}(n))}return d(e)}function d(e){const t=e.name;if(!t)throw new Error(`Unknown type reference: ${l(e)}.`);const n=i[t];if(!n)throw new Error(`Invalid or incomplete schema, unknown type: ${t}. Ensure that a full introspection query is used in order to build a client schema.`);return n}function h(e){return function(e){if(!se(e))throw new Error(`Expected ${l(e)} to be a GraphQL Object type.`);return e}(d(e))}function m(e){return function(e){if(!ae(e))throw new Error(`Expected ${l(e)} to be a GraphQL Interface type.`);return e}(d(e))}function y(e){if(null===e.interfaces&&e.kind===nt.INTERFACE)return[];if(!e.interfaces){const t=l(e);throw new Error(`Introspection result missing interfaces: ${t}.`)}return e.interfaces.map(m)}function E(e){if(!e.fields)throw new Error(`Introspection result missing fields: ${l(e)}.`);return M(e.fields,(e=>e.name),T)}function T(e){const t=u(e.type);if(!he(t)){const e=l(t);throw new Error(`Introspection must provide output type for fields, but received: ${e}.`)}if(!e.args){const t=l(e);throw new Error(`Introspection result missing field args: ${t}.`)}return{description:e.description,deprecationReason:e.deprecationReason,type:t,args:N(e.args)}}function N(e){return M(e,(e=>e.name),v)}function v(e){const t=u(e.type);if(!fe(t)){const e=l(t);throw new Error(`Introspection must provide input type for arguments, but received: ${e}.`)}const n=null!=e.defaultValue?dn(function(e,t){const n=new Parser(e,t);n.expectToken(p.SOF);const r=n.parseValueLiteral(!1);return n.expectToken(p.EOF),r}(e.defaultValue),t):void 0;return{description:e.description,type:t,defaultValue:n,deprecationReason:e.deprecationReason}}}function yn(e,t,n){const r=[],i=Object.create(null),o=[];let s;const a=[];for(const e of t.definitions)if(e.kind===c.SCHEMA_DEFINITION)s=e;else if(e.kind===c.SCHEMA_EXTENSION)a.push(e);else if(Ct(e))r.push(e);else if($t(e)){const t=e.name.value,n=i[t];i[t]=n?n.concat([e]):[e]}else e.kind===c.DIRECTIVE_DEFINITION&&o.push(e);if(0===Object.keys(i).length&&0===r.length&&0===o.length&&0===a.length&&null==s)return e;const u=Object.create(null);for(const t of e.types)u[t.name]=h(t);for(const e of r){const t=e.name.value;u[t]=En[t]??L(e)}const p={query:e.query&&f(e.query),mutation:e.mutation&&f(e.mutation),subscription:e.subscription&&f(e.subscription),...s&&E([s]),...E(a)};return{description:s?.description?.value,...p,types:C(u),directives:[...e.directives.map((function(e){const t=e.toConfig();return new GraphQLDirective({...t,args:U(t.args,y)})})),...o.map((function(e){const t=e.locations.map((({value:e})=>e));return new GraphQLDirective({name:e.name.value,description:e.description?.value,locations:t,isRepeatable:e.repeatable,args:I(e.arguments),astNode:e})}))],extensions:void 0,astNode:s??e.astNode,extensionASTNodes:e.extensionASTNodes.concat(a),assumeValid:n?.assumeValid??!1};function d(e){return le(e)?new GraphQLList(d(e.ofType)):de(e)?new GraphQLNonNull(d(e.ofType)):f(e)}function f(e){return u[e.name]}function h(e){return ct(e)||function(e){return Je.some((({name:t})=>e.name===t))}(e)?e:oe(e)?function(e){const t=e.toConfig(),n=i[t.name]??[];let r=t.specifiedByUrl;for(const e of n)r=Nn(e)??r;return new GraphQLScalarType({...t,specifiedByUrl:r,extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):se(e)?function(e){const t=e.toConfig(),n=i[t.name]??[];return new GraphQLObjectType({...t,interfaces:()=>[...e.getInterfaces().map(f),...O(n)],fields:()=>({...U(t.fields,m),...v(n)}),extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):ae(e)?function(e){const t=e.toConfig(),n=i[t.name]??[];return new GraphQLInterfaceType({...t,interfaces:()=>[...e.getInterfaces().map(f),...O(n)],fields:()=>({...U(t.fields,m),...v(n)}),extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):ce(e)?function(e){const t=e.toConfig(),n=i[t.name]??[];return new GraphQLUnionType({...t,types:()=>[...e.getTypes().map(f),...b(n)],extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):ue(e)?function(e){const t=e.toConfig(),n=i[e.name]??[];return new GraphQLEnumType({...t,values:{...t.values,..._(n)},extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):pe(e)?function(e){const t=e.toConfig(),n=i[t.name]??[];return new GraphQLInputObjectType({...t,fields:()=>({...U(t.fields,(e=>({...e,type:d(e.type)}))),...g(n)}),extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):void ne(0,"Unexpected type: "+l(e))}function m(e){return{...e,type:d(e.type),args:U(e.args,y)}}function y(e){return{...e,type:d(e.type)}}function E(e){const t={};for(const n of e){const e=n.operationTypes??[];for(const n of e)t[n.operation]=T(n.type)}return t}function T(e){const t=e.name.value,n=En[t]??u[t];if(void 0===n)throw new Error(`Unknown type: "${t}".`);return n}function N(e){return e.kind===c.LIST_TYPE?new GraphQLList(N(e.type)):e.kind===c.NON_NULL_TYPE?new GraphQLNonNull(N(e.type)):T(e)}function v(e){const t=Object.create(null);for(const n of e){const e=n.fields??[];for(const n of e)t[n.name.value]={type:N(n.type),description:n.description?.value,args:I(n.arguments),deprecationReason:Tn(n),astNode:n}}return t}function I(e){const t=e??[],n=Object.create(null);for(const e of t){const t=N(e.type);n[e.name.value]={type:t,description:e.description?.value,defaultValue:dn(e.defaultValue,t),deprecationReason:Tn(e),astNode:e}}return n}function g(e){const t=Object.create(null);for(const n of e){const e=n.fields??[];for(const n of e){const e=N(n.type);t[n.name.value]={type:e,description:n.description?.value,defaultValue:dn(n.defaultValue,e),deprecationReason:Tn(n),astNode:n}}}return t}function _(e){const t=Object.create(null);for(const n of e){const e=n.values??[];for(const n of e)t[n.name.value]={description:n.description?.value,deprecationReason:Tn(n),astNode:n}}return t}function O(e){const t=[];for(const n of e){const e=n.interfaces??[];for(const n of e)t.push(T(n))}return t}function b(e){const t=[];for(const n of e){const e=n.types??[];for(const n of e)t.push(T(n))}return t}function L(e){const t=e.name.value,n=i[t]??[];switch(e.kind){case c.OBJECT_TYPE_DEFINITION:{const r=n,i=[e,...r];return new GraphQLObjectType({name:t,description:e.description?.value,interfaces:()=>O(i),fields:()=>v(i),astNode:e,extensionASTNodes:r})}case c.INTERFACE_TYPE_DEFINITION:{const r=n,i=[e,...r];return new GraphQLInterfaceType({name:t,description:e.description?.value,interfaces:()=>O(i),fields:()=>v(i),astNode:e,extensionASTNodes:r})}case c.ENUM_TYPE_DEFINITION:{const r=n,i=[e,...r];return new GraphQLEnumType({name:t,description:e.description?.value,values:_(i),astNode:e,extensionASTNodes:r})}case c.UNION_TYPE_DEFINITION:{const r=n,i=[e,...r];return new GraphQLUnionType({name:t,description:e.description?.value,types:()=>b(i),astNode:e,extensionASTNodes:r})}case c.SCALAR_TYPE_DEFINITION:{const r=n;return new GraphQLScalarType({name:t,description:e.description?.value,specifiedByUrl:Nn(e),astNode:e,extensionASTNodes:r})}case c.INPUT_OBJECT_TYPE_DEFINITION:{const r=n,i=[e,...r];return new GraphQLInputObjectType({name:t,description:e.description?.value,fields:()=>g(i),astNode:e,extensionASTNodes:r})}}ne(0,"Unexpected type definition node: "+l(e))}}const En=V(Je.concat(at),(e=>e.name));function Tn(e){return hn(dt,e)?.reason}function Nn(e){return hn(ft,e)?.url}function vn(e,t){null!=e&&e.kind===c.DOCUMENT||f(0,"Must provide valid Document AST."),!0!==t?.assumeValid&&!0!==t?.assumeValidSDL&&function(e){const t=ln(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}(e);const n=yn({description:void 0,types:[],directives:[],extensions:void 0,extensionASTNodes:[],assumeValid:!1},e,t);if(null==n.astNode)for(const e of n.types)switch(e.name){case"Query":n.query=e;break;case"Mutation":n.mutation=e;break;case"Subscription":n.subscription=e}const{directives:r}=n;for(const e of ht)r.every((t=>t.name!==e.name))&&r.push(e);return new GraphQLSchema(n)}const In=[Ut],gn=[function(e){return{OperationDefinition:t=>(t.name||e.reportError(new GraphQLError("Apollo does not support anonymous operations because operation names are used during code generation. Please give this operation a name.",t)),!1)}},function(e){return{Field(t){"__typename"==(t.alias&&t.alias.value)&&e.reportError(new GraphQLError("Apollo needs to be able to insert __typename when needed, so using it as an alias is not supported.",t))}}},...cn.filter((e=>!In.includes(e)))];class GraphQLSchemaValidationError extends Error{constructor(e){super(e.map((e=>e.message)).join("\n\n")),this.validationErrors=e,this.name="GraphQLSchemaValidationError"}}function _n(e){const t=Et(e);if(0!==t.length)throw new GraphQLSchemaValidationError(t)}function On(e){return e.startsWith("__")}function bn(e){return null!=e}function Ln(e){switch(e.kind){case"Variable":return{kind:e.kind,value:e.name.value};case"ListValue":return{kind:e.kind,value:e.values.map(Ln)};case"ObjectValue":return{kind:e.kind,value:e.fields.reduce(((e,t)=>(e[t.name.value]=Ln(t.value),e)),{})};default:return e}}function Sn(e){var t,n;return null===(n=null===(t=e.loc)||void 0===t?void 0:t.source)||void 0===n?void 0:n.name}function An(e,t){const n=new Map;for(const e of t.definitions)e.kind===c.FRAGMENT_DEFINITION&&n.set(e.name.value,e);const r=[],i=new Map,o=new Set;for(const e of t.definitions)e.kind===c.OPERATION_DEFINITION&&r.push(s(e));for(const[e,t]of n.entries())i.set(e,a(t));return{operations:r,fragments:Array.from(i.values()),referencedTypes:Array.from(o.values())};function s(t){if(!t.name)throw new GraphQLError("Operations should be named",t);const n=Sn(t),r=t.name.value,i=t.operation,s=(t.variableDefinitions||[]).map((t=>{const n=t.variable.name.value,r=xt(e,t.type);if(!r)throw new GraphQLError(`Couldn't get type from type node "${t.type}"`,t);return o.add(ge(r)),{name:n,type:r}})),a=q(t),c=function(e,t){if("query"===t.operation){const n=e.getQueryType();if(!n)throw new GraphQLError("Schema does not define the required query root type.",t);return n}if("mutation"===t.operation){const n=e.getMutationType();if(!n)throw new GraphQLError("Schema is not configured for mutations.",t);return n}if("subscription"===t.operation){const n=e.getSubscriptionType();if(!n)throw new GraphQLError("Schema is not configured for subscriptions.",t);return n}throw new GraphQLError("Can only have query, mutation and subscription operations.",t)}(e,t);return{filePath:n,name:r,operationType:i,rootType:c,variables:s,source:a,selectionSet:u(t.selectionSet,c)}}function a(t){const n=t.name.value,r=Sn(t),i=q(t),o=xt(e,t.typeCondition);return{name:n,filePath:r,source:i,typeCondition:o,selectionSet:u(t.selectionSet,o)}}function u(t,r,s=new Set){return{parentType:r,selections:t.selections.map((t=>function(t,r,s){var p;switch(t.kind){case c.FIELD:{const n=t.name.value,i=null===(p=t.alias)||void 0===p?void 0:p.value,s=function(e,t,n){return n===it.name&&e.getQueryType()===t?it:n===ot.name&&e.getQueryType()===t?ot:n===st.name&&(se(t)||ae(t)||ce(t))?st:se(t)||ae(t)?t.getFields()[n]:void 0}(e,r,n);if(!s)throw new GraphQLError(`Cannot query field "${n}" on type "${String(r)}"`,t);const a=s.type,c=ge(a);o.add(c);const{description:l,deprecationReason:d}=s;let f={kind:"Field",name:n,alias:i,arguments:t.arguments&&t.arguments.length>0?t.arguments.map((e=>{const t=e.name.value,n=s.args.find((t=>t.name===e.name.value)),r=n&&n.type||void 0;return{name:t,value:Ln(e.value),type:r}})):void 0,type:a,description:!On(n)&&l?l:void 0,deprecationReason:d||void 0};if(ye(c)){const e=t.selectionSet;if(!e)throw new GraphQLError(`Composite field "${n}" on type "${String(r)}" requires selection set`,t);f.selectionSet=u(e,c)}return f}case c.INLINE_FRAGMENT:{const n=t.typeCondition,i=n?xt(e,n):r;return{kind:"InlineFragment",selectionSet:u(t.selectionSet,i)}}case c.FRAGMENT_SPREAD:{const e=t.name.value;if(s.has(e))return;s.add(e);const r=function(e){let t=i.get(e);if(t)return t;const r=n.get(e);return r?(n.delete(e),t=a(r),i.set(e,t),t):void 0}(e);if(!r)throw new GraphQLError(`Unknown fragment "${e}".`,t.name);return{kind:"FragmentSpread",fragment:r}}}}(t,r,s))).filter(bn)}}}return c.FIELD,c.NAME,e.GraphQLEnumType=GraphQLEnumType,e.GraphQLError=GraphQLError,e.GraphQLInputObjectType=GraphQLInputObjectType,e.GraphQLInterfaceType=GraphQLInterfaceType,e.GraphQLObjectType=GraphQLObjectType,e.GraphQLScalarType=GraphQLScalarType,e.GraphQLSchema=GraphQLSchema,e.GraphQLSchemaValidationError=GraphQLSchemaValidationError,e.GraphQLUnionType=GraphQLUnionType,e.Source=Source,e.compileDocument=function(e,t){return An(e,t)},e.loadSchemaFromIntrospectionResult=function(e){let t=JSON.parse(e);t.data&&(t=t.data);const n=mn(t);return _n(n),n},e.loadSchemaFromSDL=function(e){const t=A(e);!function(e){const t=ln(e);if(0!==t.length)throw new GraphQLSchemaValidationError(t)}(t);const n=vn(t,{assumeValidSDL:!0});return _n(n),n},e.mergeDocuments=function(e){return function(e){let t=[];for(const n of e)t=t.concat(n.definitions);return{kind:"Document",definitions:t}}(e)},e.parseDocument=function(e){return A(e)},e.validateDocument=function(e,t){return pn(e,t,gn)},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); +var ApolloCodegenFrontend=function(e){"use strict";function t(e){return"object"==typeof e&&null!==e}function n(e,t){const n=/\r\n|[\n\r]/g;let r,i=1,o=t+1;for(;(r=n.exec(e.body))&&r.index120){const e=Math.floor(p/80),t=p%80,n=[];for(let e=0;e["",e])),[" ",s(t-1)+"^"],["",n[e+1]]])}return l+o([[""+(c-1),d[i-1]],[`${c}`,f],["",s(p-1)+"^"],[`${c+1}`,d[i+1]]])}function o(e){const t=e.filter((([e,t])=>void 0!==t)),n=Math.max(...t.map((([e])=>e.length)));return t.map((([e,t])=>{return s(n-(r=e).length)+r+(t?" | "+t:" |");var r})).join("\n")}function s(e){return Array(e+1).join(" ")}class GraphQLError extends Error{constructor(e,r,i,o,s,a,c){super(e);const u=Array.isArray(r)?0!==r.length?r:void 0:r?[r]:void 0;let p=i;!p&&u&&(p=u[0].loc?.source);let l,d=o;!d&&u&&(d=u.reduce(((e,t)=>(t.loc&&e.push(t.loc.start),e)),[])),d&&0===d.length&&(d=void 0),o&&i?l=o.map((e=>n(i,e))):u&&(l=u.reduce(((e,t)=>(t.loc&&e.push(n(t.loc.source,t.loc.start)),e)),[]));let f=c;if(null==f&&null!=a){const e=a.extensions;t(e)&&(f=e)}Object.defineProperties(this,{name:{value:"GraphQLError"},message:{value:e,enumerable:!0,writable:!0},locations:{value:l??void 0,enumerable:null!=l},path:{value:s??void 0,enumerable:null!=s},nodes:{value:u??void 0},source:{value:p??void 0},positions:{value:d??void 0},originalError:{value:a},extensions:{value:f??void 0,enumerable:null!=f}}),a?.stack?Object.defineProperty(this,"stack",{value:a.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,GraphQLError):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}toString(){return function(e){let t=e.message;if(e.nodes)for(const n of e.nodes)n.loc&&(t+="\n\n"+r(n.loc));else if(e.source&&e.locations)for(const n of e.locations)t+="\n\n"+i(e.source,n);return t}(this)}get[Symbol.toStringTag](){return"Object"}}function a(e,t,n){return new GraphQLError(`Syntax Error: ${n}`,void 0,e,[t])}const c=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"});class Location{constructor(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}toJSON(){return{start:this.start,end:this.end}}[Symbol.for("nodejs.util.inspect.custom")](){return this.toJSON()}}class Token{constructor(e,t,n,r,i,o,s){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=s,this.prev=o,this.next=null}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}[Symbol.for("nodejs.util.inspect.custom")](){return this.toJSON()}}function u(e){return null!=e&&"string"==typeof e.kind}const p=Object.freeze({SOF:"",EOF:"",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function l(e){return d(e,[])}function d(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return null===e?"null":function(e,t){if(-1!==t.indexOf(e))return"[Circular]";const n=[...t,e];if("function"==typeof e.toJSON){const t=e.toJSON(e);if(t!==e)return"string"==typeof t?t:d(t,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>2)return"[Array]";const n=Math.min(10,e.length),r=e.length-n,i=[];for(let r=0;r1&&i.push(`... ${r} more items`);return"["+i.join(", ")+"]"}(e,n);return function(e,t){const n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";return"{ "+n.map((n=>n+": "+d(e[n],t))).join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}function f(e,t){if(!Boolean(e))throw new Error(t)}var h=function(e,t){return e instanceof t};class Source{constructor(e,t="GraphQL request",n={line:1,column:1}){"string"==typeof e||f(0,`Body must be a string. Received: ${l(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||f(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||f(0,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}const m=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function y(e){const t=e.split(/\r\n|[\n\r]/g),n=function(e){let t=!0,n=!0,r=0,i=null;for(let o=0;or&&E(t[i-1]);)--i;return t.slice(r,i).join("\n")}function E(e){for(let t=0;t31||9===s));return new Token(p.COMMENT,t,a,n,r,i,o.slice(t+1,a))}function _(e,t,n,r,i,o){const s=e.body;let c=n,u=t,l=!1;if(45===c&&(c=s.charCodeAt(++u)),48===c){if(c=s.charCodeAt(++u),c>=48&&c<=57)throw a(e,u,`Invalid number, unexpected digit after 0: ${N(c)}.`)}else u=O(e,u,c),c=s.charCodeAt(u);if(46===c&&(l=!0,c=s.charCodeAt(++u),u=O(e,u,c),c=s.charCodeAt(u)),69!==c&&101!==c||(l=!0,c=s.charCodeAt(++u),43!==c&&45!==c||(c=s.charCodeAt(++u)),u=O(e,u,c),c=s.charCodeAt(u)),46===c||function(e){return 95===e||e>=65&&e<=90||e>=97&&e<=122}(c))throw a(e,u,`Invalid number, expected digit but got: ${N(c)}.`);return new Token(l?p.FLOAT:p.INT,t,u,r,i,o,s.slice(t,u))}function O(e,t,n){const r=e.body;let i=t,o=n;if(o>=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw a(e,i,`Invalid number, expected digit but got: ${N(o)}.`)}function b(e,t,n,r,i){const o=e.body;let s=t+1,c=s,u=0,l="";for(;s=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function A(e,t,n,r,i){const o=e.body,s=o.length;let a=t+1,c=0;for(;a!==s&&!isNaN(c=o.charCodeAt(a))&&(95===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122);)++a;return new Token(p.NAME,t,a,n,r,i,o.slice(t,a))}function D(e,t){return new Parser(e,t).parseDocument()}class Parser{constructor(e,t){const n=function(e){return h(e,Source)}(e)?e:new Source(e);this._lexer=new Lexer(n),this._options=t}parseName(){const e=this.expectToken(p.NAME);return{kind:c.NAME,value:e.value,loc:this.loc(e)}}parseDocument(){const e=this._lexer.token;return{kind:c.DOCUMENT,definitions:this.many(p.SOF,this.parseDefinition,p.EOF),loc:this.loc(e)}}parseDefinition(){if(this.peek(p.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(p.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(p.BRACE_L))return{kind:c.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};const t=this.parseOperationType();let n;return this.peek(p.NAME)&&(n=this.parseName()),{kind:c.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}}parseOperationType(){const e=this.expectToken(p.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(p.PAREN_L,this.parseVariableDefinition,p.PAREN_R)}parseVariableDefinition(){const e=this._lexer.token;return{kind:c.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(p.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(p.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}}parseVariable(){const e=this._lexer.token;return this.expectToken(p.DOLLAR),{kind:c.VARIABLE,name:this.parseName(),loc:this.loc(e)}}parseSelectionSet(){const e=this._lexer.token;return{kind:c.SELECTION_SET,selections:this.many(p.BRACE_L,this.parseSelection,p.BRACE_R),loc:this.loc(e)}}parseSelection(){return this.peek(p.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(p.COLON)?(n=t,r=this.parseName()):r=t,{kind:c.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(p.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(e)}}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(p.PAREN_L,t,p.PAREN_R)}parseArgument(){const e=this._lexer.token,t=this.parseName();return this.expectToken(p.COLON),{kind:c.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}}parseConstArgument(){const e=this._lexer.token;return{kind:c.ARGUMENT,name:this.parseName(),value:(this.expectToken(p.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}}parseFragment(){const e=this._lexer.token;this.expectToken(p.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(p.NAME)?{kind:c.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:c.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}}parseFragmentDefinition(){const e=this._lexer.token;return this.expectKeyword("fragment"),!0===this._options?.experimentalFragmentVariables?{kind:c.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:c.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}}parseFragmentName(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()}parseValueLiteral(e){const t=this._lexer.token;switch(t.kind){case p.BRACKET_L:return this.parseList(e);case p.BRACE_L:return this.parseObject(e);case p.INT:return this._lexer.advance(),{kind:c.INT,value:t.value,loc:this.loc(t)};case p.FLOAT:return this._lexer.advance(),{kind:c.FLOAT,value:t.value,loc:this.loc(t)};case p.STRING:case p.BLOCK_STRING:return this.parseStringLiteral();case p.NAME:switch(this._lexer.advance(),t.value){case"true":return{kind:c.BOOLEAN,value:!0,loc:this.loc(t)};case"false":return{kind:c.BOOLEAN,value:!1,loc:this.loc(t)};case"null":return{kind:c.NULL,loc:this.loc(t)};default:return{kind:c.ENUM,value:t.value,loc:this.loc(t)}}case p.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()}parseStringLiteral(){const e=this._lexer.token;return this._lexer.advance(),{kind:c.STRING,value:e.value,block:e.kind===p.BLOCK_STRING,loc:this.loc(e)}}parseList(e){const t=this._lexer.token;return{kind:c.LIST,values:this.any(p.BRACKET_L,(()=>this.parseValueLiteral(e)),p.BRACKET_R),loc:this.loc(t)}}parseObject(e){const t=this._lexer.token;return{kind:c.OBJECT,fields:this.any(p.BRACE_L,(()=>this.parseObjectField(e)),p.BRACE_R),loc:this.loc(t)}}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(p.COLON),{kind:c.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}}parseDirectives(e){const t=[];for(;this.peek(p.AT);)t.push(this.parseDirective(e));return t}parseDirective(e){const t=this._lexer.token;return this.expectToken(p.AT),{kind:c.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}}parseTypeReference(){const e=this._lexer.token;let t;return this.expectOptionalToken(p.BRACKET_L)?(t=this.parseTypeReference(),this.expectToken(p.BRACKET_R),t={kind:c.LIST_TYPE,type:t,loc:this.loc(e)}):t=this.parseNamedType(),this.expectOptionalToken(p.BANG)?{kind:c.NON_NULL_TYPE,type:t,loc:this.loc(e)}:t}parseNamedType(){const e=this._lexer.token;return{kind:c.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}}parseTypeSystemDefinition(){const e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===p.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)}peekDescription(){return this.peek(p.STRING)||this.peek(p.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");const n=this.parseDirectives(!0),r=this.many(p.BRACE_L,this.parseOperationTypeDefinition,p.BRACE_R);return{kind:c.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r,loc:this.loc(e)}}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(p.COLON);const n=this.parseNamedType();return{kind:c.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}}parseScalarTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");const n=this.parseName(),r=this.parseDirectives(!0);return{kind:c.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}}parseObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:c.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(p.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(p.BRACE_L,this.parseFieldDefinition,p.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(p.COLON);const i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:c.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}}parseArgumentDefs(){return this.optionalMany(p.PAREN_L,this.parseInputValueDef,p.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(p.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(p.EQUALS)&&(i=this.parseValueLiteral(!0));const o=this.parseDirectives(!0);return{kind:c.INPUT_VALUE_DEFINITION,description:t,name:n,type:r,defaultValue:i,directives:o,loc:this.loc(e)}}parseInterfaceTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:c.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}}parseUnionTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");const n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:c.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}}parseUnionMemberTypes(){return this.expectOptionalToken(p.EQUALS)?this.delimitedMany(p.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");const n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:c.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}}parseEnumValuesDefinition(){return this.optionalMany(p.BRACE_L,this.parseEnumValueDefinition,p.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:c.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}}parseInputObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");const n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:c.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}}parseInputFieldsDefinition(){return this.optionalMany(p.BRACE_L,this.parseInputValueDef,p.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===p.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)}parseSchemaExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const t=this.parseDirectives(!0),n=this.optionalMany(p.BRACE_L,this.parseOperationTypeDefinition,p.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:c.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:c.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:c.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:c.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:c.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:c.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:c.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(p.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const o=this.parseDirectiveLocations();return{kind:c.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}}parseDirectiveLocations(){return this.delimitedMany(p.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(void 0!==m[t.value])return t;throw this.unexpected(e)}loc(e){if(!0!==this._options?.noLocation)return new Location(e,this._lexer.lastToken,this._lexer.source)}peek(e){return this._lexer.token.kind===e}expectToken(e){const t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw a(this._lexer.source,t.start,`Expected ${k(e)}, found ${w(t)}.`)}expectOptionalToken(e){const t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t}expectKeyword(e){const t=this._lexer.token;if(t.kind!==p.NAME||t.value!==e)throw a(this._lexer.source,t.start,`Expected "${e}", found ${w(t)}.`);this._lexer.advance()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===p.NAME&&t.value===e&&(this._lexer.advance(),!0)}unexpected(e){const t=e??this._lexer.token;return a(this._lexer.source,t.start,`Unexpected ${w(t)}.`)}any(e,t,n){this.expectToken(e);const r=[];for(;!this.expectOptionalToken(n);)r.push(t.call(this));return r}optionalMany(e,t,n){if(this.expectOptionalToken(e)){const e=[];do{e.push(t.call(this))}while(!this.expectOptionalToken(n));return e}return[]}many(e,t,n){this.expectToken(e);const r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}delimitedMany(e,t){this.expectOptionalToken(e);const n=[];do{n.push(t.call(this))}while(this.expectOptionalToken(e));return n}}function w(e){const t=e.value;return k(e.kind)+(null!=t?` "${t}"`:"")}function k(e){return function(e){return e===p.BANG||e===p.DOLLAR||e===p.AMP||e===p.PAREN_L||e===p.PAREN_R||e===p.SPREAD||e===p.COLON||e===p.EQUALS||e===p.AT||e===p.BRACKET_L||e===p.BRACKET_R||e===p.BRACE_L||e===p.PIPE||e===p.BRACE_R}(e)?`"${e}"`:e}const x={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},F=Object.freeze({});function R(e,t,n=x){let r,i,o,s,a=Array.isArray(e),c=[e],p=-1,d=[];const f=[],h=[];let m=e;do{p++;const e=p===c.length,y=e&&0!==d.length;if(e){if(o=0===h.length?void 0:f[f.length-1],i=s,s=h.pop(),y){if(a)i=i.slice();else{const e={};for(const t of Object.keys(i))e[t]=i[t];i=e}let e=0;for(let t=0;tObject.keys(e).map((t=>e[t])));const Q=/^[_a-zA-Z][_a-zA-Z0-9]*$/;const V=Object.entries||(e=>Object.keys(e).map((t=>[t,e[t]])));function U(e,t){return e.reduce(((e,n)=>(e[t(n)]=n,e)),Object.create(null))}function j(e,t){const n=Object.create(null);for(const[r,i]of V(e))n[r]=t(i,r);return n}function M(e){if(null===Object.getPrototypeOf(e))return e;const t=Object.create(null);for(const[n,r]of V(e))t[n]=r;return t}function P(e,t,n){return e.reduce(((e,r)=>(e[t(r)]=n(r),e)),Object.create(null))}function B(e,t){const[n,r]="string"==typeof e?[e,t]:[void 0,e];let i=" Did you mean ";n&&(i+=n+" ");const o=r.map((e=>`"${e}"`));switch(o.length){case 0:return"";case 1:return i+o[0]+"?";case 2:return i+o[0]+" or "+o[1]+"?"}const s=o.slice(0,5),a=s.pop();return i+s.join(", ")+", or "+a+"?"}function Y(e){return e}function J(e,t){const n=Object.create(null),r=new LexicalDistance(e),i=Math.floor(.4*e.length)+1;for(const e of t){const t=r.measure(e,i);void 0!==t&&(n[e]=t)}return Object.keys(n).sort(((e,t)=>{const r=n[e]-n[t];return 0!==r?r:e.localeCompare(t)}))}class LexicalDistance{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=q(this._inputLowerCase),this._rows=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)]}measure(e,t){if(this._input===e)return 0;const n=e.toLowerCase();if(this._inputLowerCase===n)return 1;let r=q(n),i=this._inputArray;if(r.lengtht)return;const a=this._rows;for(let e=0;e<=s;e++)a[0][e]=e;for(let e=1;e<=o;e++){const n=a[(e-1)%3],o=a[e%3];let c=o[0]=e;for(let t=1;t<=s;t++){const s=r[e-1]===i[t-1]?0:1;let u=Math.min(n[t]+1,o[t-1]+1,n[t-1]+s);if(e>1&&t>1&&r[e-1]===i[t-2]&&r[e-2]===i[t-1]){const n=a[(e-2)%3][t-2];u=Math.min(u,n+1)}ut)return}const c=a[o%3][s];return c<=t?c:void 0}}function q(e){const t=e.length,n=new Array(t);for(let r=0;re.value,Variable:e=>"$"+e.name,Document:e=>H(e.definitions,"\n\n")+"\n",OperationDefinition(e){const t=e.operation,n=e.name,r=W("(",H(e.variableDefinitions,", "),")"),i=H(e.directives," "),o=e.selectionSet;return n||i||r||"query"!==t?H([t,H([n,r]),i,o]," "):o},VariableDefinition:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+W(" = ",n)+W(" ",H(r," ")),SelectionSet:({selections:e})=>Z(e),Field:({alias:e,name:t,arguments:n,directives:r,selectionSet:i})=>{const o=W("",e,": ")+t;let s=o+W("(",H(n,", "),")");return s.length>80&&(s=o+W("(\n",ee(H(n,"\n")),"\n)")),H([s,H(r," "),i]," ")},Argument:({name:e,value:t})=>e+": "+t,FragmentSpread:({name:e,directives:t})=>"..."+e+W(" ",H(t," ")),InlineFragment:({typeCondition:e,directives:t,selectionSet:n})=>H(["...",W("on ",e),H(t," "),n]," "),FragmentDefinition:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${W("(",H(n,", "),")")} on ${t} ${W("",H(r," ")," ")}`+i,IntValue:({value:e})=>e,FloatValue:({value:e})=>e,StringValue:({value:e,block:t},n)=>t?T(e,"description"===n?"":" "):JSON.stringify(e),BooleanValue:({value:e})=>e?"true":"false",NullValue:()=>"null",EnumValue:({value:e})=>e,ListValue:({values:e})=>"["+H(e,", ")+"]",ObjectValue:({fields:e})=>"{"+H(e,", ")+"}",ObjectField:({name:e,value:t})=>e+": "+t,Directive:({name:e,arguments:t})=>"@"+e+W("(",H(t,", "),")"),NamedType:({name:e})=>e,ListType:({type:e})=>"["+e+"]",NonNullType:({type:e})=>e+"!",SchemaDefinition:z((({directives:e,operationTypes:t})=>H(["schema",H(e," "),Z(t)]," "))),OperationTypeDefinition:({operation:e,type:t})=>e+": "+t,ScalarTypeDefinition:z((({name:e,directives:t})=>H(["scalar",e,H(t," ")]," "))),ObjectTypeDefinition:z((({name:e,interfaces:t,directives:n,fields:r})=>H(["type",e,W("implements ",H(t," & ")),H(n," "),Z(r)]," "))),FieldDefinition:z((({name:e,arguments:t,type:n,directives:r})=>e+(ne(t)?W("(\n",ee(H(t,"\n")),"\n)"):W("(",H(t,", "),")"))+": "+n+W(" ",H(r," ")))),InputValueDefinition:z((({name:e,type:t,defaultValue:n,directives:r})=>H([e+": "+t,W("= ",n),H(r," ")]," "))),InterfaceTypeDefinition:z((({name:e,interfaces:t,directives:n,fields:r})=>H(["interface",e,W("implements ",H(t," & ")),H(n," "),Z(r)]," "))),UnionTypeDefinition:z((({name:e,directives:t,types:n})=>H(["union",e,H(t," "),n&&0!==n.length?"= "+H(n," | "):""]," "))),EnumTypeDefinition:z((({name:e,directives:t,values:n})=>H(["enum",e,H(t," "),Z(n)]," "))),EnumValueDefinition:z((({name:e,directives:t})=>H([e,H(t," ")]," "))),InputObjectTypeDefinition:z((({name:e,directives:t,fields:n})=>H(["input",e,H(t," "),Z(n)]," "))),DirectiveDefinition:z((({name:e,arguments:t,repeatable:n,locations:r})=>"directive @"+e+(ne(t)?W("(\n",ee(H(t,"\n")),"\n)"):W("(",H(t,", "),")"))+(n?" repeatable":"")+" on "+H(r," | "))),SchemaExtension:({directives:e,operationTypes:t})=>H(["extend schema",H(e," "),Z(t)]," "),ScalarTypeExtension:({name:e,directives:t})=>H(["extend scalar",e,H(t," ")]," "),ObjectTypeExtension:({name:e,interfaces:t,directives:n,fields:r})=>H(["extend type",e,W("implements ",H(t," & ")),H(n," "),Z(r)]," "),InterfaceTypeExtension:({name:e,interfaces:t,directives:n,fields:r})=>H(["extend interface",e,W("implements ",H(t," & ")),H(n," "),Z(r)]," "),UnionTypeExtension:({name:e,directives:t,types:n})=>H(["extend union",e,H(t," "),n&&0!==n.length?"= "+H(n," | "):""]," "),EnumTypeExtension:({name:e,directives:t,values:n})=>H(["extend enum",e,H(t," "),Z(n)]," "),InputObjectTypeExtension:({name:e,directives:t,fields:n})=>H(["extend input",e,H(t," "),Z(n)]," ")};function z(e){return t=>H([t.description,e(t)],"\n")}function H(e,t=""){return e?.filter((e=>e)).join(t)??""}function Z(e){return W("{\n",ee(H(e,"\n")),"\n}")}function W(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function ee(e){return W(" ",e.replace(/\n/g,"\n "))}function te(e){return-1!==e.indexOf("\n")}function ne(e){return null!=e&&e.some(te)}function re(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}function ie(e,t){switch(e.kind){case c.NULL:return null;case c.INT:return parseInt(e.value,10);case c.FLOAT:return parseFloat(e.value);case c.STRING:case c.ENUM:case c.BOOLEAN:return e.value;case c.LIST:return e.values.map((e=>ie(e,t)));case c.OBJECT:return P(e.fields,(e=>e.name.value),(e=>ie(e.value,t)));case c.VARIABLE:return t?.[e.name.value]}re(0,"Unexpected value node: "+l(e))}function oe(e){return se(e)||ae(e)||ce(e)||ue(e)||pe(e)||le(e)||de(e)||fe(e)}function se(e){return h(e,GraphQLScalarType)}function ae(e){return h(e,GraphQLObjectType)}function ce(e){return h(e,GraphQLInterfaceType)}function ue(e){return h(e,GraphQLUnionType)}function pe(e){return h(e,GraphQLEnumType)}function le(e){return h(e,GraphQLInputObjectType)}function de(e){return h(e,GraphQLList)}function fe(e){return h(e,GraphQLNonNull)}function he(e){return se(e)||pe(e)||le(e)||Ne(e)&&he(e.ofType)}function me(e){return se(e)||ae(e)||ce(e)||ue(e)||pe(e)||Ne(e)&&me(e.ofType)}function ye(e){return se(e)||pe(e)}function Ee(e){return ae(e)||ce(e)||ue(e)}function Te(e){return ce(e)||ue(e)}class GraphQLList{constructor(e){oe(e)||f(0,`Expected ${l(e)} to be a GraphQL type.`),this.ofType=e}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLList"}}class GraphQLNonNull{constructor(e){ve(e)||f(0,`Expected ${l(e)} to be a GraphQL nullable type.`),this.ofType=e}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLNonNull"}}function Ne(e){return de(e)||fe(e)}function ve(e){return oe(e)&&!fe(e)}function Ie(e){if(e)return fe(e)?e.ofType:e}function ge(e){return se(e)||ae(e)||ce(e)||ue(e)||pe(e)||le(e)}function _e(e){if(e){let t=e;for(;Ne(t);)t=t.ofType;return t}}function Oe(e){return"function"==typeof e?e():e}function be(e){return e&&e.length>0?e:void 0}class GraphQLScalarType{constructor(e){const t=e.parseValue??Y;this.name=e.name,this.description=e.description,this.specifiedByUrl=e.specifiedByUrl,this.serialize=e.serialize??Y,this.parseValue=t,this.parseLiteral=e.parseLiteral??((e,n)=>t(ie(e,n))),this.extensions=e.extensions&&M(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=be(e.extensionASTNodes),"string"==typeof e.name||f(0,"Must provide name."),null==e.specifiedByUrl||"string"==typeof e.specifiedByUrl||f(0,`${this.name} must provide "specifiedByUrl" as a string, but got: ${l(e.specifiedByUrl)}.`),null==e.serialize||"function"==typeof e.serialize||f(0,`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`),e.parseLiteral&&("function"==typeof e.parseValue&&"function"==typeof e.parseLiteral||f(0,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`))}toConfig(){return{name:this.name,description:this.description,specifiedByUrl:this.specifiedByUrl,serialize:this.serialize,parseValue:this.parseValue,parseLiteral:this.parseLiteral,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLScalarType"}}class GraphQLObjectType{constructor(e){this.name=e.name,this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=e.extensions&&M(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=be(e.extensionASTNodes),this._fields=Se.bind(void 0,e),this._interfaces=Le.bind(void 0,e),"string"==typeof e.name||f(0,"Must provide name."),null==e.isTypeOf||"function"==typeof e.isTypeOf||f(0,`${this.name} must provide "isTypeOf" as a function, but got: ${l(e.isTypeOf)}.`)}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:De(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes||[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLObjectType"}}function Le(e){const t=Oe(e.interfaces)??[];return Array.isArray(t)||f(0,`${e.name} interfaces must be an Array or a function which returns an Array.`),t}function Se(e){const t=Oe(e.fields);return Ae(t)||f(0,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),j(t,((t,n)=>{Ae(t)||f(0,`${e.name}.${n} field config must be an object.`),null==t.resolve||"function"==typeof t.resolve||f(0,`${e.name}.${n} field resolver must be a function if provided, but got: ${l(t.resolve)}.`);const r=t.args??{};Ae(r)||f(0,`${e.name}.${n} args must be an object with argument names as keys.`);const i=V(r).map((([e,t])=>({name:e,description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:t.extensions&&M(t.extensions),astNode:t.astNode})));return{name:n,description:t.description,type:t.type,args:i,resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:t.extensions&&M(t.extensions),astNode:t.astNode}}))}function Ae(e){return t(e)&&!Array.isArray(e)}function De(e){return j(e,(e=>({description:e.description,type:e.type,args:we(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function we(e){return P(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function ke(e){return fe(e.type)&&void 0===e.defaultValue}class GraphQLInterfaceType{constructor(e){this.name=e.name,this.description=e.description,this.resolveType=e.resolveType,this.extensions=e.extensions&&M(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=be(e.extensionASTNodes),this._fields=Se.bind(void 0,e),this._interfaces=Le.bind(void 0,e),"string"==typeof e.name||f(0,"Must provide name."),null==e.resolveType||"function"==typeof e.resolveType||f(0,`${this.name} must provide "resolveType" as a function, but got: ${l(e.resolveType)}.`)}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:De(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}}class GraphQLUnionType{constructor(e){this.name=e.name,this.description=e.description,this.resolveType=e.resolveType,this.extensions=e.extensions&&M(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=be(e.extensionASTNodes),this._types=xe.bind(void 0,e),"string"==typeof e.name||f(0,"Must provide name."),null==e.resolveType||"function"==typeof e.resolveType||f(0,`${this.name} must provide "resolveType" as a function, but got: ${l(e.resolveType)}.`)}getTypes(){return"function"==typeof this._types&&(this._types=this._types()),this._types}toConfig(){return{name:this.name,description:this.description,types:this.getTypes(),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLUnionType"}}function xe(e){const t=Oe(e.types);return Array.isArray(t)||f(0,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class GraphQLEnumType{constructor(e){var t,n;this.name=e.name,this.description=e.description,this.extensions=e.extensions&&M(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=be(e.extensionASTNodes),this._values=(t=this.name,Ae(n=e.values)||f(0,`${t} values must be an object with value names as keys.`),V(n).map((([e,n])=>(Ae(n)||f(0,`${t}.${e} must refer to an object with a "value" key representing an internal value but got: ${l(n)}.`),{name:e,description:n.description,value:void 0!==n.value?n.value:e,deprecationReason:n.deprecationReason,extensions:n.extensions&&M(n.extensions),astNode:n.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=U(this._values,(e=>e.name)),"string"==typeof e.name||f(0,"Must provide name.")}getValues(){return this._values}getValue(e){return this._nameLookup[e]}serialize(e){const t=this._valueLookup.get(e);if(void 0===t)throw new GraphQLError(`Enum "${this.name}" cannot represent value: ${l(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=l(e);throw new GraphQLError(`Enum "${this.name}" cannot represent non-string value: ${t}.`+Fe(this,t))}const t=this.getValue(e);if(null==t)throw new GraphQLError(`Value "${e}" does not exist in "${this.name}" enum.`+Fe(this,e));return t.value}parseLiteral(e,t){if(e.kind!==c.ENUM){const t=K(e);throw new GraphQLError(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+Fe(this,t),e)}const n=this.getValue(e.value);if(null==n){const t=K(e);throw new GraphQLError(`Value "${t}" does not exist in "${this.name}" enum.`+Fe(this,t),e)}return n.value}toConfig(){const e=P(this.getValues(),(e=>e.name),(e=>({description:e.description,value:e.value,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,values:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLEnumType"}}function Fe(e,t){return B("the enum value",J(t,e.getValues().map((e=>e.name))))}class GraphQLInputObjectType{constructor(e){this.name=e.name,this.description=e.description,this.extensions=e.extensions&&M(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=be(e.extensionASTNodes),this._fields=Re.bind(void 0,e),"string"==typeof e.name||f(0,"Must provide name.")}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=j(this.getFields(),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,fields:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[]}}toString(){return this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}}function Re(e){const t=Oe(e.fields);return Ae(t)||f(0,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),j(t,((t,n)=>(!("resolve"in t)||f(0,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:n,description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:t.extensions&&M(t.extensions),astNode:t.astNode})))}function Ge(e){return fe(e.type)&&void 0===e.defaultValue}function $e(e,t){return e===t||(fe(e)&&fe(t)||!(!de(e)||!de(t)))&&$e(e.ofType,t.ofType)}function Ce(e,t,n){return t===n||(fe(n)?!!fe(t)&&Ce(e,t.ofType,n.ofType):fe(t)?Ce(e,t.ofType,n):de(n)?!!de(t)&&Ce(e,t.ofType,n.ofType):!de(t)&&(Te(n)&&(ce(t)||ae(t))&&e.isSubType(n,t)))}function Qe(e,t,n){return t===n||(Te(t)?Te(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!Te(n)&&e.isSubType(n,t))}const Ve=2147483647,Ue=-2147483648;const je=new GraphQLScalarType({name:"Int",description:"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",serialize:function(e){const t=Pe(e);if("boolean"==typeof t)return t?1:0;let n=t;if("string"==typeof t&&""!==t&&(n=Number(t)),"number"!=typeof n||!Number.isInteger(n))throw new GraphQLError(`Int cannot represent non-integer value: ${l(t)}`);if(n>Ve||nVe||eVe||te.name===t))}function Xe(e,n){if(fe(n)){const t=Xe(e,n.ofType);return t?.kind===c.NULL?null:t}if(null===e)return{kind:c.NULL};if(void 0===e)return null;if(de(n)){const t=n.ofType;if(function(e){if(null==e||"object"!=typeof e)return!1;const t=e.length;return"number"==typeof t&&t>=0&&t%1==0||"function"==typeof e[Symbol.iterator]}(e)){const n=[];for(const r of Array.from(e)){const e=Xe(r,t);null!=e&&n.push(e)}return{kind:c.LIST,values:n}}return Xe(e,t)}if(le(n)){if(!t(e))return null;const r=[];for(const t of C(n.getFields())){const n=Xe(e[t.name],t.type);n&&r.push({kind:c.OBJECT_FIELD,name:{kind:c.NAME,value:t.name},value:n})}return{kind:c.OBJECT,fields:r}}if(ye(n)){const t=n.serialize(e);if(null==t)return null;if("boolean"==typeof t)return{kind:c.BOOLEAN,value:t};if("number"==typeof t&&Number.isFinite(t)){const e=String(t);return ze.test(e)?{kind:c.INT,value:e}:{kind:c.FLOAT,value:e}}if("string"==typeof t)return pe(n)?{kind:c.ENUM,value:t}:n===Je&&ze.test(t)?{kind:c.INT,value:t}:{kind:c.STRING,value:t};throw new TypeError(`Cannot convert value to AST: ${l(t)}.`)}re(0,"Unexpected input type: "+l(n))}const ze=/^-?(?:0|[1-9][0-9]*)$/,He=new GraphQLObjectType({name:"__Schema",description:"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",fields:()=>({description:{type:Be,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(et))),resolve:e=>C(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new GraphQLNonNull(et),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:et,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:et,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(Ze))),resolve:e=>e.getDirectives()}})}),Ze=new GraphQLObjectType({name:"__Directive",description:"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.",fields:()=>({name:{type:new GraphQLNonNull(Be),resolve:e=>e.name},description:{type:Be,resolve:e=>e.description},isRepeatable:{type:new GraphQLNonNull(Ye),resolve:e=>e.isRepeatable},locations:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(We))),resolve:e=>e.locations},args:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(nt))),resolve:e=>e.args}})}),We=new GraphQLEnumType({name:"__DirectiveLocation",description:"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",values:{QUERY:{value:m.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:m.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:m.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:m.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:m.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:m.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:m.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:m.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:m.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:m.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:m.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:m.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:m.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:m.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:m.UNION,description:"Location adjacent to a union definition."},ENUM:{value:m.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:m.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:m.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:m.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),et=new GraphQLObjectType({name:"__Type",description:"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByUrl`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",fields:()=>({kind:{type:new GraphQLNonNull(ot),resolve:e=>se(e)?it.SCALAR:ae(e)?it.OBJECT:ce(e)?it.INTERFACE:ue(e)?it.UNION:pe(e)?it.ENUM:le(e)?it.INPUT_OBJECT:de(e)?it.LIST:fe(e)?it.NON_NULL:void re(0,`Unexpected type: "${l(e)}".`)},name:{type:Be,resolve:e=>void 0!==e.name?e.name:void 0},description:{type:Be,resolve:e=>void 0!==e.description?e.description:void 0},specifiedByUrl:{type:Be,resolve:e=>void 0!==e.specifiedByUrl?e.specifiedByUrl:void 0},fields:{type:new GraphQLList(new GraphQLNonNull(tt)),args:{includeDeprecated:{type:Ye,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(ae(e)||ce(e)){const n=C(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new GraphQLList(new GraphQLNonNull(et)),resolve(e){if(ae(e)||ce(e))return e.getInterfaces()}},possibleTypes:{type:new GraphQLList(new GraphQLNonNull(et)),resolve(e,t,n,{schema:r}){if(Te(e))return r.getPossibleTypes(e)}},enumValues:{type:new GraphQLList(new GraphQLNonNull(rt)),args:{includeDeprecated:{type:Ye,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(pe(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new GraphQLList(new GraphQLNonNull(nt)),args:{includeDeprecated:{type:Ye,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(le(e)){const n=C(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:et,resolve:e=>void 0!==e.ofType?e.ofType:void 0}})}),tt=new GraphQLObjectType({name:"__Field",description:"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",fields:()=>({name:{type:new GraphQLNonNull(Be),resolve:e=>e.name},description:{type:Be,resolve:e=>e.description},args:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(nt))),args:{includeDeprecated:{type:Ye,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new GraphQLNonNull(et),resolve:e=>e.type},isDeprecated:{type:new GraphQLNonNull(Ye),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Be,resolve:e=>e.deprecationReason}})}),nt=new GraphQLObjectType({name:"__InputValue",description:"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",fields:()=>({name:{type:new GraphQLNonNull(Be),resolve:e=>e.name},description:{type:Be,resolve:e=>e.description},type:{type:new GraphQLNonNull(et),resolve:e=>e.type},defaultValue:{type:Be,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=Xe(n,t);return r?K(r):null}},isDeprecated:{type:new GraphQLNonNull(Ye),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Be,resolve:e=>e.deprecationReason}})}),rt=new GraphQLObjectType({name:"__EnumValue",description:"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",fields:()=>({name:{type:new GraphQLNonNull(Be),resolve:e=>e.name},description:{type:Be,resolve:e=>e.description},isDeprecated:{type:new GraphQLNonNull(Ye),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Be,resolve:e=>e.deprecationReason}})}),it=Object.freeze({SCALAR:"SCALAR",OBJECT:"OBJECT",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",INPUT_OBJECT:"INPUT_OBJECT",LIST:"LIST",NON_NULL:"NON_NULL"}),ot=new GraphQLEnumType({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:it.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:it.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:it.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:it.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:it.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:it.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:it.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:it.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),st={name:"__schema",type:new GraphQLNonNull(He),description:"Access the current type schema of this server.",args:[],resolve:(e,t,n,{schema:r})=>r,deprecationReason:void 0,extensions:void 0,astNode:void 0},at={name:"__type",type:et,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new GraphQLNonNull(Be),defaultValue:void 0,deprecationReason:void 0,extensions:void 0,astNode:void 0}],resolve:(e,{name:t},n,{schema:r})=>r.getType(t),deprecationReason:void 0,extensions:void 0,astNode:void 0},ct={name:"__typename",type:new GraphQLNonNull(Be),description:"The name of the current Object type at runtime.",args:[],resolve:(e,t,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:void 0,astNode:void 0},ut=Object.freeze([He,Ze,We,et,tt,nt,rt,ot]);function pt(e){return ut.some((({name:t})=>e.name===t))}function lt(e){return h(e,GraphQLDirective)}class GraphQLDirective{constructor(e){this.name=e.name,this.description=e.description,this.locations=e.locations,this.isRepeatable=e.isRepeatable??!1,this.extensions=e.extensions&&M(e.extensions),this.astNode=e.astNode,e.name||f(0,"Directive must be named."),Array.isArray(e.locations)||f(0,`@${e.name} locations must be an Array.`);const n=e.args??{};t(n)&&!Array.isArray(n)||f(0,`@${e.name} args must be an object with argument names as keys.`),this.args=V(n).map((([e,t])=>({name:e,description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:t.extensions&&M(t.extensions),astNode:t.astNode})))}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:we(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}get[Symbol.toStringTag](){return"GraphQLDirective"}}const dt=new GraphQLDirective({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[m.FIELD,m.FRAGMENT_SPREAD,m.INLINE_FRAGMENT],args:{if:{type:new GraphQLNonNull(Ye),description:"Included when true."}}}),ft=new GraphQLDirective({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[m.FIELD,m.FRAGMENT_SPREAD,m.INLINE_FRAGMENT],args:{if:{type:new GraphQLNonNull(Ye),description:"Skipped when true."}}}),ht="No longer supported",mt=new GraphQLDirective({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[m.FIELD_DEFINITION,m.ARGUMENT_DEFINITION,m.INPUT_FIELD_DEFINITION,m.ENUM_VALUE],args:{reason:{type:Be,description:"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",defaultValue:ht}}}),yt=new GraphQLDirective({name:"specifiedBy",description:"Exposes a URL that specifies the behaviour of this scalar.",locations:[m.SCALAR],args:{url:{type:new GraphQLNonNull(Be),description:"The URL that specifies the behaviour of this scalar."}}}),Et=Object.freeze([dt,ft,mt,yt]);function Tt(e){if(!function(e){return h(e,GraphQLSchema)}(e))throw new Error(`Expected ${l(e)} to be a GraphQL schema.`);return e}class GraphQLSchema{constructor(e){this.__validationErrors=!0===e.assumeValid?[]:void 0,t(e)||f(0,"Must provide configuration object."),!e.types||Array.isArray(e.types)||f(0,`"types" must be Array if provided but got: ${l(e.types)}.`),!e.directives||Array.isArray(e.directives)||f(0,`"directives" must be Array if provided but got: ${l(e.directives)}.`),this.description=e.description,this.extensions=e.extensions&&M(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=e.extensionASTNodes,this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=e.directives??Et;const n=new Set(e.types);if(null!=e.types)for(const t of e.types)n.delete(t),Nt(t,n);null!=this._queryType&&Nt(this._queryType,n),null!=this._mutationType&&Nt(this._mutationType,n),null!=this._subscriptionType&&Nt(this._subscriptionType,n);for(const e of this._directives)if(lt(e))for(const t of e.args)Nt(t.type,n);Nt(He,n),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const e of Array.from(n)){if(null==e)continue;const t=e.name;if(t||f(0,"One of the provided types for building the Schema is missing a name."),void 0!==this._typeMap[t])throw new Error(`Schema must contain uniquely named types but contains multiple types named "${t}".`);if(this._typeMap[t]=e,ce(e)){for(const t of e.getInterfaces())if(ce(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(ae(e))for(const t of e.getInterfaces())if(ce(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.objects.push(e)}}}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return ue(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){return this._implementationsMap[e.name]??{objects:[],interfaces:[]}}isSubType(e,t){let n=this._subTypeMap[e.name];if(void 0===n){if(n=Object.create(null),ue(e))for(const t of e.getTypes())n[t.name]=!0;else{const t=this.getImplementations(e);for(const e of t.objects)n[e.name]=!0;for(const e of t.interfaces)n[e.name]=!0}this._subTypeMap[e.name]=n}return void 0!==n[t.name]}getDirectives(){return this._directives}getDirective(e){return this.getDirectives().find((t=>t.name===e))}toConfig(){return{description:this.description,query:this.getQueryType(),mutation:this.getMutationType(),subscription:this.getSubscriptionType(),types:C(this.getTypeMap()),directives:this.getDirectives().slice(),extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes??[],assumeValid:void 0!==this.__validationErrors}}get[Symbol.toStringTag](){return"GraphQLSchema"}}function Nt(e,t){const n=_e(e);if(!t.has(n))if(t.add(n),ue(n))for(const e of n.getTypes())Nt(e,t);else if(ae(n)||ce(n)){for(const e of n.getInterfaces())Nt(e,t);for(const e of C(n.getFields())){Nt(e.type,t);for(const n of e.args)Nt(n.type,t)}}else if(le(n))for(const e of C(n.getFields()))Nt(e.type,t);return t}function vt(e){if(Tt(e),e.__validationErrors)return e.__validationErrors;const t=new SchemaValidationContext(e);!function(e){const t=e.schema,n=t.getQueryType();n?ae(n)||e.reportError(`Query root type must be Object type, it cannot be ${l(n)}.`,It(t,"query")??n.astNode):e.reportError("Query root type must be provided.",t.astNode);const r=t.getMutationType();r&&!ae(r)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${l(r)}.`,It(t,"mutation")??r.astNode);const i=t.getSubscriptionType();i&&!ae(i)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${l(i)}.`,It(t,"subscription")??i.astNode)}(t),function(e){for(const t of e.schema.getDirectives())if(lt(t)){gt(e,t);for(const n of t.args)gt(e,n),he(n.type)||e.reportError(`The type of @${t.name}(${n.name}:) must be Input Type but got: ${l(n.type)}.`,n.astNode),ke(n)&&null!=n.deprecationReason&&e.reportError(`Required argument @${t.name}(${n.name}:) cannot be deprecated.`,[Rt(n.astNode),n.astNode?.type])}else e.reportError(`Expected directive but got: ${l(t)}.`,t?.astNode)}(t),function(e){const t=function(e){const t=Object.create(null),n=[],r=Object.create(null);return i;function i(o){if(t[o.name])return;t[o.name]=!0,r[o.name]=n.length;const s=C(o.getFields());for(const t of s)if(fe(t.type)&&le(t.type.ofType)){const o=t.type.ofType,s=r[o.name];if(n.push(t),void 0===s)i(o);else{const t=n.slice(s),r=t.map((e=>e.name)).join(".");e.reportError(`Cannot reference Input Object "${o.name}" within itself through a series of non-null fields: "${r}".`,t.map((e=>e.astNode)))}n.pop()}r[o.name]=void 0}}(e),n=e.schema.getTypeMap();for(const r of C(n))ge(r)?(pt(r)||gt(e,r),ae(r)||ce(r)?(_t(e,r),Ot(e,r)):ue(r)?St(e,r):pe(r)?At(e,r):le(r)&&(Dt(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${l(r)}.`,r.astNode)}(t);const n=t.getErrors();return e.__validationErrors=n,n}class SchemaValidationContext{constructor(e){this._errors=[],this.schema=e}reportError(e,t){const n=Array.isArray(t)?t.filter(Boolean):t;this.addError(new GraphQLError(e,n))}addError(e){this._errors.push(e)}getErrors(){return this._errors}}function It(e,t){const n=kt(e,(e=>e.operationTypes));for(const e of n)if(e.operation===t)return e.type}function gt(e,t){const n=("string"==typeof(r=t.name)||f(0,"Expected name to be a string."),r.length>1&&"_"===r[0]&&"_"===r[1]?new GraphQLError(`Name "${r}" must not begin with "__", which is reserved by GraphQL introspection.`):Q.test(r)?void 0:new GraphQLError(`Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "${r}" does not.`));var r;n&&e.addError(function(e,t,n){const r=e instanceof Error?e:new Error("Unexpected error value: "+l(e));return Array.isArray(r.path)?r:new GraphQLError(r.message,r.nodes??t,r.source,r.positions,n,r)}(n,t.astNode))}function _t(e,t){const n=C(t.getFields());0===n.length&&e.reportError(`Type ${t.name} must define one or more fields.`,wt(t));for(const r of n){gt(e,r),me(r.type)||e.reportError(`The type of ${t.name}.${r.name} must be Output Type but got: ${l(r.type)}.`,r.astNode?.type);for(const n of r.args){const i=n.name;gt(e,n),he(n.type)||e.reportError(`The type of ${t.name}.${r.name}(${i}:) must be Input Type but got: ${l(n.type)}.`,n.astNode?.type),ke(n)&&null!=n.deprecationReason&&e.reportError(`Required argument ${t.name}.${r.name}(${i}:) cannot be deprecated.`,[Rt(n.astNode),n.astNode?.type])}}}function Ot(e,t){const n=Object.create(null);for(const r of t.getInterfaces())ce(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,xt(t,r)):(n[r.name]=!0,Lt(e,t,r),bt(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,xt(t,r)):e.reportError(`Type ${l(t)} must only implement Interface types, it cannot implement ${l(r)}.`,xt(t,r))}function bt(e,t,n){const r=t.getFields();for(const i of C(n.getFields())){const o=i.name,s=r[o];if(s){Ce(e.schema,s.type,i.type)||e.reportError(`Interface field ${n.name}.${o} expects type ${l(i.type)} but ${t.name}.${o} is type ${l(s.type)}.`,[i.astNode?.type,s.astNode?.type]);for(const r of i.args){const i=r.name,a=s.args.find((e=>e.name===i));a?$e(r.type,a.type)||e.reportError(`Interface field argument ${n.name}.${o}(${i}:) expects type ${l(r.type)} but ${t.name}.${o}(${i}:) is type ${l(a.type)}.`,[r.astNode?.type,a.astNode?.type]):e.reportError(`Interface field argument ${n.name}.${o}(${i}:) expected but ${t.name}.${o} does not provide it.`,[r.astNode,s.astNode])}for(const r of s.args){const s=r.name;!i.args.find((e=>e.name===s))&&ke(r)&&e.reportError(`Object field ${t.name}.${o} includes required argument ${s} that is missing from the Interface field ${n.name}.${o}.`,[r.astNode,i.astNode])}}else e.reportError(`Interface field ${n.name}.${o} expected but ${t.name} does not provide it.`,[i.astNode,...wt(t)])}}function Lt(e,t,n){const r=t.getInterfaces();for(const i of n.getInterfaces())-1===r.indexOf(i)&&e.reportError(i===t?`Type ${t.name} cannot implement ${n.name} because it would create a circular reference.`:`Type ${t.name} must implement ${i.name} because it is implemented by ${n.name}.`,[...xt(n,i),...xt(t,n)])}function St(e,t){const n=t.getTypes();0===n.length&&e.reportError(`Union type ${t.name} must define one or more member types.`,wt(t));const r=Object.create(null);for(const i of n)r[i.name]?e.reportError(`Union type ${t.name} can only include type ${i.name} once.`,Ft(t,i.name)):(r[i.name]=!0,ae(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${l(i)}.`,Ft(t,String(i))))}function At(e,t){const n=t.getValues();0===n.length&&e.reportError(`Enum type ${t.name} must define one or more values.`,wt(t));for(const r of n){const n=r.name;gt(e,r),"true"!==n&&"false"!==n&&"null"!==n||e.reportError(`Enum type ${t.name} cannot include value: ${n}.`,r.astNode)}}function Dt(e,t){const n=C(t.getFields());0===n.length&&e.reportError(`Input Object type ${t.name} must define one or more fields.`,wt(t));for(const r of n)gt(e,r),he(r.type)||e.reportError(`The type of ${t.name}.${r.name} must be Input Type but got: ${l(r.type)}.`,r.astNode?.type),Ge(r)&&null!=r.deprecationReason&&e.reportError(`Required input field ${t.name}.${r.name} cannot be deprecated.`,[Rt(r.astNode),r.astNode?.type])}function wt(e){const{astNode:t,extensionASTNodes:n}=e;return t?n?[t].concat(n):[t]:n??[]}function kt(e,t){let n=[];for(const r of wt(e))n=n.concat(t(r)??[]);return n}function xt(e,t){return kt(e,(e=>e.interfaces)).filter((e=>e.name.value===t.name))}function Ft(e,t){return kt(e,(e=>e.types)).filter((e=>e.name.value===t))}function Rt(e){return e?.directives?.find((e=>e.name.value===mt.name))}function Gt(e,t){let n;return t.kind===c.LIST_TYPE?(n=Gt(e,t.type),n&&new GraphQLList(n)):t.kind===c.NON_NULL_TYPE?(n=Gt(e,t.type),n&&new GraphQLNonNull(n)):t.kind===c.NAMED_TYPE?e.getType(t.name.value):void re(0,"Unexpected type node: "+l(t))}class TypeInfo{constructor(e,t,n){this._schema=e,this._typeStack=[],this._parentTypeStack=[],this._inputTypeStack=[],this._fieldDefStack=[],this._defaultValueStack=[],this._directive=null,this._argument=null,this._enumValue=null,this._getFieldDef=t??$t,n&&(he(n)&&this._inputTypeStack.push(n),Ee(n)&&this._parentTypeStack.push(n),me(n)&&this._typeStack.push(n))}getType(){if(this._typeStack.length>0)return this._typeStack[this._typeStack.length-1]}getParentType(){if(this._parentTypeStack.length>0)return this._parentTypeStack[this._parentTypeStack.length-1]}getInputType(){if(this._inputTypeStack.length>0)return this._inputTypeStack[this._inputTypeStack.length-1]}getParentInputType(){if(this._inputTypeStack.length>1)return this._inputTypeStack[this._inputTypeStack.length-2]}getFieldDef(){if(this._fieldDefStack.length>0)return this._fieldDefStack[this._fieldDefStack.length-1]}getDefaultValue(){if(this._defaultValueStack.length>0)return this._defaultValueStack[this._defaultValueStack.length-1]}getDirective(){return this._directive}getArgument(){return this._argument}getEnumValue(){return this._enumValue}enter(e){const t=this._schema;switch(e.kind){case c.SELECTION_SET:{const e=_e(this.getType());this._parentTypeStack.push(Ee(e)?e:void 0);break}case c.FIELD:{const n=this.getParentType();let r,i;n&&(r=this._getFieldDef(t,n,e),r&&(i=r.type)),this._fieldDefStack.push(r),this._typeStack.push(me(i)?i:void 0);break}case c.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case c.OPERATION_DEFINITION:{let n;switch(e.operation){case"query":n=t.getQueryType();break;case"mutation":n=t.getMutationType();break;case"subscription":n=t.getSubscriptionType()}this._typeStack.push(ae(n)?n:void 0);break}case c.INLINE_FRAGMENT:case c.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?Gt(t,n):_e(this.getType());this._typeStack.push(me(r)?r:void 0);break}case c.VARIABLE_DEFINITION:{const n=Gt(t,e.type);this._inputTypeStack.push(he(n)?n:void 0);break}case c.ARGUMENT:{let t,n;const r=this.getDirective()??this.getFieldDef();r&&(t=r.args.find((t=>t.name===e.name.value)),t&&(n=t.type)),this._argument=t,this._defaultValueStack.push(t?t.defaultValue:void 0),this._inputTypeStack.push(he(n)?n:void 0);break}case c.LIST:{const e=Ie(this.getInputType()),t=de(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(he(t)?t:void 0);break}case c.OBJECT_FIELD:{const t=_e(this.getInputType());let n,r;le(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(he(n)?n:void 0);break}case c.ENUM:{const t=_e(this.getInputType());let n;pe(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case c.SELECTION_SET:this._parentTypeStack.pop();break;case c.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case c.DIRECTIVE:this._directive=null;break;case c.OPERATION_DEFINITION:case c.INLINE_FRAGMENT:case c.FRAGMENT_DEFINITION:this._typeStack.pop();break;case c.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case c.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case c.LIST:case c.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case c.ENUM:this._enumValue=null}}}function $t(e,t,n){const r=n.name.value;return r===st.name&&e.getQueryType()===t?st:r===at.name&&e.getQueryType()===t?at:r===ct.name&&Ee(t)?ct:ae(t)||ce(t)?t.getFields()[r]:void 0}function Ct(e,t){return{enter(n){e.enter(n);const r=$(t,n.kind,!1);if(r){const i=r.apply(t,arguments);return void 0!==i&&(e.leave(n),u(i)&&e.enter(i)),i}},leave(n){const r=$(t,n.kind,!0);let i;return r&&(i=r.apply(t,arguments)),e.leave(n),i}}}function Qt(e){return e.kind===c.OPERATION_DEFINITION||e.kind===c.FRAGMENT_DEFINITION}function Vt(e){return e.kind===c.SCALAR_TYPE_DEFINITION||e.kind===c.OBJECT_TYPE_DEFINITION||e.kind===c.INTERFACE_TYPE_DEFINITION||e.kind===c.UNION_TYPE_DEFINITION||e.kind===c.ENUM_TYPE_DEFINITION||e.kind===c.INPUT_OBJECT_TYPE_DEFINITION}function Ut(e){return e.kind===c.SCALAR_TYPE_EXTENSION||e.kind===c.OBJECT_TYPE_EXTENSION||e.kind===c.INTERFACE_TYPE_EXTENSION||e.kind===c.UNION_TYPE_EXTENSION||e.kind===c.ENUM_TYPE_EXTENSION||e.kind===c.INPUT_OBJECT_TYPE_EXTENSION}function jt(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);for(const t of e.getDocument().definitions)Vt(t)&&(r[t.name.value]=!0);const i=Object.keys(n).concat(Object.keys(r));return{NamedType(t,o,s,a,u){const p=t.name.value;if(!n[p]&&!r[p]){const n=u[2]??s,r=null!=n&&(l=n,!Array.isArray(l)&&(function(e){return e.kind===c.SCHEMA_DEFINITION||Vt(e)||e.kind===c.DIRECTIVE_DEFINITION}(l)||function(e){return e.kind===c.SCHEMA_EXTENSION||Ut(e)}(l)));if(r&&function(e){return-1!==Mt.indexOf(e)}(p))return;const o=J(p,r?Mt.concat(i):i);e.reportError(new GraphQLError(`Unknown type "${p}".`+B(o),t))}var l}}}const Mt=[...qe,...ut].map((e=>e.name));function Pt(e){const t=[],n=[];return{OperationDefinition:e=>(t.push(e),!1),FragmentDefinition:e=>(n.push(e),!1),Document:{leave(){const r=Object.create(null);for(const n of t)for(const t of e.getRecursivelyReferencedFragments(n))r[t.name.value]=!0;for(const t of n){const n=t.name.value;!0!==r[n]&&e.reportError(new GraphQLError(`Fragment "${n}" is never used.`,t))}}}}}function Bt(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Et;for(const e of r)t[e.name]=e.locations;const i=e.getDocument().definitions;for(const e of i)e.kind===c.DIRECTIVE_DEFINITION&&(t[e.name.value]=e.locations.map((e=>e.value)));return{Directive(n,r,i,o,s){const a=n.name.value,u=t[a];if(!u)return void e.reportError(new GraphQLError(`Unknown directive "@${a}".`,n));const p=function(e){const t=e[e.length-1];switch(!Array.isArray(t)||re(0),t.kind){case c.OPERATION_DEFINITION:return function(e){switch(e){case"query":return m.QUERY;case"mutation":return m.MUTATION;case"subscription":return m.SUBSCRIPTION}re(0,"Unexpected operation: "+l(e))}(t.operation);case c.FIELD:return m.FIELD;case c.FRAGMENT_SPREAD:return m.FRAGMENT_SPREAD;case c.INLINE_FRAGMENT:return m.INLINE_FRAGMENT;case c.FRAGMENT_DEFINITION:return m.FRAGMENT_DEFINITION;case c.VARIABLE_DEFINITION:return m.VARIABLE_DEFINITION;case c.SCHEMA_DEFINITION:case c.SCHEMA_EXTENSION:return m.SCHEMA;case c.SCALAR_TYPE_DEFINITION:case c.SCALAR_TYPE_EXTENSION:return m.SCALAR;case c.OBJECT_TYPE_DEFINITION:case c.OBJECT_TYPE_EXTENSION:return m.OBJECT;case c.FIELD_DEFINITION:return m.FIELD_DEFINITION;case c.INTERFACE_TYPE_DEFINITION:case c.INTERFACE_TYPE_EXTENSION:return m.INTERFACE;case c.UNION_TYPE_DEFINITION:case c.UNION_TYPE_EXTENSION:return m.UNION;case c.ENUM_TYPE_DEFINITION:case c.ENUM_TYPE_EXTENSION:return m.ENUM;case c.ENUM_VALUE_DEFINITION:return m.ENUM_VALUE;case c.INPUT_OBJECT_TYPE_DEFINITION:case c.INPUT_OBJECT_TYPE_EXTENSION:return m.INPUT_OBJECT;case c.INPUT_VALUE_DEFINITION:return e[e.length-3].kind===c.INPUT_OBJECT_TYPE_DEFINITION?m.INPUT_FIELD_DEFINITION:m.ARGUMENT_DEFINITION}}(s);p&&-1===u.indexOf(p)&&e.reportError(new GraphQLError(`Directive "@${a}" may not be used on ${p}.`,n))}}}function Yt(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Et;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===c.DIRECTIVE_DEFINITION&&(t[e.name.value]=!e.repeatable);const o=Object.create(null),s=Object.create(null);return{enter(n){if(null==n.directives)return;let r;if(n.kind===c.SCHEMA_DEFINITION||n.kind===c.SCHEMA_EXTENSION)r=o;else if(Vt(n)||Ut(n)){const e=n.name.value;r=s[e],void 0===r&&(s[e]=r=Object.create(null))}else r=Object.create(null);for(const i of n.directives){const n=i.name.value;t[n]&&(r[n]?e.reportError(new GraphQLError(`The directive "@${n}" can only be used once at this location.`,[r[n],i])):r[n]=i)}}}}function Jt(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Et;for(const e of r)t[e.name]=e.args.map((e=>e.name));const i=e.getDocument().definitions;for(const e of i)if(e.kind===c.DIRECTIVE_DEFINITION){const n=e.arguments??[];t[e.name.value]=n.map((e=>e.name.value))}return{Directive(n){const r=n.name.value,i=t[r];if(n.arguments&&i)for(const t of n.arguments){const n=t.name.value;if(-1===i.indexOf(n)){const o=J(n,i);e.reportError(new GraphQLError(`Unknown argument "${n}" on directive "@${r}".`+B(o),t))}}return!1}}}function qt(e){let t=Object.create(null);return{Field(){t=Object.create(null)},Directive(){t=Object.create(null)},Argument(n){const r=n.name.value;return t[r]?e.reportError(new GraphQLError(`There can be only one argument named "${r}".`,[t[r],n.name])):t[r]=n.name,!1}}}function Kt(e,t){const n=e.getInputType();if(!n)return;const r=_e(n);if(ye(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=l(n);e.reportError(new GraphQLError(`Expected value of type "${r}", found ${K(t)}.`,t))}}catch(r){const i=l(n);r instanceof GraphQLError?e.reportError(r):e.reportError(new GraphQLError(`Expected value of type "${i}", found ${K(t)}; `+r.message,t,void 0,void 0,void 0,r))}else{const r=l(n);e.reportError(new GraphQLError(`Expected value of type "${r}", found ${K(t)}.`,t))}}function Xt(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Et;for(const e of r)t[e.name]=U(e.args.filter(ke),(e=>e.name));const i=e.getDocument().definitions;for(const e of i)if(e.kind===c.DIRECTIVE_DEFINITION){const n=e.arguments??[];t[e.name.value]=U(n.filter(zt),(e=>e.name.value))}return{Directive:{leave(n){const r=n.name.value,i=t[r];if(i){const t=U(n.arguments??[],(e=>e.name.value));for(const o of Object.keys(i))if(!t[o]){const t=i[o].type,s=oe(t)?l(t):K(t);e.reportError(new GraphQLError(`Directive "@${r}" argument "${o}" of type "${s}" is required, but it was not provided.`,n))}}}}}}function zt(e){return e.type.kind===c.NON_NULL_TYPE&&null==e.defaultValue}function Ht(e,t,n,r,i){if(fe(r)&&!fe(t)){const o=void 0!==i;if(!(null!=n&&n.kind!==c.NULL)&&!o)return!1;return Ce(e,t,r.ofType)}return Ce(e,t,r)}function Zt(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+Zt(t))).join(" and "):e}function Wt(e,t,n,r,i,o,s){const a=e.getFragment(s);if(!a)return;const[c,u]=sn(e,n,a);if(o!==c){tn(e,t,n,r,i,o,c);for(let s=0;s{const n=t.find((t=>t.name.value===e.name.value));return!!n&&(r=e.value,i=n.value,K(r)===K(i));var r,i}))}(c.arguments??[],d.arguments??[]))return[[i,"they have differing arguments"],[c],[d]]}const m=u?.type,y=f?.type;if(m&&y&&rn(m,y))return[[i,`they return conflicting types "${l(m)}" and "${l(y)}"`],[c],[d]];const E=c.selectionSet,T=d.selectionSet;if(E&&T){return function(e,t,n,r){if(e.length>0)return[[t,e.map((([e])=>e))],e.reduce(((e,[,t])=>e.concat(t)),[n]),e.reduce(((e,[,,t])=>e.concat(t)),[r])]}(function(e,t,n,r,i,o,s,a){const c=[],[u,p]=on(e,t,i,o),[l,d]=on(e,t,s,a);if(tn(e,c,t,n,r,u,l),0!==d.length)for(let i=0;i!1}},function(e){let t=0;return{Document(e){t=e.definitions.filter((e=>e.kind===c.OPERATION_DEFINITION)).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new GraphQLError("This anonymous operation must be the only defined operation.",n))}}},function(e){return{OperationDefinition(t){"subscription"===t.operation&&1!==t.selectionSet.selections.length&&e.reportError(new GraphQLError(t.name?`Subscription "${t.name.value}" must select only one top level field.`:"Anonymous Subscription must select only one top level field.",t.selectionSet.selections.slice(1)))}}},jt,function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=Gt(e.getSchema(),n);if(t&&!Ee(t)){const t=K(n);e.reportError(new GraphQLError(`Fragment cannot condition on non composite type "${t}".`,n))}}},FragmentDefinition(t){const n=Gt(e.getSchema(),t.typeCondition);if(n&&!Ee(n)){const n=K(t.typeCondition);e.reportError(new GraphQLError(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,t.typeCondition))}}}},function(e){return{VariableDefinition(t){const n=Gt(e.getSchema(),t.type);if(n&&!he(n)){const n=t.variable.name.value,r=K(t.type);e.reportError(new GraphQLError(`Variable "$${n}" cannot be non-input type "${r}".`,t.type))}}}},function(e){return{Field(t){const n=e.getType(),r=t.selectionSet;if(n)if(ye(_e(n))){if(r){const i=t.name.value,o=l(n);e.reportError(new GraphQLError(`Field "${i}" must not have a selection since type "${o}" has no subfields.`,r))}}else if(!r){const r=t.name.value,i=l(n);e.reportError(new GraphQLError(`Field "${r}" of type "${i}" must have a selection of subfields. Did you mean "${r} { ... }"?`,t))}}}},function(e){return{Field(t){const n=e.getParentType();if(n){if(!e.getFieldDef()){const r=e.getSchema(),i=t.name.value;let o=B("to use an inline fragment on",function(e,t,n){if(!Te(t))return[];const r=new Set,i=Object.create(null);for(const o of e.getPossibleTypes(t))if(o.getFields()[n]){r.add(o),i[o.name]=1;for(const e of o.getInterfaces())e.getFields()[n]&&(r.add(e),i[e.name]=(i[e.name]??0)+1)}return Array.from(r).sort(((t,n)=>{const r=i[n.name]-i[t.name];return 0!==r?r:ce(t)&&e.isSubType(t,n)?-1:ce(n)&&e.isSubType(n,t)?1:t.name.localeCompare(n.name)})).map((e=>e.name))}(r,n,i));""===o&&(o=B(function(e,t){if(ae(e)||ce(e)){return J(t,Object.keys(e.getFields()))}return[]}(n,i))),e.reportError(new GraphQLError(`Cannot query field "${i}" on type "${n.name}".`+o,t))}}}}},function(e){const t=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(n){const r=n.name.value;return t[r]?e.reportError(new GraphQLError(`There can be only one fragment named "${r}".`,[t[r],n.name])):t[r]=n.name,!1}}},function(e){return{FragmentSpread(t){const n=t.name.value;e.getFragment(n)||e.reportError(new GraphQLError(`Unknown fragment "${n}".`,t.name))}}},Pt,function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(Ee(n)&&Ee(r)&&!Qe(e.getSchema(),n,r)){const i=l(r),o=l(n);e.reportError(new GraphQLError(`Fragment cannot be spread here as objects of type "${i}" can never be of type "${o}".`,t))}},FragmentSpread(t){const n=t.name.value,r=function(e,t){const n=e.getFragment(t);if(n){const t=Gt(e.getSchema(),n.typeCondition);if(Ee(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!Qe(e.getSchema(),r,i)){const o=l(i),s=l(r);e.reportError(new GraphQLError(`Fragment "${n}" cannot be spread here as objects of type "${o}" can never be of type "${s}".`,t))}}}},function(e){const t=Object.create(null),n=[],r=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition:e=>(i(e),!1)};function i(o){if(t[o.name.value])return;const s=o.name.value;t[s]=!0;const a=e.getFragmentSpreads(o.selectionSet);if(0!==a.length){r[s]=n.length;for(const t of a){const o=t.name.value,s=r[o];if(n.push(t),void 0===s){const t=e.getFragment(o);t&&i(t)}else{const t=n.slice(s),r=t.slice(0,-1).map((e=>'"'+e.name.value+'"')).join(", ");e.reportError(new GraphQLError(`Cannot spread fragment "${o}" within itself`+(""!==r?` via ${r}.`:"."),t))}n.pop()}r[s]=void 0}}},function(e){let t=Object.create(null);return{OperationDefinition(){t=Object.create(null)},VariableDefinition(n){const r=n.variable.name.value;t[r]?e.reportError(new GraphQLError(`There can be only one variable named "$${r}".`,[t[r],n.variable.name])):t[r]=n.variable.name}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:i}of r){const r=i.name.value;!0!==t[r]&&e.reportError(new GraphQLError(n.name?`Variable "$${r}" is not defined by operation "${n.name.value}".`:`Variable "$${r}" is not defined.`,[i,n]))}}},VariableDefinition(e){t[e.variable.name.value]=!0}}},function(e){let t=[];return{OperationDefinition:{enter(){t=[]},leave(n){const r=Object.create(null),i=e.getRecursiveVariableUsages(n);for(const{node:e}of i)r[e.name.value]=!0;for(const i of t){const t=i.variable.name.value;!0!==r[t]&&e.reportError(new GraphQLError(n.name?`Variable "$${t}" is never used in operation "${n.name.value}".`:`Variable "$${t}" is never used.`,i))}}},VariableDefinition(e){t.push(e)}}},Bt,Yt,function(e){return{...Jt(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,o=J(n,r.args.map((e=>e.name)));e.reportError(new GraphQLError(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+B(o),t))}}}},qt,function(e){return{ListValue(t){if(!de(Ie(e.getParentInputType())))return Kt(e,t),!1},ObjectValue(t){const n=_e(e.getInputType());if(!le(n))return Kt(e,t),!1;const r=U(t.fields,(e=>e.name.value));for(const i of C(n.getFields())){if(!r[i.name]&&Ge(i)){const r=l(i.type);e.reportError(new GraphQLError(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,t))}}},ObjectField(t){const n=_e(e.getParentInputType());if(!e.getInputType()&&le(n)){const r=J(t.name.value,Object.keys(n.getFields()));e.reportError(new GraphQLError(`Field "${t.name.value}" is not defined by type "${n.name}".`+B(r),t))}},NullValue(t){const n=e.getInputType();fe(n)&&e.reportError(new GraphQLError(`Expected value of type "${l(n)}", found ${K(t)}.`,t))},EnumValue:t=>Kt(e,t),IntValue:t=>Kt(e,t),FloatValue:t=>Kt(e,t),StringValue:t=>Kt(e,t),BooleanValue:t=>Kt(e,t)}},function(e){return{...Xt(e),Field:{leave(t){const n=e.getFieldDef();if(!n)return!1;const r=U(t.arguments??[],(e=>e.name.value));for(const i of n.args){if(!r[i.name]&&ke(i)){const r=l(i.type);e.reportError(new GraphQLError(`Field "${n.name}" argument "${i.name}" of type "${r}" is required, but it was not provided.`,t))}}}}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:n,type:i,defaultValue:o}of r){const r=n.name.value,s=t[r];if(s&&i){const t=e.getSchema(),a=Gt(t,s.type);if(a&&!Ht(t,a,s.defaultValue,i,o)){const t=l(a),o=l(i);e.reportError(new GraphQLError(`Variable "$${r}" of type "${t}" used in position expecting type "${o}".`,[s,n]))}}}}},VariableDefinition(e){t[e.variable.name.value]=e}}},function(e){const t=new PairSet,n=new Map;return{SelectionSet(r){const i=function(e,t,n,r,i){const o=[],[s,a]=on(e,t,r,i);if(function(e,t,n,r,i){for(const[o,s]of V(i))if(s.length>1)for(let i=0;i0&&e.reportError(new GraphQLError("Must provide only one schema definition.",t)),++r)}}},function(e){const t=e.getSchema(),n=Object.create(null),r=t?{query:t.getQueryType(),mutation:t.getMutationType(),subscription:t.getSubscriptionType()}:{};return{SchemaDefinition:i,SchemaExtension:i};function i(t){const i=t.operationTypes??[];for(const t of i){const i=t.operation,o=n[i];r[i]?e.reportError(new GraphQLError(`Type for ${i} already defined in the schema. It cannot be redefined.`,t)):o?e.reportError(new GraphQLError(`There can be only one ${i} type in schema.`,[o,t])):n[i]=t}return!1}},function(e){const t=Object.create(null),n=e.getSchema();return{ScalarTypeDefinition:r,ObjectTypeDefinition:r,InterfaceTypeDefinition:r,UnionTypeDefinition:r,EnumTypeDefinition:r,InputObjectTypeDefinition:r};function r(r){const i=r.name.value;if(!n?.getType(i))return t[i]?e.reportError(new GraphQLError(`There can be only one type named "${i}".`,[t[i],r.name])):t[i]=r.name,!1;e.reportError(new GraphQLError(`Type "${i}" already exists in the schema. It cannot also be defined in this type definition.`,r.name))}},function(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);return{EnumTypeDefinition:i,EnumTypeExtension:i};function i(t){const i=t.name.value;r[i]||(r[i]=Object.create(null));const o=t.values??[],s=r[i];for(const t of o){const r=t.name.value,o=n[i];pe(o)&&o.getValue(r)?e.reportError(new GraphQLError(`Enum value "${i}.${r}" already exists in the schema. It cannot also be defined in this type extension.`,t.name)):s[r]?e.reportError(new GraphQLError(`Enum value "${i}.${r}" can only be defined once.`,[s[r],t.name])):s[r]=t.name}return!1}},function(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);return{InputObjectTypeDefinition:i,InputObjectTypeExtension:i,InterfaceTypeDefinition:i,InterfaceTypeExtension:i,ObjectTypeDefinition:i,ObjectTypeExtension:i};function i(t){const i=t.name.value;r[i]||(r[i]=Object.create(null));const o=t.fields??[],s=r[i];for(const t of o){const r=t.name.value;un(n[i],r)?e.reportError(new GraphQLError(`Field "${i}.${r}" already exists in the schema. It cannot also be defined in this type extension.`,t.name)):s[r]?e.reportError(new GraphQLError(`Field "${i}.${r}" can only be defined once.`,[s[r],t.name])):s[r]=t.name}return!1}},function(e){const t=Object.create(null),n=e.getSchema();return{DirectiveDefinition(r){const i=r.name.value;if(!n?.getDirective(i))return t[i]?e.reportError(new GraphQLError(`There can be only one directive named "@${i}".`,[t[i],r.name])):t[i]=r.name,!1;e.reportError(new GraphQLError(`Directive "@${i}" already exists in the schema. It cannot be redefined.`,r.name))}}},jt,Bt,Yt,function(e){const t=e.getSchema(),n=Object.create(null);for(const t of e.getDocument().definitions)Vt(t)&&(n[t.name.value]=t);return{ScalarTypeExtension:r,ObjectTypeExtension:r,InterfaceTypeExtension:r,UnionTypeExtension:r,EnumTypeExtension:r,InputObjectTypeExtension:r};function r(r){const i=r.name.value,o=n[i],s=t?.getType(i);let a;if(o?a=pn[o.kind]:s&&(a=function(e){if(se(e))return c.SCALAR_TYPE_EXTENSION;if(ae(e))return c.OBJECT_TYPE_EXTENSION;if(ce(e))return c.INTERFACE_TYPE_EXTENSION;if(ue(e))return c.UNION_TYPE_EXTENSION;if(pe(e))return c.ENUM_TYPE_EXTENSION;if(le(e))return c.INPUT_OBJECT_TYPE_EXTENSION;re(0,"Unexpected type: "+l(e))}(s)),a){if(a!==r.kind){const t=function(e){switch(e){case c.SCALAR_TYPE_EXTENSION:return"scalar";case c.OBJECT_TYPE_EXTENSION:return"object";case c.INTERFACE_TYPE_EXTENSION:return"interface";case c.UNION_TYPE_EXTENSION:return"union";case c.ENUM_TYPE_EXTENSION:return"enum";case c.INPUT_OBJECT_TYPE_EXTENSION:return"input object"}re(0,"Unexpected kind: "+l(e))}(r.kind);e.reportError(new GraphQLError(`Cannot extend non-${t} type "${i}".`,o?[o,r]:r))}}else{let o=Object.keys(n);t&&(o=o.concat(Object.keys(t.getTypeMap())));const s=J(i,o);e.reportError(new GraphQLError(`Cannot extend type "${i}" because it is not defined.`+B(s),r.name))}}},Jt,qt,cn,Xt]);class ASTValidationContext{constructor(e,t){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=t}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let t=this._fragments;return t||(this._fragments=t=this.getDocument().definitions.reduce(((e,t)=>(t.kind===c.FRAGMENT_DEFINITION&&(e[t.name.value]=t),e)),Object.create(null))),t[e]}getFragmentSpreads(e){let t=this._fragmentSpreads.get(e);if(!t){t=[];const n=[e];for(;0!==n.length;){const e=n.pop();for(const r of e.selections)r.kind===c.FRAGMENT_SPREAD?t.push(r):r.selectionSet&&n.push(r.selectionSet)}this._fragmentSpreads.set(e,t)}return t}getRecursivelyReferencedFragments(e){let t=this._recursivelyReferencedFragments.get(e);if(!t){t=[];const n=Object.create(null),r=[e.selectionSet];for(;0!==r.length;){const e=r.pop();for(const i of this.getFragmentSpreads(e)){const e=i.name.value;if(!0!==n[e]){n[e]=!0;const i=this.getFragment(e);i&&(t.push(i),r.push(i.selectionSet))}}}this._recursivelyReferencedFragments.set(e,t)}return t}}class SDLValidationContext extends ASTValidationContext{constructor(e,t,n){super(e,n),this._schema=t}getSchema(){return this._schema}}class ValidationContext extends ASTValidationContext{constructor(e,t,n,r){super(t,r),this._schema=e,this._typeInfo=n,this._variableUsages=new Map,this._recursiveVariableUsages=new Map}getSchema(){return this._schema}getVariableUsages(e){let t=this._variableUsages.get(e);if(!t){const n=[],r=new TypeInfo(this._schema);R(e,Ct(r,{VariableDefinition:()=>!1,Variable(e){n.push({node:e,type:r.getInputType(),defaultValue:r.getDefaultValue()})}})),t=n,this._variableUsages.set(e,t)}return t}getRecursiveVariableUsages(e){let t=this._recursiveVariableUsages.get(e);if(!t){t=this.getVariableUsages(e);for(const n of this.getRecursivelyReferencedFragments(e))t=t.concat(this.getVariableUsages(n));this._recursiveVariableUsages.set(e,t)}return t}getType(){return this._typeInfo.getType()}getParentType(){return this._typeInfo.getParentType()}getInputType(){return this._typeInfo.getInputType()}getParentInputType(){return this._typeInfo.getParentInputType()}getFieldDef(){return this._typeInfo.getFieldDef()}getDirective(){return this._typeInfo.getDirective()}getArgument(){return this._typeInfo.getArgument()}getEnumValue(){return this._typeInfo.getEnumValue()}}function fn(e,t,n=ln,r=new TypeInfo(e),i={maxErrors:void 0}){t||f(0,"Must provide document."),function(e){const t=vt(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}(e);const o=Object.freeze({}),s=[],a=new ValidationContext(e,t,r,(e=>{if(null!=i.maxErrors&&s.length>=i.maxErrors)throw s.push(new GraphQLError("Too many validation errors, error limit reached. Validation aborted.")),o;s.push(e)})),c=G(n.map((e=>e(a))));try{R(t,Ct(r,c))}catch(e){if(e!==o)throw e}return s}function hn(e,t,n=dn){const r=[],i=new SDLValidationContext(e,t,(e=>{r.push(e)}));return R(e,G(n.map((e=>e(i))))),r}function mn(e,t,n){if(e){if(e.kind===c.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&fe(t))return;return i}if(fe(t)){if(e.kind===c.NULL)return;return mn(e,t.ofType,n)}if(e.kind===c.NULL)return null;if(de(t)){const r=t.ofType;if(e.kind===c.LIST){const t=[];for(const i of e.values)if(yn(i,n)){if(fe(r))return;t.push(null)}else{const e=mn(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=mn(e,r,n);if(void 0===i)return;return[i]}if(le(t)){if(e.kind!==c.OBJECT)return;const r=Object.create(null),i=U(e.fields,(e=>e.name.value));for(const e of C(t.getFields())){const t=i[e.name];if(!t||yn(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(fe(e.type))return;continue}const o=mn(t.value,e.type,n);if(void 0===o)return;r[e.name]=o}return r}if(ye(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}re(0,"Unexpected input type: "+l(t))}}function yn(e,t){return e.kind===c.VARIABLE&&(null==t||void 0===t[e.name.value])}function En(e,t,n){const r=t.directives?.find((t=>t.name.value===e.name));if(r)return function(e,t,n){const r={},i=U(t.arguments??[],(e=>e.name.value));for(const a of e.args){const e=a.name,u=a.type,p=i[e];if(!p){if(void 0!==a.defaultValue)r[e]=a.defaultValue;else if(fe(u))throw new GraphQLError(`Argument "${e}" of required type "${l(u)}" was not provided.`,t);continue}const d=p.value;let f=d.kind===c.NULL;if(d.kind===c.VARIABLE){const t=d.name.value;if(null==n||(o=n,s=t,!Object.prototype.hasOwnProperty.call(o,s))){if(void 0!==a.defaultValue)r[e]=a.defaultValue;else if(fe(u))throw new GraphQLError(`Argument "${e}" of required type "${l(u)}" was provided the variable "$${t}" which was not provided a runtime value.`,d);continue}f=null==n[t]}if(f&&fe(u))throw new GraphQLError(`Argument "${e}" of non-null type "${l(u)}" must not be null.`,d);const h=mn(d,u,n);if(void 0===h)throw new GraphQLError(`Argument "${e}" has invalid value ${K(d)}.`,d);r[e]=h}var o,s;return r}(e,r,n)}function Tn(e,n){t(e)&&t(e.__schema)||f(0,`Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${l(e)}.`);const r=e.__schema,i=P(r.types,(e=>e.name),(e=>function(e){if(null!=e&&null!=e.name&&null!=e.kind)switch(e.kind){case it.SCALAR:return new GraphQLScalarType({name:(r=e).name,description:r.description,specifiedByUrl:r.specifiedByUrl});case it.OBJECT:return new GraphQLObjectType({name:(n=e).name,description:n.description,interfaces:()=>y(n),fields:()=>E(n)});case it.INTERFACE:return new GraphQLInterfaceType({name:(t=e).name,description:t.description,interfaces:()=>y(t),fields:()=>E(t)});case it.UNION:return function(e){if(!e.possibleTypes){const t=l(e);throw new Error(`Introspection result missing possibleTypes: ${t}.`)}return new GraphQLUnionType({name:e.name,description:e.description,types:()=>e.possibleTypes.map(h)})}(e);case it.ENUM:return function(e){if(!e.enumValues){const t=l(e);throw new Error(`Introspection result missing enumValues: ${t}.`)}return new GraphQLEnumType({name:e.name,description:e.description,values:P(e.enumValues,(e=>e.name),(e=>({description:e.description,deprecationReason:e.deprecationReason})))})}(e);case it.INPUT_OBJECT:return function(e){if(!e.inputFields){const t=l(e);throw new Error(`Introspection result missing inputFields: ${t}.`)}return new GraphQLInputObjectType({name:e.name,description:e.description,fields:()=>N(e.inputFields)})}(e)}var t;var n;var r;const i=l(e);throw new Error(`Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${i}.`)}(e)));for(const e of[...qe,...ut])i[e.name]&&(i[e.name]=e);const o=r.queryType?h(r.queryType):null,s=r.mutationType?h(r.mutationType):null,a=r.subscriptionType?h(r.subscriptionType):null,c=r.directives?r.directives.map((function(e){if(!e.args){const t=l(e);throw new Error(`Introspection result missing directive args: ${t}.`)}if(!e.locations){const t=l(e);throw new Error(`Introspection result missing directive locations: ${t}.`)}return new GraphQLDirective({name:e.name,description:e.description,isRepeatable:e.isRepeatable,locations:e.locations.slice(),args:N(e.args)})})):[];return new GraphQLSchema({description:r.description,query:o,mutation:s,subscription:a,types:C(i),directives:c,assumeValid:n?.assumeValid});function u(e){if(e.kind===it.LIST){const t=e.ofType;if(!t)throw new Error("Decorated type deeper than introspection query.");return new GraphQLList(u(t))}if(e.kind===it.NON_NULL){const t=e.ofType;if(!t)throw new Error("Decorated type deeper than introspection query.");const n=u(t);return new GraphQLNonNull(function(e){if(!ve(e))throw new Error(`Expected ${l(e)} to be a GraphQL nullable type.`);return e}(n))}return d(e)}function d(e){const t=e.name;if(!t)throw new Error(`Unknown type reference: ${l(e)}.`);const n=i[t];if(!n)throw new Error(`Invalid or incomplete schema, unknown type: ${t}. Ensure that a full introspection query is used in order to build a client schema.`);return n}function h(e){return function(e){if(!ae(e))throw new Error(`Expected ${l(e)} to be a GraphQL Object type.`);return e}(d(e))}function m(e){return function(e){if(!ce(e))throw new Error(`Expected ${l(e)} to be a GraphQL Interface type.`);return e}(d(e))}function y(e){if(null===e.interfaces&&e.kind===it.INTERFACE)return[];if(!e.interfaces){const t=l(e);throw new Error(`Introspection result missing interfaces: ${t}.`)}return e.interfaces.map(m)}function E(e){if(!e.fields)throw new Error(`Introspection result missing fields: ${l(e)}.`);return P(e.fields,(e=>e.name),T)}function T(e){const t=u(e.type);if(!me(t)){const e=l(t);throw new Error(`Introspection must provide output type for fields, but received: ${e}.`)}if(!e.args){const t=l(e);throw new Error(`Introspection result missing field args: ${t}.`)}return{description:e.description,deprecationReason:e.deprecationReason,type:t,args:N(e.args)}}function N(e){return P(e,(e=>e.name),v)}function v(e){const t=u(e.type);if(!he(t)){const e=l(t);throw new Error(`Introspection must provide input type for arguments, but received: ${e}.`)}const n=null!=e.defaultValue?mn(function(e,t){const n=new Parser(e,t);n.expectToken(p.SOF);const r=n.parseValueLiteral(!1);return n.expectToken(p.EOF),r}(e.defaultValue),t):void 0;return{description:e.description,type:t,defaultValue:n,deprecationReason:e.deprecationReason}}}function Nn(e,t,n){const r=[],i=Object.create(null),o=[];let s;const a=[];for(const e of t.definitions)if(e.kind===c.SCHEMA_DEFINITION)s=e;else if(e.kind===c.SCHEMA_EXTENSION)a.push(e);else if(Vt(e))r.push(e);else if(Ut(e)){const t=e.name.value,n=i[t];i[t]=n?n.concat([e]):[e]}else e.kind===c.DIRECTIVE_DEFINITION&&o.push(e);if(0===Object.keys(i).length&&0===r.length&&0===o.length&&0===a.length&&null==s)return e;const u=Object.create(null);for(const t of e.types)u[t.name]=h(t);for(const e of r){const t=e.name.value;u[t]=vn[t]??L(e)}const p={query:e.query&&f(e.query),mutation:e.mutation&&f(e.mutation),subscription:e.subscription&&f(e.subscription),...s&&E([s]),...E(a)};return{description:s?.description?.value,...p,types:C(u),directives:[...e.directives.map((function(e){const t=e.toConfig();return new GraphQLDirective({...t,args:j(t.args,y)})})),...o.map((function(e){const t=e.locations.map((({value:e})=>e));return new GraphQLDirective({name:e.name.value,description:e.description?.value,locations:t,isRepeatable:e.repeatable,args:I(e.arguments),astNode:e})}))],extensions:void 0,astNode:s??e.astNode,extensionASTNodes:e.extensionASTNodes.concat(a),assumeValid:n?.assumeValid??!1};function d(e){return de(e)?new GraphQLList(d(e.ofType)):fe(e)?new GraphQLNonNull(d(e.ofType)):f(e)}function f(e){return u[e.name]}function h(e){return pt(e)||Ke(e)?e:se(e)?function(e){const t=e.toConfig(),n=i[t.name]??[];let r=t.specifiedByUrl;for(const e of n)r=gn(e)??r;return new GraphQLScalarType({...t,specifiedByUrl:r,extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):ae(e)?function(e){const t=e.toConfig(),n=i[t.name]??[];return new GraphQLObjectType({...t,interfaces:()=>[...e.getInterfaces().map(f),...O(n)],fields:()=>({...j(t.fields,m),...v(n)}),extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):ce(e)?function(e){const t=e.toConfig(),n=i[t.name]??[];return new GraphQLInterfaceType({...t,interfaces:()=>[...e.getInterfaces().map(f),...O(n)],fields:()=>({...j(t.fields,m),...v(n)}),extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):ue(e)?function(e){const t=e.toConfig(),n=i[t.name]??[];return new GraphQLUnionType({...t,types:()=>[...e.getTypes().map(f),...b(n)],extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):pe(e)?function(e){const t=e.toConfig(),n=i[e.name]??[];return new GraphQLEnumType({...t,values:{...t.values,..._(n)},extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):le(e)?function(e){const t=e.toConfig(),n=i[t.name]??[];return new GraphQLInputObjectType({...t,fields:()=>({...j(t.fields,(e=>({...e,type:d(e.type)}))),...g(n)}),extensionASTNodes:t.extensionASTNodes.concat(n)})}(e):void re(0,"Unexpected type: "+l(e))}function m(e){return{...e,type:d(e.type),args:j(e.args,y)}}function y(e){return{...e,type:d(e.type)}}function E(e){const t={};for(const n of e){const e=n.operationTypes??[];for(const n of e)t[n.operation]=T(n.type)}return t}function T(e){const t=e.name.value,n=vn[t]??u[t];if(void 0===n)throw new Error(`Unknown type: "${t}".`);return n}function N(e){return e.kind===c.LIST_TYPE?new GraphQLList(N(e.type)):e.kind===c.NON_NULL_TYPE?new GraphQLNonNull(N(e.type)):T(e)}function v(e){const t=Object.create(null);for(const n of e){const e=n.fields??[];for(const n of e)t[n.name.value]={type:N(n.type),description:n.description?.value,args:I(n.arguments),deprecationReason:In(n),astNode:n}}return t}function I(e){const t=e??[],n=Object.create(null);for(const e of t){const t=N(e.type);n[e.name.value]={type:t,description:e.description?.value,defaultValue:mn(e.defaultValue,t),deprecationReason:In(e),astNode:e}}return n}function g(e){const t=Object.create(null);for(const n of e){const e=n.fields??[];for(const n of e){const e=N(n.type);t[n.name.value]={type:e,description:n.description?.value,defaultValue:mn(n.defaultValue,e),deprecationReason:In(n),astNode:n}}}return t}function _(e){const t=Object.create(null);for(const n of e){const e=n.values??[];for(const n of e)t[n.name.value]={description:n.description?.value,deprecationReason:In(n),astNode:n}}return t}function O(e){const t=[];for(const n of e){const e=n.interfaces??[];for(const n of e)t.push(T(n))}return t}function b(e){const t=[];for(const n of e){const e=n.types??[];for(const n of e)t.push(T(n))}return t}function L(e){const t=e.name.value,n=i[t]??[];switch(e.kind){case c.OBJECT_TYPE_DEFINITION:{const r=n,i=[e,...r];return new GraphQLObjectType({name:t,description:e.description?.value,interfaces:()=>O(i),fields:()=>v(i),astNode:e,extensionASTNodes:r})}case c.INTERFACE_TYPE_DEFINITION:{const r=n,i=[e,...r];return new GraphQLInterfaceType({name:t,description:e.description?.value,interfaces:()=>O(i),fields:()=>v(i),astNode:e,extensionASTNodes:r})}case c.ENUM_TYPE_DEFINITION:{const r=n,i=[e,...r];return new GraphQLEnumType({name:t,description:e.description?.value,values:_(i),astNode:e,extensionASTNodes:r})}case c.UNION_TYPE_DEFINITION:{const r=n,i=[e,...r];return new GraphQLUnionType({name:t,description:e.description?.value,types:()=>b(i),astNode:e,extensionASTNodes:r})}case c.SCALAR_TYPE_DEFINITION:{const r=n;return new GraphQLScalarType({name:t,description:e.description?.value,specifiedByUrl:gn(e),astNode:e,extensionASTNodes:r})}case c.INPUT_OBJECT_TYPE_DEFINITION:{const r=n,i=[e,...r];return new GraphQLInputObjectType({name:t,description:e.description?.value,fields:()=>g(i),astNode:e,extensionASTNodes:r})}}re(0,"Unexpected type definition node: "+l(e))}}const vn=U(qe.concat(ut),(e=>e.name));function In(e){return En(mt,e)?.reason}function gn(e){return En(yt,e)?.url}function _n(e,t){null!=e&&e.kind===c.DOCUMENT||f(0,"Must provide valid Document AST."),!0!==t?.assumeValid&&!0!==t?.assumeValidSDL&&function(e){const t=hn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}(e);const n=Nn({description:void 0,types:[],directives:[],extensions:void 0,extensionASTNodes:[],assumeValid:!1},e,t);if(null==n.astNode)for(const e of n.types)switch(e.name){case"Query":n.query=e;break;case"Mutation":n.mutation=e;break;case"Subscription":n.subscription=e}const{directives:r}=n;for(const e of Et)r.every((t=>t.name!==e.name))&&r.push(e);return new GraphQLSchema(n)}function On(e){return function(e,t,n){const r=e.getDirectives().filter(t),i=C(e.getTypeMap()).filter(n);return[Ln(e)].concat(r.map((e=>function(e){return Fn(e)+"directive @"+e.name+wn(e.args)+(e.isRepeatable?" repeatable":"")+" on "+e.locations.join(" | ")}(e))),i.map((e=>function(e){if(se(e))return function(e){return Fn(e)+`scalar ${e.name}`+function(e){if(null==e.specifiedByUrl)return"";const t=Xe(e.specifiedByUrl,Be);return t||re(0,"Unexpected null value returned from `astFromValue` for specifiedByUrl")," @specifiedBy(url: "+K(t)+")"}(e)}(e);if(ae(e))return function(e){return Fn(e)+`type ${e.name}`+Sn(e)+An(e)}(e);if(ce(e))return function(e){return Fn(e)+`interface ${e.name}`+Sn(e)+An(e)}(e);if(ue(e))return function(e){const t=e.getTypes(),n=t.length?" = "+t.join(" | "):"";return Fn(e)+"union "+e.name+n}(e);if(pe(e))return function(e){const t=e.getValues().map(((e,t)=>Fn(e," ",!t)+" "+e.name+xn(e.deprecationReason)));return Fn(e)+`enum ${e.name}`+Dn(t)}(e);if(le(e))return function(e){const t=C(e.getFields()).map(((e,t)=>Fn(e," ",!t)+" "+kn(e)));return Fn(e)+`input ${e.name}`+Dn(t)}(e);re(0,"Unexpected type: "+l(e))}(e)))).filter(Boolean).join("\n\n")+"\n"}(e,(e=>{return t=e,!Et.some((({name:e})=>e===t.name));var t}),bn)}function bn(e){return!Ke(e)&&!pt(e)}function Ln(e){if(null==e.description&&function(e){const t=e.getQueryType();if(t&&"Query"!==t.name)return!1;const n=e.getMutationType();if(n&&"Mutation"!==n.name)return!1;const r=e.getSubscriptionType();if(r&&"Subscription"!==r.name)return!1;return!0}(e))return;const t=[],n=e.getQueryType();n&&t.push(` query: ${n.name}`);const r=e.getMutationType();r&&t.push(` mutation: ${r.name}`);const i=e.getSubscriptionType();return i&&t.push(` subscription: ${i.name}`),Fn(e)+`schema {\n${t.join("\n")}\n}`}function Sn(e){const t=e.getInterfaces();return t.length?" implements "+t.map((e=>e.name)).join(" & "):""}function An(e){return Dn(C(e.getFields()).map(((e,t)=>Fn(e," ",!t)+" "+e.name+wn(e.args," ")+": "+String(e.type)+xn(e.deprecationReason))))}function Dn(e){return 0!==e.length?" {\n"+e.join("\n")+"\n}":""}function wn(e,t=""){return 0===e.length?"":e.every((e=>!e.description))?"("+e.map(kn).join(", ")+")":"(\n"+e.map(((e,n)=>Fn(e," "+t,!n)+" "+t+kn(e))).join("\n")+"\n"+t+")"}function kn(e){const t=Xe(e.defaultValue,e.type);let n=e.name+": "+String(e.type);return t&&(n+=` = ${K(t)}`),n+xn(e.deprecationReason)}function xn(e){if(null==e)return"";const t=Xe(e,Be);return t&&e!==ht?" @deprecated(reason: "+K(t)+")":" @deprecated"}function Fn(e,t="",n=!0){const{description:r}=e;if(null==r)return"";return(t&&!n?"\n"+t:t)+T(r,"",r.length>70).replace(/\n/g,"\n"+t)+"\n"}const Rn=[Pt],Gn=[function(e){return{OperationDefinition:t=>(t.name||e.reportError(new GraphQLError("Apollo does not support anonymous operations because operation names are used during code generation. Please give this operation a name.",t)),!1)}},function(e){return{Field(t){"__typename"==(t.alias&&t.alias.value)&&e.reportError(new GraphQLError("Apollo needs to be able to insert __typename when needed, so using it as an alias is not supported.",t))}}},...ln.filter((e=>!Rn.includes(e)))];class GraphQLSchemaValidationError extends Error{constructor(e){super(e.map((e=>e.message)).join("\n\n")),this.validationErrors=e,this.name="GraphQLSchemaValidationError"}}function $n(e){const t=vt(e);if(0!==t.length)throw new GraphQLSchemaValidationError(t)}function Cn(e){return e.startsWith("__")}function Qn(e){return null!=e}function Vn(e){switch(e.kind){case"Variable":return{kind:e.kind,value:e.name.value};case"ListValue":return{kind:e.kind,value:e.values.map(Vn)};case"ObjectValue":return{kind:e.kind,value:e.fields.reduce(((e,t)=>(e[t.name.value]=Vn(t.value),e)),{})};default:return e}}function Un(e){var t,n;return null===(n=null===(t=e.loc)||void 0===t?void 0:t.source)||void 0===n?void 0:n.name}function jn(e,t){const n=new Map;for(const e of t.definitions)e.kind===c.FRAGMENT_DEFINITION&&n.set(e.name.value,e);const r=[],i=new Map,o=new Set;for(const e of t.definitions)e.kind===c.OPERATION_DEFINITION&&r.push(s(e));for(const[e,t]of n.entries())i.set(e,a(t));return{operations:r,fragments:Array.from(i.values()),referencedTypes:Array.from(o.values())};function s(t){if(!t.name)throw new GraphQLError("Operations should be named",t);const n=Un(t),r=t.name.value,i=t.operation,s=(t.variableDefinitions||[]).map((t=>{const n=t.variable.name.value,r=Gt(e,t.type);if(!r)throw new GraphQLError(`Couldn't get type from type node "${t.type}"`,t);return o.add(_e(r)),{name:n,type:r}})),a=K(t),c=function(e,t){if("query"===t.operation){const n=e.getQueryType();if(!n)throw new GraphQLError("Schema does not define the required query root type.",t);return n}if("mutation"===t.operation){const n=e.getMutationType();if(!n)throw new GraphQLError("Schema is not configured for mutations.",t);return n}if("subscription"===t.operation){const n=e.getSubscriptionType();if(!n)throw new GraphQLError("Schema is not configured for subscriptions.",t);return n}throw new GraphQLError("Can only have query, mutation and subscription operations.",t)}(e,t);return{filePath:n,name:r,operationType:i,rootType:c,variables:s,source:a,selectionSet:u(t.selectionSet,c)}}function a(t){const n=t.name.value,r=Un(t),i=K(t),o=Gt(e,t.typeCondition);return{name:n,filePath:r,source:i,typeCondition:o,selectionSet:u(t.selectionSet,o)}}function u(t,r,s=new Set){return{parentType:r,selections:t.selections.map((t=>function(t,r,s){var p;switch(t.kind){case c.FIELD:{const n=t.name.value,i=null===(p=t.alias)||void 0===p?void 0:p.value,s=function(e,t,n){return n===st.name&&e.getQueryType()===t?st:n===at.name&&e.getQueryType()===t?at:n===ct.name&&(ae(t)||ce(t)||ue(t))?ct:ae(t)||ce(t)?t.getFields()[n]:void 0}(e,r,n);if(!s)throw new GraphQLError(`Cannot query field "${n}" on type "${String(r)}"`,t);const a=s.type,c=_e(a);o.add(c);const{description:l,deprecationReason:d}=s;let f={kind:"Field",name:n,alias:i,arguments:t.arguments&&t.arguments.length>0?t.arguments.map((e=>{const t=e.name.value,n=s.args.find((t=>t.name===e.name.value)),r=n&&n.type||void 0;return{name:t,value:Vn(e.value),type:r}})):void 0,type:a,description:!Cn(n)&&l?l:void 0,deprecationReason:d||void 0};if(Ee(c)){const e=t.selectionSet;if(!e)throw new GraphQLError(`Composite field "${n}" on type "${String(r)}" requires selection set`,t);f.selectionSet=u(e,c)}return f}case c.INLINE_FRAGMENT:{const n=t.typeCondition,i=n?Gt(e,n):r;return{kind:"InlineFragment",selectionSet:u(t.selectionSet,i)}}case c.FRAGMENT_SPREAD:{const e=t.name.value;if(s.has(e))return;s.add(e);const r=function(e){let t=i.get(e);if(t)return t;const r=n.get(e);return r?(n.delete(e),t=a(r),i.set(e,t),t):void 0}(e);if(!r)throw new GraphQLError(`Unknown fragment "${e}".`,t.name);return{kind:"FragmentSpread",fragment:r}}}}(t,r,s))).filter(Qn)}}}return c.FIELD,c.NAME,e.GraphQLEnumType=GraphQLEnumType,e.GraphQLError=GraphQLError,e.GraphQLInputObjectType=GraphQLInputObjectType,e.GraphQLInterfaceType=GraphQLInterfaceType,e.GraphQLObjectType=GraphQLObjectType,e.GraphQLScalarType=GraphQLScalarType,e.GraphQLSchema=GraphQLSchema,e.GraphQLSchemaValidationError=GraphQLSchemaValidationError,e.GraphQLUnionType=GraphQLUnionType,e.Source=Source,e.compileDocument=function(e,t){return jn(e,t)},e.loadSchemaFromIntrospectionResult=function(e){let t=JSON.parse(e);t.data&&(t=t.data);const n=Tn(t);return $n(n),n},e.loadSchemaFromSDL=function(e){const t=D(e);!function(e){const t=hn(e);if(0!==t.length)throw new GraphQLSchemaValidationError(t)}(t);const n=_n(t,{assumeValidSDL:!0});return $n(n),n},e.mergeDocuments=function(e){return function(e){let t=[];for(const n of e)t=t.concat(n.definitions);return{kind:"Document",definitions:t}}(e)},e.parseDocument=function(e){return D(e)},e.printSchemaToSDL=function(e){return On(e)},e.validateDocument=function(e,t){return fn(e,t,Gn)},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); //# sourceMappingURL=ApolloCodegenFrontend.bundle.js.map diff --git a/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js.map b/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js.map index 0905979313..03ac05b23d 100644 --- a/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js.map +++ b/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js.map @@ -1 +1 @@ -{"version":3,"file":"ApolloCodegenFrontend.bundle.js","sources":["../JavaScript/node_modules/graphql/jsutils/isObjectLike.mjs","../JavaScript/node_modules/graphql/language/location.mjs","../JavaScript/node_modules/graphql/language/printLocation.mjs","../JavaScript/node_modules/graphql/error/GraphQLError.mjs","../JavaScript/node_modules/graphql/error/syntaxError.mjs","../JavaScript/node_modules/graphql/language/kinds.mjs","../JavaScript/node_modules/graphql/language/ast.mjs","../JavaScript/node_modules/graphql/language/tokenKind.mjs","../JavaScript/node_modules/graphql/jsutils/inspect.mjs","../JavaScript/node_modules/graphql/jsutils/devAssert.mjs","../JavaScript/node_modules/graphql/jsutils/instanceOf.mjs","../JavaScript/node_modules/graphql/language/source.mjs","../JavaScript/node_modules/graphql/language/directiveLocation.mjs","../JavaScript/node_modules/graphql/language/blockString.mjs","../JavaScript/node_modules/graphql/language/lexer.mjs","../JavaScript/node_modules/graphql/language/parser.mjs","../JavaScript/node_modules/graphql/language/visitor.mjs","../JavaScript/node_modules/graphql/polyfills/objectValues.mjs","../JavaScript/node_modules/graphql/utilities/assertValidName.mjs","../JavaScript/node_modules/graphql/polyfills/objectEntries.mjs","../JavaScript/node_modules/graphql/jsutils/keyMap.mjs","../JavaScript/node_modules/graphql/jsutils/mapValue.mjs","../JavaScript/node_modules/graphql/jsutils/toObjMap.mjs","../JavaScript/node_modules/graphql/jsutils/keyValMap.mjs","../JavaScript/node_modules/graphql/jsutils/didYouMean.mjs","../JavaScript/node_modules/graphql/jsutils/identityFunc.mjs","../JavaScript/node_modules/graphql/jsutils/suggestionList.mjs","../JavaScript/node_modules/graphql/language/printer.mjs","../JavaScript/node_modules/graphql/jsutils/invariant.mjs","../JavaScript/node_modules/graphql/utilities/valueFromASTUntyped.mjs","../JavaScript/node_modules/graphql/type/definition.mjs","../JavaScript/node_modules/graphql/utilities/typeComparators.mjs","../JavaScript/node_modules/graphql/type/scalars.mjs","../JavaScript/node_modules/graphql/utilities/astFromValue.mjs","../JavaScript/node_modules/graphql/jsutils/isCollection.mjs","../JavaScript/node_modules/graphql/type/introspection.mjs","../JavaScript/node_modules/graphql/type/directives.mjs","../JavaScript/node_modules/graphql/type/schema.mjs","../JavaScript/node_modules/graphql/type/validate.mjs","../JavaScript/node_modules/graphql/error/locatedError.mjs","../JavaScript/node_modules/graphql/utilities/typeFromAST.mjs","../JavaScript/node_modules/graphql/utilities/TypeInfo.mjs","../JavaScript/node_modules/graphql/language/predicates.mjs","../JavaScript/node_modules/graphql/validation/rules/KnownTypeNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/NoUnusedFragmentsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/KnownDirectivesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueDirectivesPerLocationRule.mjs","../JavaScript/node_modules/graphql/validation/rules/KnownArgumentNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueArgumentNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/ValuesOfCorrectTypeRule.mjs","../JavaScript/node_modules/graphql/validation/rules/ProvidedRequiredArgumentsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.mjs","../JavaScript/node_modules/graphql/validation/rules/OverlappingFieldsCanBeMergedRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueInputFieldNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueFieldDefinitionNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/PossibleTypeExtensionsRule.mjs","../JavaScript/node_modules/graphql/validation/specifiedRules.mjs","../JavaScript/node_modules/graphql/validation/rules/ExecutableDefinitionsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueOperationNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/LoneAnonymousOperationRule.mjs","../JavaScript/node_modules/graphql/validation/rules/SingleFieldSubscriptionsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/FragmentsOnCompositeTypesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/VariablesAreInputTypesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/ScalarLeafsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueFragmentNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/KnownFragmentNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/PossibleFragmentSpreadsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/NoFragmentCyclesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueVariableNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/NoUndefinedVariablesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/NoUnusedVariablesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/LoneSchemaDefinitionRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueOperationTypesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueTypeNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueEnumValueNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueDirectiveNamesRule.mjs","../JavaScript/node_modules/graphql/validation/ValidationContext.mjs","../JavaScript/node_modules/graphql/validation/validate.mjs","../JavaScript/node_modules/graphql/utilities/valueFromAST.mjs","../JavaScript/node_modules/graphql/execution/values.mjs","../JavaScript/node_modules/graphql/utilities/buildClientSchema.mjs","../JavaScript/node_modules/graphql/utilities/extendSchema.mjs","../JavaScript/node_modules/graphql/utilities/buildASTSchema.mjs","../JavaScript/src/validationRules.ts","../JavaScript/src/utilities/graphql.ts","../JavaScript/src/utilities/predicates.ts","../JavaScript/src/compiler/values.ts","../JavaScript/src/compiler/index.ts","../JavaScript/node_modules/graphql/utilities/getOperationRootType.mjs","../JavaScript/src/index.ts","../JavaScript/node_modules/graphql/utilities/concatAST.mjs"],"sourcesContent":["/**\n * Return true if `value` is object-like. A value is object-like if it's not\n * `null` and has a `typeof` result of \"object\".\n */\nexport default function isObjectLike(value) {\n return typeof value == 'object' && value !== null;\n}\n","/**\n * Represents a location in a Source.\n */\n\n/**\n * Takes a Source and a UTF-8 character offset, and returns the corresponding\n * line and column as a SourceLocation.\n */\nexport function getLocation(source, position) {\n const lineRegexp = /\\r\\n|[\\n\\r]/g;\n let line = 1;\n let column = position + 1;\n let match;\n\n while ((match = lineRegexp.exec(source.body)) && match.index < position) {\n line += 1;\n column = position + 1 - (match.index + match[0].length);\n }\n\n return {\n line,\n column\n };\n}\n","import { getLocation } from \"./location.mjs\";\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\n\nexport function printLocation(location) {\n return printSourceLocation(location.source, getLocation(location.source, location.start));\n}\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\n\nexport function printSourceLocation(source, sourceLocation) {\n const firstLineColumnOffset = source.locationOffset.column - 1;\n const body = whitespace(firstLineColumnOffset) + source.body;\n const lineIndex = sourceLocation.line - 1;\n const lineOffset = source.locationOffset.line - 1;\n const lineNum = sourceLocation.line + lineOffset;\n const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;\n const columnNum = sourceLocation.column + columnOffset;\n const locationStr = `${source.name}:${lineNum}:${columnNum}\\n`;\n const lines = body.split(/\\r\\n|[\\n\\r]/g);\n const locationLine = lines[lineIndex]; // Special case for minified documents\n\n if (locationLine.length > 120) {\n const subLineIndex = Math.floor(columnNum / 80);\n const subLineColumnNum = columnNum % 80;\n const subLines = [];\n\n for (let i = 0; i < locationLine.length; i += 80) {\n subLines.push(locationLine.slice(i, i + 80));\n }\n\n return locationStr + printPrefixedLines([[`${lineNum}`, subLines[0]], ...subLines.slice(1, subLineIndex + 1).map(subLine => ['', subLine]), [' ', whitespace(subLineColumnNum - 1) + '^'], ['', subLines[subLineIndex + 1]]]);\n }\n\n return locationStr + printPrefixedLines([// Lines specified like this: [\"prefix\", \"string\"],\n [`${lineNum - 1}`, lines[lineIndex - 1]], [`${lineNum}`, locationLine], ['', whitespace(columnNum - 1) + '^'], [`${lineNum + 1}`, lines[lineIndex + 1]]]);\n}\n\nfunction printPrefixedLines(lines) {\n const existingLines = lines.filter(([_, line]) => line !== undefined);\n const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));\n return existingLines.map(([prefix, line]) => leftPad(padLen, prefix) + (line ? ' | ' + line : ' |')).join('\\n');\n}\n\nfunction whitespace(len) {\n return Array(len + 1).join(' ');\n}\n\nfunction leftPad(len, str) {\n return whitespace(len - str.length) + str;\n}\n","// FIXME:\n// flowlint uninitialized-instance-property:off\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport { getLocation } from \"../language/location.mjs\";\nimport { printLocation, printSourceLocation } from \"../language/printLocation.mjs\";\n/**\n * A GraphQLError describes an Error found during the parse, validate, or\n * execute phases of performing a GraphQL operation. In addition to a message\n * and stack trace, it also includes information about the locations in a\n * GraphQL document and/or execution result that correspond to the Error.\n */\n\nexport class GraphQLError extends Error {\n /**\n * A message describing the Error for debugging purposes.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n *\n * Note: should be treated as readonly, despite invariant usage.\n */\n\n /**\n * An array of { line, column } locations within the source GraphQL document\n * which correspond to this error.\n *\n * Errors during validation often contain multiple locations, for example to\n * point out two things with the same name. Errors during execution include a\n * single location, the field which produced the error.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n\n /**\n * An array describing the JSON-path into the execution response which\n * corresponds to this error. Only included for errors during execution.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n\n /**\n * An array of GraphQL AST Nodes corresponding to this error.\n */\n\n /**\n * The source GraphQL document for the first location of this error.\n *\n * Note that if this Error represents more than one node, the source may not\n * represent nodes after the first node.\n */\n\n /**\n * An array of character offsets within the source GraphQL document\n * which correspond to this error.\n */\n\n /**\n * The original error thrown from a field resolver during execution.\n */\n\n /**\n * Extension fields to add to the formatted error.\n */\n constructor(message, nodes, source, positions, path, originalError, extensions) {\n super(message); // Compute list of blame nodes.\n\n const _nodes = Array.isArray(nodes) ? nodes.length !== 0 ? nodes : undefined : nodes ? [nodes] : undefined; // Compute locations in the source for the given nodes/positions.\n\n\n let _source = source;\n\n if (!_source && _nodes) {\n _source = _nodes[0].loc?.source;\n }\n\n let _positions = positions;\n\n if (!_positions && _nodes) {\n _positions = _nodes.reduce((list, node) => {\n if (node.loc) {\n list.push(node.loc.start);\n }\n\n return list;\n }, []);\n }\n\n if (_positions && _positions.length === 0) {\n _positions = undefined;\n }\n\n let _locations;\n\n if (positions && source) {\n _locations = positions.map(pos => getLocation(source, pos));\n } else if (_nodes) {\n _locations = _nodes.reduce((list, node) => {\n if (node.loc) {\n list.push(getLocation(node.loc.source, node.loc.start));\n }\n\n return list;\n }, []);\n }\n\n let _extensions = extensions;\n\n if (_extensions == null && originalError != null) {\n const originalExtensions = originalError.extensions;\n\n if (isObjectLike(originalExtensions)) {\n _extensions = originalExtensions;\n }\n }\n\n Object.defineProperties(this, {\n name: {\n value: 'GraphQLError'\n },\n message: {\n value: message,\n // By being enumerable, JSON.stringify will include `message` in the\n // resulting output. This ensures that the simplest possible GraphQL\n // service adheres to the spec.\n enumerable: true,\n writable: true\n },\n locations: {\n // Coercing falsy values to undefined ensures they will not be included\n // in JSON.stringify() when not provided.\n value: _locations ?? undefined,\n // By being enumerable, JSON.stringify will include `locations` in the\n // resulting output. This ensures that the simplest possible GraphQL\n // service adheres to the spec.\n enumerable: _locations != null\n },\n path: {\n // Coercing falsy values to undefined ensures they will not be included\n // in JSON.stringify() when not provided.\n value: path ?? undefined,\n // By being enumerable, JSON.stringify will include `path` in the\n // resulting output. This ensures that the simplest possible GraphQL\n // service adheres to the spec.\n enumerable: path != null\n },\n nodes: {\n value: _nodes ?? undefined\n },\n source: {\n value: _source ?? undefined\n },\n positions: {\n value: _positions ?? undefined\n },\n originalError: {\n value: originalError\n },\n extensions: {\n // Coercing falsy values to undefined ensures they will not be included\n // in JSON.stringify() when not provided.\n value: _extensions ?? undefined,\n // By being enumerable, JSON.stringify will include `path` in the\n // resulting output. This ensures that the simplest possible GraphQL\n // service adheres to the spec.\n enumerable: _extensions != null\n }\n }); // Include (non-enumerable) stack trace.\n\n if (originalError?.stack) {\n Object.defineProperty(this, 'stack', {\n value: originalError.stack,\n writable: true,\n configurable: true\n });\n return;\n } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')\n\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, GraphQLError);\n } else {\n Object.defineProperty(this, 'stack', {\n value: Error().stack,\n writable: true,\n configurable: true\n });\n }\n }\n\n toString() {\n return printError(this);\n } // FIXME: workaround to not break chai comparisons, should be remove in v16\n // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'Object';\n }\n\n}\n/**\n * Prints a GraphQLError to a string, representing useful location information\n * about the error's position in the source.\n */\n\nexport function printError(error) {\n let output = error.message;\n\n if (error.nodes) {\n for (const node of error.nodes) {\n if (node.loc) {\n output += '\\n\\n' + printLocation(node.loc);\n }\n }\n } else if (error.source && error.locations) {\n for (const location of error.locations) {\n output += '\\n\\n' + printSourceLocation(error.source, location);\n }\n }\n\n return output;\n}\n","import { GraphQLError } from \"./GraphQLError.mjs\";\n/**\n * Produces a GraphQLError representing a syntax error, containing useful\n * descriptive information about the syntax error's position in the source.\n */\n\nexport function syntaxError(source, position, description) {\n return new GraphQLError(`Syntax Error: ${description}`, undefined, source, [position]);\n}\n","/**\n * The set of allowed kind values for AST nodes.\n */\nexport const Kind = Object.freeze({\n // Name\n NAME: 'Name',\n // Document\n DOCUMENT: 'Document',\n OPERATION_DEFINITION: 'OperationDefinition',\n VARIABLE_DEFINITION: 'VariableDefinition',\n SELECTION_SET: 'SelectionSet',\n FIELD: 'Field',\n ARGUMENT: 'Argument',\n // Fragments\n FRAGMENT_SPREAD: 'FragmentSpread',\n INLINE_FRAGMENT: 'InlineFragment',\n FRAGMENT_DEFINITION: 'FragmentDefinition',\n // Values\n VARIABLE: 'Variable',\n INT: 'IntValue',\n FLOAT: 'FloatValue',\n STRING: 'StringValue',\n BOOLEAN: 'BooleanValue',\n NULL: 'NullValue',\n ENUM: 'EnumValue',\n LIST: 'ListValue',\n OBJECT: 'ObjectValue',\n OBJECT_FIELD: 'ObjectField',\n // Directives\n DIRECTIVE: 'Directive',\n // Types\n NAMED_TYPE: 'NamedType',\n LIST_TYPE: 'ListType',\n NON_NULL_TYPE: 'NonNullType',\n // Type System Definitions\n SCHEMA_DEFINITION: 'SchemaDefinition',\n OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition',\n // Type Definitions\n SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition',\n OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition',\n FIELD_DEFINITION: 'FieldDefinition',\n INPUT_VALUE_DEFINITION: 'InputValueDefinition',\n INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition',\n UNION_TYPE_DEFINITION: 'UnionTypeDefinition',\n ENUM_TYPE_DEFINITION: 'EnumTypeDefinition',\n ENUM_VALUE_DEFINITION: 'EnumValueDefinition',\n INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition',\n // Directive Definitions\n DIRECTIVE_DEFINITION: 'DirectiveDefinition',\n // Type System Extensions\n SCHEMA_EXTENSION: 'SchemaExtension',\n // Type Extensions\n SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension',\n OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension',\n INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension',\n UNION_TYPE_EXTENSION: 'UnionTypeExtension',\n ENUM_TYPE_EXTENSION: 'EnumTypeExtension',\n INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension'\n});\n/**\n * The enum type representing the possible kind values of AST nodes.\n */\n","/**\n * Contains a range of UTF-8 character offsets and token references that\n * identify the region of the source from which the AST derived.\n */\nexport class Location {\n /**\n * The character offset at which this Node begins.\n */\n\n /**\n * The character offset at which this Node ends.\n */\n\n /**\n * The Token at which this Node begins.\n */\n\n /**\n * The Token at which this Node ends.\n */\n\n /**\n * The Source document the AST represents.\n */\n constructor(startToken, endToken, source) {\n this.start = startToken.start;\n this.end = endToken.end;\n this.startToken = startToken;\n this.endToken = endToken;\n this.source = source;\n }\n\n toJSON() {\n return {\n start: this.start,\n end: this.end\n };\n } // @deprecated: Will be removed in v17\n // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return this.toJSON();\n }\n\n}\n/**\n * Represents a range of characters represented by a lexical token\n * within a Source.\n */\n\nexport class Token {\n /**\n * The kind of Token.\n */\n\n /**\n * The character offset at which this Node begins.\n */\n\n /**\n * The character offset at which this Node ends.\n */\n\n /**\n * The 1-indexed line number on which this Token appears.\n */\n\n /**\n * The 1-indexed column number at which this Token begins.\n */\n\n /**\n * For non-punctuation tokens, represents the interpreted value of the token.\n */\n\n /**\n * Tokens exist as nodes in a double-linked-list amongst all tokens\n * including ignored tokens. is always the first node and \n * the last.\n */\n constructor(kind, start, end, line, column, prev, value) {\n this.kind = kind;\n this.start = start;\n this.end = end;\n this.line = line;\n this.column = column;\n this.value = value;\n this.prev = prev;\n this.next = null;\n }\n\n toJSON() {\n return {\n kind: this.kind,\n value: this.value,\n line: this.line,\n column: this.column\n };\n } // @deprecated: Will be removed in v17\n // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return this.toJSON();\n }\n\n}\n/**\n * @internal\n */\n\nexport function isNode(maybeNode) {\n return maybeNode != null && typeof maybeNode.kind === 'string';\n}\n/**\n * The list of all possible AST node types.\n */\n","/**\n * An exported enum describing the different kinds of tokens that the\n * lexer emits.\n */\nexport const TokenKind = Object.freeze({\n SOF: '',\n EOF: '',\n BANG: '!',\n DOLLAR: '$',\n AMP: '&',\n PAREN_L: '(',\n PAREN_R: ')',\n SPREAD: '...',\n COLON: ':',\n EQUALS: '=',\n AT: '@',\n BRACKET_L: '[',\n BRACKET_R: ']',\n BRACE_L: '{',\n PIPE: '|',\n BRACE_R: '}',\n NAME: 'Name',\n INT: 'Int',\n FLOAT: 'Float',\n STRING: 'String',\n BLOCK_STRING: 'BlockString',\n COMMENT: 'Comment'\n});\n/**\n * The enum type representing the token kinds values.\n */\n","/* eslint-disable flowtype/no-weak-types */\nconst MAX_ARRAY_LENGTH = 10;\nconst MAX_RECURSIVE_DEPTH = 2;\n/**\n * Used to print values in error messages.\n */\n\nexport default function inspect(value) {\n return formatValue(value, []);\n}\n\nfunction formatValue(value, seenValues) {\n switch (typeof value) {\n case 'string':\n return JSON.stringify(value);\n\n case 'function':\n return value.name ? `[function ${value.name}]` : '[function]';\n\n case 'object':\n if (value === null) {\n return 'null';\n }\n\n return formatObjectValue(value, seenValues);\n\n default:\n return String(value);\n }\n}\n\nfunction formatObjectValue(value, previouslySeenValues) {\n if (previouslySeenValues.indexOf(value) !== -1) {\n return '[Circular]';\n }\n\n const seenValues = [...previouslySeenValues, value];\n\n if (typeof value.toJSON === 'function') {\n const jsonValue = value.toJSON(value); // check for infinite recursion\n\n if (jsonValue !== value) {\n return typeof jsonValue === 'string' ? jsonValue : formatValue(jsonValue, seenValues);\n }\n } else if (Array.isArray(value)) {\n return formatArray(value, seenValues);\n }\n\n return formatObject(value, seenValues);\n}\n\nfunction formatObject(object, seenValues) {\n const keys = Object.keys(object);\n\n if (keys.length === 0) {\n return '{}';\n }\n\n if (seenValues.length > MAX_RECURSIVE_DEPTH) {\n return '[' + getObjectTag(object) + ']';\n }\n\n const properties = keys.map(key => {\n const value = formatValue(object[key], seenValues);\n return key + ': ' + value;\n });\n return '{ ' + properties.join(', ') + ' }';\n}\n\nfunction formatArray(array, seenValues) {\n if (array.length === 0) {\n return '[]';\n }\n\n if (seenValues.length > MAX_RECURSIVE_DEPTH) {\n return '[Array]';\n }\n\n const len = Math.min(MAX_ARRAY_LENGTH, array.length);\n const remaining = array.length - len;\n const items = [];\n\n for (let i = 0; i < len; ++i) {\n items.push(formatValue(array[i], seenValues));\n }\n\n if (remaining === 1) {\n items.push('... 1 more item');\n } else if (remaining > 1) {\n items.push(`... ${remaining} more items`);\n }\n\n return '[' + items.join(', ') + ']';\n}\n\nfunction getObjectTag(object) {\n const tag = Object.prototype.toString.call(object).replace(/^\\[object /, '').replace(/]$/, '');\n\n if (tag === 'Object' && typeof object.constructor === 'function') {\n const name = object.constructor.name;\n\n if (typeof name === 'string' && name !== '') {\n return name;\n }\n }\n\n return tag;\n}\n","export default function devAssert(condition, message) {\n const booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')\n\n if (!booleanCondition) {\n throw new Error(message);\n }\n}\n","/**\n * A replacement for instanceof which includes an error warning when multi-realm\n * constructors are detected.\n */\n// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production\n// See: https://webpack.js.org/guides/production/\nexport default process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')\n// eslint-disable-next-line no-shadow\nfunction instanceOf(value, constructor) {\n return value instanceof constructor;\n} : // eslint-disable-next-line no-shadow\nfunction instanceOf(value, constructor) {\n if (value instanceof constructor) {\n return true;\n }\n\n if (value) {\n const valueClass = value.constructor;\n const className = constructor.name;\n\n if (className && valueClass && valueClass.name === className) {\n throw new Error(`Cannot use ${className} \"${value}\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.`);\n }\n }\n\n return false;\n};\n","import inspect from \"../jsutils/inspect.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport instanceOf from \"../jsutils/instanceOf.mjs\";\n\n/**\n * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are\n * optional, but they are useful for clients who store GraphQL documents in source files.\n * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might\n * be useful for `name` to be `\"Foo.graphql\"` and location to be `{ line: 40, column: 1 }`.\n * The `line` and `column` properties in `locationOffset` are 1-indexed.\n */\nexport class Source {\n constructor(body, name = 'GraphQL request', locationOffset = {\n line: 1,\n column: 1\n }) {\n typeof body === 'string' || devAssert(0, `Body must be a string. Received: ${inspect(body)}.`);\n this.body = body;\n this.name = name;\n this.locationOffset = locationOffset;\n this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.');\n this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.');\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'Source';\n }\n\n}\n/**\n * Test if the given value is a Source object.\n *\n * @internal\n */\n\n// eslint-disable-next-line no-redeclare\nexport function isSource(source) {\n return instanceOf(source, Source);\n}\n","/**\n * The set of allowed directive location values.\n */\nexport const DirectiveLocation = Object.freeze({\n // Request Definitions\n QUERY: 'QUERY',\n MUTATION: 'MUTATION',\n SUBSCRIPTION: 'SUBSCRIPTION',\n FIELD: 'FIELD',\n FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',\n FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',\n INLINE_FRAGMENT: 'INLINE_FRAGMENT',\n VARIABLE_DEFINITION: 'VARIABLE_DEFINITION',\n // Type System Definitions\n SCHEMA: 'SCHEMA',\n SCALAR: 'SCALAR',\n OBJECT: 'OBJECT',\n FIELD_DEFINITION: 'FIELD_DEFINITION',\n ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',\n INTERFACE: 'INTERFACE',\n UNION: 'UNION',\n ENUM: 'ENUM',\n ENUM_VALUE: 'ENUM_VALUE',\n INPUT_OBJECT: 'INPUT_OBJECT',\n INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'\n});\n/**\n * The enum type representing the directive location values.\n */\n","/**\n * Produces the value of a block string from its parsed raw value, similar to\n * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.\n *\n * This implements the GraphQL spec's BlockStringValue() static algorithm.\n *\n * @internal\n */\nexport function dedentBlockStringValue(rawString) {\n // Expand a block string's raw value into independent lines.\n const lines = rawString.split(/\\r\\n|[\\n\\r]/g); // Remove common indentation from all lines but first.\n\n const commonIndent = getBlockStringIndentation(rawString);\n\n if (commonIndent !== 0) {\n for (let i = 1; i < lines.length; i++) {\n lines[i] = lines[i].slice(commonIndent);\n }\n } // Remove leading and trailing blank lines.\n\n\n let startLine = 0;\n\n while (startLine < lines.length && isBlank(lines[startLine])) {\n ++startLine;\n }\n\n let endLine = lines.length;\n\n while (endLine > startLine && isBlank(lines[endLine - 1])) {\n --endLine;\n } // Return a string of the lines joined with U+000A.\n\n\n return lines.slice(startLine, endLine).join('\\n');\n}\n\nfunction isBlank(str) {\n for (let i = 0; i < str.length; ++i) {\n if (str[i] !== ' ' && str[i] !== '\\t') {\n return false;\n }\n }\n\n return true;\n}\n/**\n * @internal\n */\n\n\nexport function getBlockStringIndentation(value) {\n let isFirstLine = true;\n let isEmptyLine = true;\n let indent = 0;\n let commonIndent = null;\n\n for (let i = 0; i < value.length; ++i) {\n switch (value.charCodeAt(i)) {\n case 13:\n // \\r\n if (value.charCodeAt(i + 1) === 10) {\n ++i; // skip \\r\\n as one symbol\n }\n\n // falls through\n\n case 10:\n // \\n\n isFirstLine = false;\n isEmptyLine = true;\n indent = 0;\n break;\n\n case 9: // \\t\n\n case 32:\n // \n ++indent;\n break;\n\n default:\n if (isEmptyLine && !isFirstLine && (commonIndent === null || indent < commonIndent)) {\n commonIndent = indent;\n }\n\n isEmptyLine = false;\n }\n }\n\n return commonIndent ?? 0;\n}\n/**\n * Print a block string in the indented block form by adding a leading and\n * trailing blank line. However, if a block string starts with whitespace and is\n * a single-line, adding a leading blank line would strip that whitespace.\n *\n * @internal\n */\n\nexport function printBlockString(value, indentation = '', preferMultipleLines = false) {\n const isSingleLine = value.indexOf('\\n') === -1;\n const hasLeadingSpace = value[0] === ' ' || value[0] === '\\t';\n const hasTrailingQuote = value[value.length - 1] === '\"';\n const hasTrailingSlash = value[value.length - 1] === '\\\\';\n const printAsMultipleLines = !isSingleLine || hasTrailingQuote || hasTrailingSlash || preferMultipleLines;\n let result = ''; // Format a multi-line block quote to account for leading space.\n\n if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) {\n result += '\\n' + indentation;\n }\n\n result += indentation ? value.replace(/\\n/g, '\\n' + indentation) : value;\n\n if (printAsMultipleLines) {\n result += '\\n';\n }\n\n return '\"\"\"' + result.replace(/\"\"\"/g, '\\\\\"\"\"') + '\"\"\"';\n}\n","import { syntaxError } from \"../error/syntaxError.mjs\";\nimport { Token } from \"./ast.mjs\";\nimport { TokenKind } from \"./tokenKind.mjs\";\nimport { dedentBlockStringValue } from \"./blockString.mjs\";\n/**\n * Given a Source object, creates a Lexer for that source.\n * A Lexer is a stateful stream generator in that every time\n * it is advanced, it returns the next token in the Source. Assuming the\n * source lexes, the final Token emitted by the lexer will be of kind\n * EOF, after which the lexer will repeatedly return the same EOF token\n * whenever called.\n */\n\nexport class Lexer {\n /**\n * The previously focused non-ignored token.\n */\n\n /**\n * The currently focused non-ignored token.\n */\n\n /**\n * The (1-indexed) line containing the current token.\n */\n\n /**\n * The character offset at which the current line begins.\n */\n constructor(source) {\n const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0, null);\n this.source = source;\n this.lastToken = startOfFileToken;\n this.token = startOfFileToken;\n this.line = 1;\n this.lineStart = 0;\n }\n /**\n * Advances the token stream to the next non-ignored token.\n */\n\n\n advance() {\n this.lastToken = this.token;\n const token = this.token = this.lookahead();\n return token;\n }\n /**\n * Looks ahead and returns the next non-ignored token, but does not change\n * the state of Lexer.\n */\n\n\n lookahead() {\n let token = this.token;\n\n if (token.kind !== TokenKind.EOF) {\n do {\n // Note: next is only mutable during parsing, so we cast to allow this.\n token = token.next ?? (token.next = readToken(this, token));\n } while (token.kind === TokenKind.COMMENT);\n }\n\n return token;\n }\n\n}\n/**\n * @internal\n */\n\nexport function isPunctuatorTokenKind(kind) {\n return kind === TokenKind.BANG || kind === TokenKind.DOLLAR || kind === TokenKind.AMP || kind === TokenKind.PAREN_L || kind === TokenKind.PAREN_R || kind === TokenKind.SPREAD || kind === TokenKind.COLON || kind === TokenKind.EQUALS || kind === TokenKind.AT || kind === TokenKind.BRACKET_L || kind === TokenKind.BRACKET_R || kind === TokenKind.BRACE_L || kind === TokenKind.PIPE || kind === TokenKind.BRACE_R;\n}\n\nfunction printCharCode(code) {\n return (// NaN/undefined represents access beyond the end of the file.\n isNaN(code) ? TokenKind.EOF : // Trust JSON for ASCII.\n code < 0x007f ? JSON.stringify(String.fromCharCode(code)) : // Otherwise print the escaped form.\n `\"\\\\u${('00' + code.toString(16).toUpperCase()).slice(-4)}\"`\n );\n}\n/**\n * Gets the next token from the source starting at the given position.\n *\n * This skips over whitespace until it finds the next lexable token, then lexes\n * punctuators immediately or calls the appropriate helper function for more\n * complicated tokens.\n */\n\n\nfunction readToken(lexer, prev) {\n const source = lexer.source;\n const body = source.body;\n const bodyLength = body.length;\n let pos = prev.end;\n\n while (pos < bodyLength) {\n const code = body.charCodeAt(pos);\n const line = lexer.line;\n const col = 1 + pos - lexer.lineStart; // SourceCharacter\n\n switch (code) {\n case 0xfeff: // \n\n case 9: // \\t\n\n case 32: // \n\n case 44:\n // ,\n ++pos;\n continue;\n\n case 10:\n // \\n\n ++pos;\n ++lexer.line;\n lexer.lineStart = pos;\n continue;\n\n case 13:\n // \\r\n if (body.charCodeAt(pos + 1) === 10) {\n pos += 2;\n } else {\n ++pos;\n }\n\n ++lexer.line;\n lexer.lineStart = pos;\n continue;\n\n case 33:\n // !\n return new Token(TokenKind.BANG, pos, pos + 1, line, col, prev);\n\n case 35:\n // #\n return readComment(source, pos, line, col, prev);\n\n case 36:\n // $\n return new Token(TokenKind.DOLLAR, pos, pos + 1, line, col, prev);\n\n case 38:\n // &\n return new Token(TokenKind.AMP, pos, pos + 1, line, col, prev);\n\n case 40:\n // (\n return new Token(TokenKind.PAREN_L, pos, pos + 1, line, col, prev);\n\n case 41:\n // )\n return new Token(TokenKind.PAREN_R, pos, pos + 1, line, col, prev);\n\n case 46:\n // .\n if (body.charCodeAt(pos + 1) === 46 && body.charCodeAt(pos + 2) === 46) {\n return new Token(TokenKind.SPREAD, pos, pos + 3, line, col, prev);\n }\n\n break;\n\n case 58:\n // :\n return new Token(TokenKind.COLON, pos, pos + 1, line, col, prev);\n\n case 61:\n // =\n return new Token(TokenKind.EQUALS, pos, pos + 1, line, col, prev);\n\n case 64:\n // @\n return new Token(TokenKind.AT, pos, pos + 1, line, col, prev);\n\n case 91:\n // [\n return new Token(TokenKind.BRACKET_L, pos, pos + 1, line, col, prev);\n\n case 93:\n // ]\n return new Token(TokenKind.BRACKET_R, pos, pos + 1, line, col, prev);\n\n case 123:\n // {\n return new Token(TokenKind.BRACE_L, pos, pos + 1, line, col, prev);\n\n case 124:\n // |\n return new Token(TokenKind.PIPE, pos, pos + 1, line, col, prev);\n\n case 125:\n // }\n return new Token(TokenKind.BRACE_R, pos, pos + 1, line, col, prev);\n\n case 34:\n // \"\n if (body.charCodeAt(pos + 1) === 34 && body.charCodeAt(pos + 2) === 34) {\n return readBlockString(source, pos, line, col, prev, lexer);\n }\n\n return readString(source, pos, line, col, prev);\n\n case 45: // -\n\n case 48: // 0\n\n case 49: // 1\n\n case 50: // 2\n\n case 51: // 3\n\n case 52: // 4\n\n case 53: // 5\n\n case 54: // 6\n\n case 55: // 7\n\n case 56: // 8\n\n case 57:\n // 9\n return readNumber(source, pos, code, line, col, prev);\n\n case 65: // A\n\n case 66: // B\n\n case 67: // C\n\n case 68: // D\n\n case 69: // E\n\n case 70: // F\n\n case 71: // G\n\n case 72: // H\n\n case 73: // I\n\n case 74: // J\n\n case 75: // K\n\n case 76: // L\n\n case 77: // M\n\n case 78: // N\n\n case 79: // O\n\n case 80: // P\n\n case 81: // Q\n\n case 82: // R\n\n case 83: // S\n\n case 84: // T\n\n case 85: // U\n\n case 86: // V\n\n case 87: // W\n\n case 88: // X\n\n case 89: // Y\n\n case 90: // Z\n\n case 95: // _\n\n case 97: // a\n\n case 98: // b\n\n case 99: // c\n\n case 100: // d\n\n case 101: // e\n\n case 102: // f\n\n case 103: // g\n\n case 104: // h\n\n case 105: // i\n\n case 106: // j\n\n case 107: // k\n\n case 108: // l\n\n case 109: // m\n\n case 110: // n\n\n case 111: // o\n\n case 112: // p\n\n case 113: // q\n\n case 114: // r\n\n case 115: // s\n\n case 116: // t\n\n case 117: // u\n\n case 118: // v\n\n case 119: // w\n\n case 120: // x\n\n case 121: // y\n\n case 122:\n // z\n return readName(source, pos, line, col, prev);\n }\n\n throw syntaxError(source, pos, unexpectedCharacterMessage(code));\n }\n\n const line = lexer.line;\n const col = 1 + pos - lexer.lineStart;\n return new Token(TokenKind.EOF, bodyLength, bodyLength, line, col, prev);\n}\n/**\n * Report a message that an unexpected character was encountered.\n */\n\n\nfunction unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return `Cannot contain the invalid character ${printCharCode(code)}.`;\n }\n\n if (code === 39) {\n // '\n return 'Unexpected single quote character (\\'), did you mean to use a double quote (\")?';\n }\n\n return `Cannot parse the unexpected character ${printCharCode(code)}.`;\n}\n/**\n * Reads a comment token from the source file.\n *\n * #[\\u0009\\u0020-\\uFFFF]*\n */\n\n\nfunction readComment(source, start, line, col, prev) {\n const body = source.body;\n let code;\n let position = start;\n\n do {\n code = body.charCodeAt(++position);\n } while (!isNaN(code) && ( // SourceCharacter but not LineTerminator\n code > 0x001f || code === 0x0009));\n\n return new Token(TokenKind.COMMENT, start, position, line, col, prev, body.slice(start + 1, position));\n}\n/**\n * Reads a number token from the source file, either a float\n * or an int depending on whether a decimal point appears.\n *\n * Int: -?(0|[1-9][0-9]*)\n * Float: -?(0|[1-9][0-9]*)(\\.[0-9]+)?((E|e)(+|-)?[0-9]+)?\n */\n\n\nfunction readNumber(source, start, firstCode, line, col, prev) {\n const body = source.body;\n let code = firstCode;\n let position = start;\n let isFloat = false;\n\n if (code === 45) {\n // -\n code = body.charCodeAt(++position);\n }\n\n if (code === 48) {\n // 0\n code = body.charCodeAt(++position);\n\n if (code >= 48 && code <= 57) {\n throw syntaxError(source, position, `Invalid number, unexpected digit after 0: ${printCharCode(code)}.`);\n }\n } else {\n position = readDigits(source, position, code);\n code = body.charCodeAt(position);\n }\n\n if (code === 46) {\n // .\n isFloat = true;\n code = body.charCodeAt(++position);\n position = readDigits(source, position, code);\n code = body.charCodeAt(position);\n }\n\n if (code === 69 || code === 101) {\n // E e\n isFloat = true;\n code = body.charCodeAt(++position);\n\n if (code === 43 || code === 45) {\n // + -\n code = body.charCodeAt(++position);\n }\n\n position = readDigits(source, position, code);\n code = body.charCodeAt(position);\n } // Numbers cannot be followed by . or NameStart\n\n\n if (code === 46 || isNameStart(code)) {\n throw syntaxError(source, position, `Invalid number, expected digit but got: ${printCharCode(code)}.`);\n }\n\n return new Token(isFloat ? TokenKind.FLOAT : TokenKind.INT, start, position, line, col, prev, body.slice(start, position));\n}\n/**\n * Returns the new position in the source after reading digits.\n */\n\n\nfunction readDigits(source, start, firstCode) {\n const body = source.body;\n let position = start;\n let code = firstCode;\n\n if (code >= 48 && code <= 57) {\n // 0 - 9\n do {\n code = body.charCodeAt(++position);\n } while (code >= 48 && code <= 57); // 0 - 9\n\n\n return position;\n }\n\n throw syntaxError(source, position, `Invalid number, expected digit but got: ${printCharCode(code)}.`);\n}\n/**\n * Reads a string token from the source file.\n *\n * \"([^\"\\\\\\u000A\\u000D]|(\\\\(u[0-9a-fA-F]{4}|[\"\\\\/bfnrt])))*\"\n */\n\n\nfunction readString(source, start, line, col, prev) {\n const body = source.body;\n let position = start + 1;\n let chunkStart = position;\n let code = 0;\n let value = '';\n\n while (position < body.length && !isNaN(code = body.charCodeAt(position)) && // not LineTerminator\n code !== 0x000a && code !== 0x000d) {\n // Closing Quote (\")\n if (code === 34) {\n value += body.slice(chunkStart, position);\n return new Token(TokenKind.STRING, start, position + 1, line, col, prev, value);\n } // SourceCharacter\n\n\n if (code < 0x0020 && code !== 0x0009) {\n throw syntaxError(source, position, `Invalid character within String: ${printCharCode(code)}.`);\n }\n\n ++position;\n\n if (code === 92) {\n // \\\n value += body.slice(chunkStart, position - 1);\n code = body.charCodeAt(position);\n\n switch (code) {\n case 34:\n value += '\"';\n break;\n\n case 47:\n value += '/';\n break;\n\n case 92:\n value += '\\\\';\n break;\n\n case 98:\n value += '\\b';\n break;\n\n case 102:\n value += '\\f';\n break;\n\n case 110:\n value += '\\n';\n break;\n\n case 114:\n value += '\\r';\n break;\n\n case 116:\n value += '\\t';\n break;\n\n case 117:\n {\n // uXXXX\n const charCode = uniCharCode(body.charCodeAt(position + 1), body.charCodeAt(position + 2), body.charCodeAt(position + 3), body.charCodeAt(position + 4));\n\n if (charCode < 0) {\n const invalidSequence = body.slice(position + 1, position + 5);\n throw syntaxError(source, position, `Invalid character escape sequence: \\\\u${invalidSequence}.`);\n }\n\n value += String.fromCharCode(charCode);\n position += 4;\n break;\n }\n\n default:\n throw syntaxError(source, position, `Invalid character escape sequence: \\\\${String.fromCharCode(code)}.`);\n }\n\n ++position;\n chunkStart = position;\n }\n }\n\n throw syntaxError(source, position, 'Unterminated string.');\n}\n/**\n * Reads a block string token from the source file.\n *\n * \"\"\"(\"?\"?(\\\\\"\"\"|\\\\(?!=\"\"\")|[^\"\\\\]))*\"\"\"\n */\n\n\nfunction readBlockString(source, start, line, col, prev, lexer) {\n const body = source.body;\n let position = start + 3;\n let chunkStart = position;\n let code = 0;\n let rawValue = '';\n\n while (position < body.length && !isNaN(code = body.charCodeAt(position))) {\n // Closing Triple-Quote (\"\"\")\n if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {\n rawValue += body.slice(chunkStart, position);\n return new Token(TokenKind.BLOCK_STRING, start, position + 3, line, col, prev, dedentBlockStringValue(rawValue));\n } // SourceCharacter\n\n\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n throw syntaxError(source, position, `Invalid character within String: ${printCharCode(code)}.`);\n }\n\n if (code === 10) {\n // new line\n ++position;\n ++lexer.line;\n lexer.lineStart = position;\n } else if (code === 13) {\n // carriage return\n if (body.charCodeAt(position + 1) === 10) {\n position += 2;\n } else {\n ++position;\n }\n\n ++lexer.line;\n lexer.lineStart = position;\n } else if ( // Escape Triple-Quote (\\\"\"\")\n code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {\n rawValue += body.slice(chunkStart, position) + '\"\"\"';\n position += 4;\n chunkStart = position;\n } else {\n ++position;\n }\n }\n\n throw syntaxError(source, position, 'Unterminated string.');\n}\n/**\n * Converts four hexadecimal chars to the integer that the\n * string represents. For example, uniCharCode('0','0','0','f')\n * will return 15, and uniCharCode('0','0','f','f') returns 255.\n *\n * Returns a negative number on error, if a char was invalid.\n *\n * This is implemented by noting that char2hex() returns -1 on error,\n * which means the result of ORing the char2hex() will also be negative.\n */\n\n\nfunction uniCharCode(a, b, c, d) {\n return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d);\n}\n/**\n * Converts a hex character to its integer value.\n * '0' becomes 0, '9' becomes 9\n * 'A' becomes 10, 'F' becomes 15\n * 'a' becomes 10, 'f' becomes 15\n *\n * Returns -1 on error.\n */\n\n\nfunction char2hex(a) {\n return a >= 48 && a <= 57 ? a - 48 // 0-9\n : a >= 65 && a <= 70 ? a - 55 // A-F\n : a >= 97 && a <= 102 ? a - 87 // a-f\n : -1;\n}\n/**\n * Reads an alphanumeric + underscore name from the source.\n *\n * [_A-Za-z][_0-9A-Za-z]*\n */\n\n\nfunction readName(source, start, line, col, prev) {\n const body = source.body;\n const bodyLength = body.length;\n let position = start + 1;\n let code = 0;\n\n while (position !== bodyLength && !isNaN(code = body.charCodeAt(position)) && (code === 95 || // _\n code >= 48 && code <= 57 || // 0-9\n code >= 65 && code <= 90 || // A-Z\n code >= 97 && code <= 122) // a-z\n ) {\n ++position;\n }\n\n return new Token(TokenKind.NAME, start, position, line, col, prev, body.slice(start, position));\n} // _ A-Z a-z\n\n\nfunction isNameStart(code) {\n return code === 95 || code >= 65 && code <= 90 || code >= 97 && code <= 122;\n}\n","import { syntaxError } from \"../error/syntaxError.mjs\";\nimport { Kind } from \"./kinds.mjs\";\nimport { Location } from \"./ast.mjs\";\nimport { TokenKind } from \"./tokenKind.mjs\";\nimport { Source, isSource } from \"./source.mjs\";\nimport { DirectiveLocation } from \"./directiveLocation.mjs\";\nimport { Lexer, isPunctuatorTokenKind } from \"./lexer.mjs\";\n/**\n * Configuration options to control parser behavior\n */\n\n/**\n * Given a GraphQL source, parses it into a Document.\n * Throws GraphQLError if a syntax error is encountered.\n */\nexport function parse(source, options) {\n const parser = new Parser(source, options);\n return parser.parseDocument();\n}\n/**\n * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for\n * that value.\n * Throws GraphQLError if a syntax error is encountered.\n *\n * This is useful within tools that operate upon GraphQL Values directly and\n * in isolation of complete GraphQL documents.\n *\n * Consider providing the results to the utility function: valueFromAST().\n */\n\nexport function parseValue(source, options) {\n const parser = new Parser(source, options);\n parser.expectToken(TokenKind.SOF);\n const value = parser.parseValueLiteral(false);\n parser.expectToken(TokenKind.EOF);\n return value;\n}\n/**\n * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for\n * that type.\n * Throws GraphQLError if a syntax error is encountered.\n *\n * This is useful within tools that operate upon GraphQL Types directly and\n * in isolation of complete GraphQL documents.\n *\n * Consider providing the results to the utility function: typeFromAST().\n */\n\nexport function parseType(source, options) {\n const parser = new Parser(source, options);\n parser.expectToken(TokenKind.SOF);\n const type = parser.parseTypeReference();\n parser.expectToken(TokenKind.EOF);\n return type;\n}\n/**\n * This class is exported only to assist people in implementing their own parsers\n * without duplicating too much code and should be used only as last resort for cases\n * such as experimental syntax or if certain features could not be contributed upstream.\n *\n * It is still part of the internal API and is versioned, so any changes to it are never\n * considered breaking changes. If you still need to support multiple versions of the\n * library, please use the `versionInfo` variable for version detection.\n *\n * @internal\n */\n\nexport class Parser {\n constructor(source, options) {\n const sourceObj = isSource(source) ? source : new Source(source);\n this._lexer = new Lexer(sourceObj);\n this._options = options;\n }\n /**\n * Converts a name lex token into a name parse node.\n */\n\n\n parseName() {\n const token = this.expectToken(TokenKind.NAME);\n return {\n kind: Kind.NAME,\n value: token.value,\n loc: this.loc(token)\n };\n } // Implements the parsing rules in the Document section.\n\n /**\n * Document : Definition+\n */\n\n\n parseDocument() {\n const start = this._lexer.token;\n return {\n kind: Kind.DOCUMENT,\n definitions: this.many(TokenKind.SOF, this.parseDefinition, TokenKind.EOF),\n loc: this.loc(start)\n };\n }\n /**\n * Definition :\n * - ExecutableDefinition\n * - TypeSystemDefinition\n * - TypeSystemExtension\n *\n * ExecutableDefinition :\n * - OperationDefinition\n * - FragmentDefinition\n */\n\n\n parseDefinition() {\n if (this.peek(TokenKind.NAME)) {\n switch (this._lexer.token.value) {\n case 'query':\n case 'mutation':\n case 'subscription':\n return this.parseOperationDefinition();\n\n case 'fragment':\n return this.parseFragmentDefinition();\n\n case 'schema':\n case 'scalar':\n case 'type':\n case 'interface':\n case 'union':\n case 'enum':\n case 'input':\n case 'directive':\n return this.parseTypeSystemDefinition();\n\n case 'extend':\n return this.parseTypeSystemExtension();\n }\n } else if (this.peek(TokenKind.BRACE_L)) {\n return this.parseOperationDefinition();\n } else if (this.peekDescription()) {\n return this.parseTypeSystemDefinition();\n }\n\n throw this.unexpected();\n } // Implements the parsing rules in the Operations section.\n\n /**\n * OperationDefinition :\n * - SelectionSet\n * - OperationType Name? VariableDefinitions? Directives? SelectionSet\n */\n\n\n parseOperationDefinition() {\n const start = this._lexer.token;\n\n if (this.peek(TokenKind.BRACE_L)) {\n return {\n kind: Kind.OPERATION_DEFINITION,\n operation: 'query',\n name: undefined,\n variableDefinitions: [],\n directives: [],\n selectionSet: this.parseSelectionSet(),\n loc: this.loc(start)\n };\n }\n\n const operation = this.parseOperationType();\n let name;\n\n if (this.peek(TokenKind.NAME)) {\n name = this.parseName();\n }\n\n return {\n kind: Kind.OPERATION_DEFINITION,\n operation,\n name,\n variableDefinitions: this.parseVariableDefinitions(),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n loc: this.loc(start)\n };\n }\n /**\n * OperationType : one of query mutation subscription\n */\n\n\n parseOperationType() {\n const operationToken = this.expectToken(TokenKind.NAME);\n\n switch (operationToken.value) {\n case 'query':\n return 'query';\n\n case 'mutation':\n return 'mutation';\n\n case 'subscription':\n return 'subscription';\n }\n\n throw this.unexpected(operationToken);\n }\n /**\n * VariableDefinitions : ( VariableDefinition+ )\n */\n\n\n parseVariableDefinitions() {\n return this.optionalMany(TokenKind.PAREN_L, this.parseVariableDefinition, TokenKind.PAREN_R);\n }\n /**\n * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?\n */\n\n\n parseVariableDefinition() {\n const start = this._lexer.token;\n return {\n kind: Kind.VARIABLE_DEFINITION,\n variable: this.parseVariable(),\n type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),\n defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseValueLiteral(true) : undefined,\n directives: this.parseDirectives(true),\n loc: this.loc(start)\n };\n }\n /**\n * Variable : $ Name\n */\n\n\n parseVariable() {\n const start = this._lexer.token;\n this.expectToken(TokenKind.DOLLAR);\n return {\n kind: Kind.VARIABLE,\n name: this.parseName(),\n loc: this.loc(start)\n };\n }\n /**\n * SelectionSet : { Selection+ }\n */\n\n\n parseSelectionSet() {\n const start = this._lexer.token;\n return {\n kind: Kind.SELECTION_SET,\n selections: this.many(TokenKind.BRACE_L, this.parseSelection, TokenKind.BRACE_R),\n loc: this.loc(start)\n };\n }\n /**\n * Selection :\n * - Field\n * - FragmentSpread\n * - InlineFragment\n */\n\n\n parseSelection() {\n return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();\n }\n /**\n * Field : Alias? Name Arguments? Directives? SelectionSet?\n *\n * Alias : Name :\n */\n\n\n parseField() {\n const start = this._lexer.token;\n const nameOrAlias = this.parseName();\n let alias;\n let name;\n\n if (this.expectOptionalToken(TokenKind.COLON)) {\n alias = nameOrAlias;\n name = this.parseName();\n } else {\n name = nameOrAlias;\n }\n\n return {\n kind: Kind.FIELD,\n alias,\n name,\n arguments: this.parseArguments(false),\n directives: this.parseDirectives(false),\n selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : undefined,\n loc: this.loc(start)\n };\n }\n /**\n * Arguments[Const] : ( Argument[?Const]+ )\n */\n\n\n parseArguments(isConst) {\n const item = isConst ? this.parseConstArgument : this.parseArgument;\n return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);\n }\n /**\n * Argument[Const] : Name : Value[?Const]\n */\n\n\n parseArgument() {\n const start = this._lexer.token;\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n return {\n kind: Kind.ARGUMENT,\n name,\n value: this.parseValueLiteral(false),\n loc: this.loc(start)\n };\n }\n\n parseConstArgument() {\n const start = this._lexer.token;\n return {\n kind: Kind.ARGUMENT,\n name: this.parseName(),\n value: (this.expectToken(TokenKind.COLON), this.parseValueLiteral(true)),\n loc: this.loc(start)\n };\n } // Implements the parsing rules in the Fragments section.\n\n /**\n * Corresponds to both FragmentSpread and InlineFragment in the spec.\n *\n * FragmentSpread : ... FragmentName Directives?\n *\n * InlineFragment : ... TypeCondition? Directives? SelectionSet\n */\n\n\n parseFragment() {\n const start = this._lexer.token;\n this.expectToken(TokenKind.SPREAD);\n const hasTypeCondition = this.expectOptionalKeyword('on');\n\n if (!hasTypeCondition && this.peek(TokenKind.NAME)) {\n return {\n kind: Kind.FRAGMENT_SPREAD,\n name: this.parseFragmentName(),\n directives: this.parseDirectives(false),\n loc: this.loc(start)\n };\n }\n\n return {\n kind: Kind.INLINE_FRAGMENT,\n typeCondition: hasTypeCondition ? this.parseNamedType() : undefined,\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n loc: this.loc(start)\n };\n }\n /**\n * FragmentDefinition :\n * - fragment FragmentName on TypeCondition Directives? SelectionSet\n *\n * TypeCondition : NamedType\n */\n\n\n parseFragmentDefinition() {\n const start = this._lexer.token;\n this.expectKeyword('fragment'); // Experimental support for defining variables within fragments changes\n // the grammar of FragmentDefinition:\n // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet\n\n if (this._options?.experimentalFragmentVariables === true) {\n return {\n kind: Kind.FRAGMENT_DEFINITION,\n name: this.parseFragmentName(),\n variableDefinitions: this.parseVariableDefinitions(),\n typeCondition: (this.expectKeyword('on'), this.parseNamedType()),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n loc: this.loc(start)\n };\n }\n\n return {\n kind: Kind.FRAGMENT_DEFINITION,\n name: this.parseFragmentName(),\n typeCondition: (this.expectKeyword('on'), this.parseNamedType()),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n loc: this.loc(start)\n };\n }\n /**\n * FragmentName : Name but not `on`\n */\n\n\n parseFragmentName() {\n if (this._lexer.token.value === 'on') {\n throw this.unexpected();\n }\n\n return this.parseName();\n } // Implements the parsing rules in the Values section.\n\n /**\n * Value[Const] :\n * - [~Const] Variable\n * - IntValue\n * - FloatValue\n * - StringValue\n * - BooleanValue\n * - NullValue\n * - EnumValue\n * - ListValue[?Const]\n * - ObjectValue[?Const]\n *\n * BooleanValue : one of `true` `false`\n *\n * NullValue : `null`\n *\n * EnumValue : Name but not `true`, `false` or `null`\n */\n\n\n parseValueLiteral(isConst) {\n const token = this._lexer.token;\n\n switch (token.kind) {\n case TokenKind.BRACKET_L:\n return this.parseList(isConst);\n\n case TokenKind.BRACE_L:\n return this.parseObject(isConst);\n\n case TokenKind.INT:\n this._lexer.advance();\n\n return {\n kind: Kind.INT,\n value: token.value,\n loc: this.loc(token)\n };\n\n case TokenKind.FLOAT:\n this._lexer.advance();\n\n return {\n kind: Kind.FLOAT,\n value: token.value,\n loc: this.loc(token)\n };\n\n case TokenKind.STRING:\n case TokenKind.BLOCK_STRING:\n return this.parseStringLiteral();\n\n case TokenKind.NAME:\n this._lexer.advance();\n\n switch (token.value) {\n case 'true':\n return {\n kind: Kind.BOOLEAN,\n value: true,\n loc: this.loc(token)\n };\n\n case 'false':\n return {\n kind: Kind.BOOLEAN,\n value: false,\n loc: this.loc(token)\n };\n\n case 'null':\n return {\n kind: Kind.NULL,\n loc: this.loc(token)\n };\n\n default:\n return {\n kind: Kind.ENUM,\n value: token.value,\n loc: this.loc(token)\n };\n }\n\n case TokenKind.DOLLAR:\n if (!isConst) {\n return this.parseVariable();\n }\n\n break;\n }\n\n throw this.unexpected();\n }\n\n parseStringLiteral() {\n const token = this._lexer.token;\n\n this._lexer.advance();\n\n return {\n kind: Kind.STRING,\n value: token.value,\n block: token.kind === TokenKind.BLOCK_STRING,\n loc: this.loc(token)\n };\n }\n /**\n * ListValue[Const] :\n * - [ ]\n * - [ Value[?Const]+ ]\n */\n\n\n parseList(isConst) {\n const start = this._lexer.token;\n\n const item = () => this.parseValueLiteral(isConst);\n\n return {\n kind: Kind.LIST,\n values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R),\n loc: this.loc(start)\n };\n }\n /**\n * ObjectValue[Const] :\n * - { }\n * - { ObjectField[?Const]+ }\n */\n\n\n parseObject(isConst) {\n const start = this._lexer.token;\n\n const item = () => this.parseObjectField(isConst);\n\n return {\n kind: Kind.OBJECT,\n fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R),\n loc: this.loc(start)\n };\n }\n /**\n * ObjectField[Const] : Name : Value[?Const]\n */\n\n\n parseObjectField(isConst) {\n const start = this._lexer.token;\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n return {\n kind: Kind.OBJECT_FIELD,\n name,\n value: this.parseValueLiteral(isConst),\n loc: this.loc(start)\n };\n } // Implements the parsing rules in the Directives section.\n\n /**\n * Directives[Const] : Directive[?Const]+\n */\n\n\n parseDirectives(isConst) {\n const directives = [];\n\n while (this.peek(TokenKind.AT)) {\n directives.push(this.parseDirective(isConst));\n }\n\n return directives;\n }\n /**\n * Directive[Const] : @ Name Arguments[?Const]?\n */\n\n\n parseDirective(isConst) {\n const start = this._lexer.token;\n this.expectToken(TokenKind.AT);\n return {\n kind: Kind.DIRECTIVE,\n name: this.parseName(),\n arguments: this.parseArguments(isConst),\n loc: this.loc(start)\n };\n } // Implements the parsing rules in the Types section.\n\n /**\n * Type :\n * - NamedType\n * - ListType\n * - NonNullType\n */\n\n\n parseTypeReference() {\n const start = this._lexer.token;\n let type;\n\n if (this.expectOptionalToken(TokenKind.BRACKET_L)) {\n type = this.parseTypeReference();\n this.expectToken(TokenKind.BRACKET_R);\n type = {\n kind: Kind.LIST_TYPE,\n type,\n loc: this.loc(start)\n };\n } else {\n type = this.parseNamedType();\n }\n\n if (this.expectOptionalToken(TokenKind.BANG)) {\n return {\n kind: Kind.NON_NULL_TYPE,\n type,\n loc: this.loc(start)\n };\n }\n\n return type;\n }\n /**\n * NamedType : Name\n */\n\n\n parseNamedType() {\n const start = this._lexer.token;\n return {\n kind: Kind.NAMED_TYPE,\n name: this.parseName(),\n loc: this.loc(start)\n };\n } // Implements the parsing rules in the Type Definition section.\n\n /**\n * TypeSystemDefinition :\n * - SchemaDefinition\n * - TypeDefinition\n * - DirectiveDefinition\n *\n * TypeDefinition :\n * - ScalarTypeDefinition\n * - ObjectTypeDefinition\n * - InterfaceTypeDefinition\n * - UnionTypeDefinition\n * - EnumTypeDefinition\n * - InputObjectTypeDefinition\n */\n\n\n parseTypeSystemDefinition() {\n // Many definitions begin with a description and require a lookahead.\n const keywordToken = this.peekDescription() ? this._lexer.lookahead() : this._lexer.token;\n\n if (keywordToken.kind === TokenKind.NAME) {\n switch (keywordToken.value) {\n case 'schema':\n return this.parseSchemaDefinition();\n\n case 'scalar':\n return this.parseScalarTypeDefinition();\n\n case 'type':\n return this.parseObjectTypeDefinition();\n\n case 'interface':\n return this.parseInterfaceTypeDefinition();\n\n case 'union':\n return this.parseUnionTypeDefinition();\n\n case 'enum':\n return this.parseEnumTypeDefinition();\n\n case 'input':\n return this.parseInputObjectTypeDefinition();\n\n case 'directive':\n return this.parseDirectiveDefinition();\n }\n }\n\n throw this.unexpected(keywordToken);\n }\n\n peekDescription() {\n return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);\n }\n /**\n * Description : StringValue\n */\n\n\n parseDescription() {\n if (this.peekDescription()) {\n return this.parseStringLiteral();\n }\n }\n /**\n * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }\n */\n\n\n parseSchemaDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('schema');\n const directives = this.parseDirectives(true);\n const operationTypes = this.many(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);\n return {\n kind: Kind.SCHEMA_DEFINITION,\n description,\n directives,\n operationTypes,\n loc: this.loc(start)\n };\n }\n /**\n * OperationTypeDefinition : OperationType : NamedType\n */\n\n\n parseOperationTypeDefinition() {\n const start = this._lexer.token;\n const operation = this.parseOperationType();\n this.expectToken(TokenKind.COLON);\n const type = this.parseNamedType();\n return {\n kind: Kind.OPERATION_TYPE_DEFINITION,\n operation,\n type,\n loc: this.loc(start)\n };\n }\n /**\n * ScalarTypeDefinition : Description? scalar Name Directives[Const]?\n */\n\n\n parseScalarTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('scalar');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n return {\n kind: Kind.SCALAR_TYPE_DEFINITION,\n description,\n name,\n directives,\n loc: this.loc(start)\n };\n }\n /**\n * ObjectTypeDefinition :\n * Description?\n * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?\n */\n\n\n parseObjectTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('type');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseDirectives(true);\n const fields = this.parseFieldsDefinition();\n return {\n kind: Kind.OBJECT_TYPE_DEFINITION,\n description,\n name,\n interfaces,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * ImplementsInterfaces :\n * - implements `&`? NamedType\n * - ImplementsInterfaces & NamedType\n */\n\n\n parseImplementsInterfaces() {\n return this.expectOptionalKeyword('implements') ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];\n }\n /**\n * FieldsDefinition : { FieldDefinition+ }\n */\n\n\n parseFieldsDefinition() {\n return this.optionalMany(TokenKind.BRACE_L, this.parseFieldDefinition, TokenKind.BRACE_R);\n }\n /**\n * FieldDefinition :\n * - Description? Name ArgumentsDefinition? : Type Directives[Const]?\n */\n\n\n parseFieldDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n const args = this.parseArgumentDefs();\n this.expectToken(TokenKind.COLON);\n const type = this.parseTypeReference();\n const directives = this.parseDirectives(true);\n return {\n kind: Kind.FIELD_DEFINITION,\n description,\n name,\n arguments: args,\n type,\n directives,\n loc: this.loc(start)\n };\n }\n /**\n * ArgumentsDefinition : ( InputValueDefinition+ )\n */\n\n\n parseArgumentDefs() {\n return this.optionalMany(TokenKind.PAREN_L, this.parseInputValueDef, TokenKind.PAREN_R);\n }\n /**\n * InputValueDefinition :\n * - Description? Name : Type DefaultValue? Directives[Const]?\n */\n\n\n parseInputValueDef() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n const type = this.parseTypeReference();\n let defaultValue;\n\n if (this.expectOptionalToken(TokenKind.EQUALS)) {\n defaultValue = this.parseValueLiteral(true);\n }\n\n const directives = this.parseDirectives(true);\n return {\n kind: Kind.INPUT_VALUE_DEFINITION,\n description,\n name,\n type,\n defaultValue,\n directives,\n loc: this.loc(start)\n };\n }\n /**\n * InterfaceTypeDefinition :\n * - Description? interface Name Directives[Const]? FieldsDefinition?\n */\n\n\n parseInterfaceTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('interface');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseDirectives(true);\n const fields = this.parseFieldsDefinition();\n return {\n kind: Kind.INTERFACE_TYPE_DEFINITION,\n description,\n name,\n interfaces,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * UnionTypeDefinition :\n * - Description? union Name Directives[Const]? UnionMemberTypes?\n */\n\n\n parseUnionTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('union');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const types = this.parseUnionMemberTypes();\n return {\n kind: Kind.UNION_TYPE_DEFINITION,\n description,\n name,\n directives,\n types,\n loc: this.loc(start)\n };\n }\n /**\n * UnionMemberTypes :\n * - = `|`? NamedType\n * - UnionMemberTypes | NamedType\n */\n\n\n parseUnionMemberTypes() {\n return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];\n }\n /**\n * EnumTypeDefinition :\n * - Description? enum Name Directives[Const]? EnumValuesDefinition?\n */\n\n\n parseEnumTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('enum');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const values = this.parseEnumValuesDefinition();\n return {\n kind: Kind.ENUM_TYPE_DEFINITION,\n description,\n name,\n directives,\n values,\n loc: this.loc(start)\n };\n }\n /**\n * EnumValuesDefinition : { EnumValueDefinition+ }\n */\n\n\n parseEnumValuesDefinition() {\n return this.optionalMany(TokenKind.BRACE_L, this.parseEnumValueDefinition, TokenKind.BRACE_R);\n }\n /**\n * EnumValueDefinition : Description? EnumValue Directives[Const]?\n *\n * EnumValue : Name\n */\n\n\n parseEnumValueDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n return {\n kind: Kind.ENUM_VALUE_DEFINITION,\n description,\n name,\n directives,\n loc: this.loc(start)\n };\n }\n /**\n * InputObjectTypeDefinition :\n * - Description? input Name Directives[Const]? InputFieldsDefinition?\n */\n\n\n parseInputObjectTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('input');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const fields = this.parseInputFieldsDefinition();\n return {\n kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,\n description,\n name,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * InputFieldsDefinition : { InputValueDefinition+ }\n */\n\n\n parseInputFieldsDefinition() {\n return this.optionalMany(TokenKind.BRACE_L, this.parseInputValueDef, TokenKind.BRACE_R);\n }\n /**\n * TypeSystemExtension :\n * - SchemaExtension\n * - TypeExtension\n *\n * TypeExtension :\n * - ScalarTypeExtension\n * - ObjectTypeExtension\n * - InterfaceTypeExtension\n * - UnionTypeExtension\n * - EnumTypeExtension\n * - InputObjectTypeDefinition\n */\n\n\n parseTypeSystemExtension() {\n const keywordToken = this._lexer.lookahead();\n\n if (keywordToken.kind === TokenKind.NAME) {\n switch (keywordToken.value) {\n case 'schema':\n return this.parseSchemaExtension();\n\n case 'scalar':\n return this.parseScalarTypeExtension();\n\n case 'type':\n return this.parseObjectTypeExtension();\n\n case 'interface':\n return this.parseInterfaceTypeExtension();\n\n case 'union':\n return this.parseUnionTypeExtension();\n\n case 'enum':\n return this.parseEnumTypeExtension();\n\n case 'input':\n return this.parseInputObjectTypeExtension();\n }\n }\n\n throw this.unexpected(keywordToken);\n }\n /**\n * SchemaExtension :\n * - extend schema Directives[Const]? { OperationTypeDefinition+ }\n * - extend schema Directives[Const]\n */\n\n\n parseSchemaExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('schema');\n const directives = this.parseDirectives(true);\n const operationTypes = this.optionalMany(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);\n\n if (directives.length === 0 && operationTypes.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.SCHEMA_EXTENSION,\n directives,\n operationTypes,\n loc: this.loc(start)\n };\n }\n /**\n * ScalarTypeExtension :\n * - extend scalar Name Directives[Const]\n */\n\n\n parseScalarTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('scalar');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n\n if (directives.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.SCALAR_TYPE_EXTENSION,\n name,\n directives,\n loc: this.loc(start)\n };\n }\n /**\n * ObjectTypeExtension :\n * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition\n * - extend type Name ImplementsInterfaces? Directives[Const]\n * - extend type Name ImplementsInterfaces\n */\n\n\n parseObjectTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('type');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseDirectives(true);\n const fields = this.parseFieldsDefinition();\n\n if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.OBJECT_TYPE_EXTENSION,\n name,\n interfaces,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * InterfaceTypeExtension :\n * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition\n * - extend interface Name ImplementsInterfaces? Directives[Const]\n * - extend interface Name ImplementsInterfaces\n */\n\n\n parseInterfaceTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('interface');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseDirectives(true);\n const fields = this.parseFieldsDefinition();\n\n if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.INTERFACE_TYPE_EXTENSION,\n name,\n interfaces,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * UnionTypeExtension :\n * - extend union Name Directives[Const]? UnionMemberTypes\n * - extend union Name Directives[Const]\n */\n\n\n parseUnionTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('union');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const types = this.parseUnionMemberTypes();\n\n if (directives.length === 0 && types.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.UNION_TYPE_EXTENSION,\n name,\n directives,\n types,\n loc: this.loc(start)\n };\n }\n /**\n * EnumTypeExtension :\n * - extend enum Name Directives[Const]? EnumValuesDefinition\n * - extend enum Name Directives[Const]\n */\n\n\n parseEnumTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('enum');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const values = this.parseEnumValuesDefinition();\n\n if (directives.length === 0 && values.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.ENUM_TYPE_EXTENSION,\n name,\n directives,\n values,\n loc: this.loc(start)\n };\n }\n /**\n * InputObjectTypeExtension :\n * - extend input Name Directives[Const]? InputFieldsDefinition\n * - extend input Name Directives[Const]\n */\n\n\n parseInputObjectTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('input');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const fields = this.parseInputFieldsDefinition();\n\n if (directives.length === 0 && fields.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,\n name,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * DirectiveDefinition :\n * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations\n */\n\n\n parseDirectiveDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('directive');\n this.expectToken(TokenKind.AT);\n const name = this.parseName();\n const args = this.parseArgumentDefs();\n const repeatable = this.expectOptionalKeyword('repeatable');\n this.expectKeyword('on');\n const locations = this.parseDirectiveLocations();\n return {\n kind: Kind.DIRECTIVE_DEFINITION,\n description,\n name,\n arguments: args,\n repeatable,\n locations,\n loc: this.loc(start)\n };\n }\n /**\n * DirectiveLocations :\n * - `|`? DirectiveLocation\n * - DirectiveLocations | DirectiveLocation\n */\n\n\n parseDirectiveLocations() {\n return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);\n }\n /*\n * DirectiveLocation :\n * - ExecutableDirectiveLocation\n * - TypeSystemDirectiveLocation\n *\n * ExecutableDirectiveLocation : one of\n * `QUERY`\n * `MUTATION`\n * `SUBSCRIPTION`\n * `FIELD`\n * `FRAGMENT_DEFINITION`\n * `FRAGMENT_SPREAD`\n * `INLINE_FRAGMENT`\n *\n * TypeSystemDirectiveLocation : one of\n * `SCHEMA`\n * `SCALAR`\n * `OBJECT`\n * `FIELD_DEFINITION`\n * `ARGUMENT_DEFINITION`\n * `INTERFACE`\n * `UNION`\n * `ENUM`\n * `ENUM_VALUE`\n * `INPUT_OBJECT`\n * `INPUT_FIELD_DEFINITION`\n */\n\n\n parseDirectiveLocation() {\n const start = this._lexer.token;\n const name = this.parseName();\n\n if (DirectiveLocation[name.value] !== undefined) {\n return name;\n }\n\n throw this.unexpected(start);\n } // Core parsing utility functions\n\n /**\n * Returns a location object, used to identify the place in the source that created a given parsed object.\n */\n\n\n loc(startToken) {\n if (this._options?.noLocation !== true) {\n return new Location(startToken, this._lexer.lastToken, this._lexer.source);\n }\n }\n /**\n * Determines if the next token is of a given kind\n */\n\n\n peek(kind) {\n return this._lexer.token.kind === kind;\n }\n /**\n * If the next token is of the given kind, return that token after advancing the lexer.\n * Otherwise, do not change the parser state and throw an error.\n */\n\n\n expectToken(kind) {\n const token = this._lexer.token;\n\n if (token.kind === kind) {\n this._lexer.advance();\n\n return token;\n }\n\n throw syntaxError(this._lexer.source, token.start, `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`);\n }\n /**\n * If the next token is of the given kind, return that token after advancing the lexer.\n * Otherwise, do not change the parser state and return undefined.\n */\n\n\n expectOptionalToken(kind) {\n const token = this._lexer.token;\n\n if (token.kind === kind) {\n this._lexer.advance();\n\n return token;\n }\n\n return undefined;\n }\n /**\n * If the next token is a given keyword, advance the lexer.\n * Otherwise, do not change the parser state and throw an error.\n */\n\n\n expectKeyword(value) {\n const token = this._lexer.token;\n\n if (token.kind === TokenKind.NAME && token.value === value) {\n this._lexer.advance();\n } else {\n throw syntaxError(this._lexer.source, token.start, `Expected \"${value}\", found ${getTokenDesc(token)}.`);\n }\n }\n /**\n * If the next token is a given keyword, return \"true\" after advancing the lexer.\n * Otherwise, do not change the parser state and return \"false\".\n */\n\n\n expectOptionalKeyword(value) {\n const token = this._lexer.token;\n\n if (token.kind === TokenKind.NAME && token.value === value) {\n this._lexer.advance();\n\n return true;\n }\n\n return false;\n }\n /**\n * Helper function for creating an error when an unexpected lexed token is encountered.\n */\n\n\n unexpected(atToken) {\n const token = atToken ?? this._lexer.token;\n return syntaxError(this._lexer.source, token.start, `Unexpected ${getTokenDesc(token)}.`);\n }\n /**\n * Returns a possibly empty list of parse nodes, determined by the parseFn.\n * This list begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n\n\n any(openKind, parseFn, closeKind) {\n this.expectToken(openKind);\n const nodes = [];\n\n while (!this.expectOptionalToken(closeKind)) {\n nodes.push(parseFn.call(this));\n }\n\n return nodes;\n }\n /**\n * Returns a list of parse nodes, determined by the parseFn.\n * It can be empty only if open token is missing otherwise it will always return non-empty list\n * that begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n\n\n optionalMany(openKind, parseFn, closeKind) {\n if (this.expectOptionalToken(openKind)) {\n const nodes = [];\n\n do {\n nodes.push(parseFn.call(this));\n } while (!this.expectOptionalToken(closeKind));\n\n return nodes;\n }\n\n return [];\n }\n /**\n * Returns a non-empty list of parse nodes, determined by the parseFn.\n * This list begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n\n\n many(openKind, parseFn, closeKind) {\n this.expectToken(openKind);\n const nodes = [];\n\n do {\n nodes.push(parseFn.call(this));\n } while (!this.expectOptionalToken(closeKind));\n\n return nodes;\n }\n /**\n * Returns a non-empty list of parse nodes, determined by the parseFn.\n * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.\n * Advances the parser to the next lex token after last item in the list.\n */\n\n\n delimitedMany(delimiterKind, parseFn) {\n this.expectOptionalToken(delimiterKind);\n const nodes = [];\n\n do {\n nodes.push(parseFn.call(this));\n } while (this.expectOptionalToken(delimiterKind));\n\n return nodes;\n }\n\n}\n/**\n * A helper function to describe a token as a string for debugging.\n */\n\nfunction getTokenDesc(token) {\n const value = token.value;\n return getTokenKindDesc(token.kind) + (value != null ? ` \"${value}\"` : '');\n}\n/**\n * A helper function to describe a token kind as a string for debugging.\n */\n\n\nfunction getTokenKindDesc(kind) {\n return isPunctuatorTokenKind(kind) ? `\"${kind}\"` : kind;\n}\n","import inspect from \"../jsutils/inspect.mjs\";\nimport { isNode } from \"./ast.mjs\";\n/**\n * A visitor is provided to visit, it contains the collection of\n * relevant functions to be called during the visitor's traversal.\n */\n\nexport const QueryDocumentKeys = {\n Name: [],\n Document: ['definitions'],\n OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'],\n VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],\n Variable: ['name'],\n SelectionSet: ['selections'],\n Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],\n Argument: ['name', 'value'],\n FragmentSpread: ['name', 'directives'],\n InlineFragment: ['typeCondition', 'directives', 'selectionSet'],\n FragmentDefinition: ['name', // Note: fragment variable definitions are experimental and may be changed\n // or removed in the future.\n 'variableDefinitions', 'typeCondition', 'directives', 'selectionSet'],\n IntValue: [],\n FloatValue: [],\n StringValue: [],\n BooleanValue: [],\n NullValue: [],\n EnumValue: [],\n ListValue: ['values'],\n ObjectValue: ['fields'],\n ObjectField: ['name', 'value'],\n Directive: ['name', 'arguments'],\n NamedType: ['name'],\n ListType: ['type'],\n NonNullType: ['type'],\n SchemaDefinition: ['description', 'directives', 'operationTypes'],\n OperationTypeDefinition: ['type'],\n ScalarTypeDefinition: ['description', 'name', 'directives'],\n ObjectTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],\n FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'],\n InputValueDefinition: ['description', 'name', 'type', 'defaultValue', 'directives'],\n InterfaceTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],\n UnionTypeDefinition: ['description', 'name', 'directives', 'types'],\n EnumTypeDefinition: ['description', 'name', 'directives', 'values'],\n EnumValueDefinition: ['description', 'name', 'directives'],\n InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],\n DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],\n SchemaExtension: ['directives', 'operationTypes'],\n ScalarTypeExtension: ['name', 'directives'],\n ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],\n InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],\n UnionTypeExtension: ['name', 'directives', 'types'],\n EnumTypeExtension: ['name', 'directives', 'values'],\n InputObjectTypeExtension: ['name', 'directives', 'fields']\n};\nexport const BREAK = Object.freeze({});\n/**\n * visit() will walk through an AST using a depth-first traversal, calling\n * the visitor's enter function at each node in the traversal, and calling the\n * leave function after visiting that node and all of its child nodes.\n *\n * By returning different values from the enter and leave functions, the\n * behavior of the visitor can be altered, including skipping over a sub-tree of\n * the AST (by returning false), editing the AST by returning a value or null\n * to remove the value, or to stop the whole traversal by returning BREAK.\n *\n * When using visit() to edit an AST, the original AST will not be modified, and\n * a new version of the AST with the changes applied will be returned from the\n * visit function.\n *\n * const editedAST = visit(ast, {\n * enter(node, key, parent, path, ancestors) {\n * // @return\n * // undefined: no action\n * // false: skip visiting this node\n * // visitor.BREAK: stop visiting altogether\n * // null: delete this node\n * // any value: replace this node with the returned value\n * },\n * leave(node, key, parent, path, ancestors) {\n * // @return\n * // undefined: no action\n * // false: no action\n * // visitor.BREAK: stop visiting altogether\n * // null: delete this node\n * // any value: replace this node with the returned value\n * }\n * });\n *\n * Alternatively to providing enter() and leave() functions, a visitor can\n * instead provide functions named the same as the kinds of AST nodes, or\n * enter/leave visitors at a named key, leading to four permutations of the\n * visitor API:\n *\n * 1) Named visitors triggered when entering a node of a specific kind.\n *\n * visit(ast, {\n * Kind(node) {\n * // enter the \"Kind\" node\n * }\n * })\n *\n * 2) Named visitors that trigger upon entering and leaving a node of\n * a specific kind.\n *\n * visit(ast, {\n * Kind: {\n * enter(node) {\n * // enter the \"Kind\" node\n * }\n * leave(node) {\n * // leave the \"Kind\" node\n * }\n * }\n * })\n *\n * 3) Generic visitors that trigger upon entering and leaving any node.\n *\n * visit(ast, {\n * enter(node) {\n * // enter any node\n * },\n * leave(node) {\n * // leave any node\n * }\n * })\n *\n * 4) Parallel visitors for entering and leaving nodes of a specific kind.\n *\n * visit(ast, {\n * enter: {\n * Kind(node) {\n * // enter the \"Kind\" node\n * }\n * },\n * leave: {\n * Kind(node) {\n * // leave the \"Kind\" node\n * }\n * }\n * })\n */\n\nexport function visit(root, visitor, visitorKeys = QueryDocumentKeys) {\n /* eslint-disable no-undef-init */\n let stack = undefined;\n let inArray = Array.isArray(root);\n let keys = [root];\n let index = -1;\n let edits = [];\n let node = undefined;\n let key = undefined;\n let parent = undefined;\n const path = [];\n const ancestors = [];\n let newRoot = root;\n /* eslint-enable no-undef-init */\n\n do {\n index++;\n const isLeaving = index === keys.length;\n const isEdited = isLeaving && edits.length !== 0;\n\n if (isLeaving) {\n key = ancestors.length === 0 ? undefined : path[path.length - 1];\n node = parent;\n parent = ancestors.pop();\n\n if (isEdited) {\n if (inArray) {\n node = node.slice();\n } else {\n const clone = {};\n\n for (const k of Object.keys(node)) {\n clone[k] = node[k];\n }\n\n node = clone;\n }\n\n let editOffset = 0;\n\n for (let ii = 0; ii < edits.length; ii++) {\n let editKey = edits[ii][0];\n const editValue = edits[ii][1];\n\n if (inArray) {\n editKey -= editOffset;\n }\n\n if (inArray && editValue === null) {\n node.splice(editKey, 1);\n editOffset++;\n } else {\n node[editKey] = editValue;\n }\n }\n }\n\n index = stack.index;\n keys = stack.keys;\n edits = stack.edits;\n inArray = stack.inArray;\n stack = stack.prev;\n } else {\n key = parent ? inArray ? index : keys[index] : undefined;\n node = parent ? parent[key] : newRoot;\n\n if (node === null || node === undefined) {\n continue;\n }\n\n if (parent) {\n path.push(key);\n }\n }\n\n let result;\n\n if (!Array.isArray(node)) {\n if (!isNode(node)) {\n throw new Error(`Invalid AST Node: ${inspect(node)}.`);\n }\n\n const visitFn = getVisitFn(visitor, node.kind, isLeaving);\n\n if (visitFn) {\n result = visitFn.call(visitor, node, key, parent, path, ancestors);\n\n if (result === BREAK) {\n break;\n }\n\n if (result === false) {\n if (!isLeaving) {\n path.pop();\n continue;\n }\n } else if (result !== undefined) {\n edits.push([key, result]);\n\n if (!isLeaving) {\n if (isNode(result)) {\n node = result;\n } else {\n path.pop();\n continue;\n }\n }\n }\n }\n }\n\n if (result === undefined && isEdited) {\n edits.push([key, node]);\n }\n\n if (isLeaving) {\n path.pop();\n } else {\n stack = {\n inArray,\n index,\n keys,\n edits,\n prev: stack\n };\n inArray = Array.isArray(node);\n keys = inArray ? node : visitorKeys[node.kind] ?? [];\n index = -1;\n edits = [];\n\n if (parent) {\n ancestors.push(parent);\n }\n\n parent = node;\n }\n } while (stack !== undefined);\n\n if (edits.length !== 0) {\n newRoot = edits[edits.length - 1][1];\n }\n\n return newRoot;\n}\n/**\n * Creates a new visitor instance which delegates to many visitors to run in\n * parallel. Each visitor will be visited for each node before moving on.\n *\n * If a prior visitor edits a node, no following visitors will see that node.\n */\n\nexport function visitInParallel(visitors) {\n const skipping = new Array(visitors.length);\n return {\n enter(node) {\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] == null) {\n const fn = getVisitFn(visitors[i], node.kind,\n /* isLeaving */\n false);\n\n if (fn) {\n const result = fn.apply(visitors[i], arguments);\n\n if (result === false) {\n skipping[i] = node;\n } else if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined) {\n return result;\n }\n }\n }\n }\n },\n\n leave(node) {\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] == null) {\n const fn = getVisitFn(visitors[i], node.kind,\n /* isLeaving */\n true);\n\n if (fn) {\n const result = fn.apply(visitors[i], arguments);\n\n if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined && result !== false) {\n return result;\n }\n }\n } else if (skipping[i] === node) {\n skipping[i] = null;\n }\n }\n }\n\n };\n}\n/**\n * Given a visitor instance, if it is leaving or not, and a node kind, return\n * the function the visitor runtime should call.\n */\n\nexport function getVisitFn(visitor, kind, isLeaving) {\n const kindVisitor = visitor[kind];\n\n if (kindVisitor) {\n if (!isLeaving && typeof kindVisitor === 'function') {\n // { Kind() {} }\n return kindVisitor;\n }\n\n const kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter;\n\n if (typeof kindSpecificVisitor === 'function') {\n // { Kind: { enter() {}, leave() {} } }\n return kindSpecificVisitor;\n }\n } else {\n const specificVisitor = isLeaving ? visitor.leave : visitor.enter;\n\n if (specificVisitor) {\n if (typeof specificVisitor === 'function') {\n // { enter() {}, leave() {} }\n return specificVisitor;\n }\n\n const specificKindVisitor = specificVisitor[kind];\n\n if (typeof specificKindVisitor === 'function') {\n // { enter: { Kind() {} }, leave: { Kind() {} } }\n return specificKindVisitor;\n }\n }\n }\n}\n","/* eslint-disable no-redeclare */\n// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441\nconst objectValues = Object.values || (obj => Object.keys(obj).map(key => obj[key]));\n\nexport default objectValues;\n","import devAssert from \"../jsutils/devAssert.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nconst NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;\n/**\n * Upholds the spec rules about naming.\n */\n\nexport function assertValidName(name) {\n const error = isValidNameError(name);\n\n if (error) {\n throw error;\n }\n\n return name;\n}\n/**\n * Returns an Error if a name is invalid.\n */\n\nexport function isValidNameError(name) {\n typeof name === 'string' || devAssert(0, 'Expected name to be a string.');\n\n if (name.length > 1 && name[0] === '_' && name[1] === '_') {\n return new GraphQLError(`Name \"${name}\" must not begin with \"__\", which is reserved by GraphQL introspection.`);\n }\n\n if (!NAME_RX.test(name)) {\n return new GraphQLError(`Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \"${name}\" does not.`);\n }\n}\n","/* eslint-disable no-redeclare */\n// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441\nconst objectEntries = Object.entries || (obj => Object.keys(obj).map(key => [key, obj[key]]));\n\nexport default objectEntries;\n","/**\n * Creates a keyed JS object from an array, given a function to produce the keys\n * for each value in the array.\n *\n * This provides a convenient lookup for the array items if the key function\n * produces unique results.\n *\n * const phoneBook = [\n * { name: 'Jon', num: '555-1234' },\n * { name: 'Jenny', num: '867-5309' }\n * ]\n *\n * // { Jon: { name: 'Jon', num: '555-1234' },\n * // Jenny: { name: 'Jenny', num: '867-5309' } }\n * const entriesByName = keyMap(\n * phoneBook,\n * entry => entry.name\n * )\n *\n * // { name: 'Jenny', num: '857-6309' }\n * const jennyEntry = entriesByName['Jenny']\n *\n */\nexport default function keyMap(list, keyFn) {\n return list.reduce((map, item) => {\n map[keyFn(item)] = item;\n return map;\n }, Object.create(null));\n}\n","import objectEntries from \"../polyfills/objectEntries.mjs\";\n\n/**\n * Creates an object map with the same keys as `map` and values generated by\n * running each value of `map` thru `fn`.\n */\nexport default function mapValue(map, fn) {\n const result = Object.create(null);\n\n for (const [key, value] of objectEntries(map)) {\n result[key] = fn(value, key);\n }\n\n return result;\n}\n","import objectEntries from \"../polyfills/objectEntries.mjs\";\nexport default function toObjMap(obj) {\n /* eslint-enable no-redeclare */\n if (Object.getPrototypeOf(obj) === null) {\n return obj;\n }\n\n const map = Object.create(null);\n\n for (const [key, value] of objectEntries(obj)) {\n map[key] = value;\n }\n\n return map;\n}\n","/**\n * Creates a keyed JS object from an array, given a function to produce the keys\n * and a function to produce the values from each item in the array.\n *\n * const phoneBook = [\n * { name: 'Jon', num: '555-1234' },\n * { name: 'Jenny', num: '867-5309' }\n * ]\n *\n * // { Jon: '555-1234', Jenny: '867-5309' }\n * const phonesByName = keyValMap(\n * phoneBook,\n * entry => entry.name,\n * entry => entry.num\n * )\n *\n */\nexport default function keyValMap(list, keyFn, valFn) {\n return list.reduce((map, item) => {\n map[keyFn(item)] = valFn(item);\n return map;\n }, Object.create(null));\n}\n","const MAX_SUGGESTIONS = 5;\n/**\n * Given [ A, B, C ] return ' Did you mean A, B, or C?'.\n */\n\n// eslint-disable-next-line no-redeclare\nexport default function didYouMean(firstArg, secondArg) {\n const [subMessage, suggestionsArg] = typeof firstArg === 'string' ? [firstArg, secondArg] : [undefined, firstArg];\n let message = ' Did you mean ';\n\n if (subMessage) {\n message += subMessage + ' ';\n }\n\n const suggestions = suggestionsArg.map(x => `\"${x}\"`);\n\n switch (suggestions.length) {\n case 0:\n return '';\n\n case 1:\n return message + suggestions[0] + '?';\n\n case 2:\n return message + suggestions[0] + ' or ' + suggestions[1] + '?';\n }\n\n const selected = suggestions.slice(0, MAX_SUGGESTIONS);\n const lastItem = selected.pop();\n return message + selected.join(', ') + ', or ' + lastItem + '?';\n}\n","/**\n * Returns the first argument it receives.\n */\nexport default function identityFunc(x) {\n return x;\n}\n","/**\n * Given an invalid input string and a list of valid options, returns a filtered\n * list of valid options sorted based on their similarity with the input.\n */\nexport default function suggestionList(input, options) {\n const optionsByDistance = Object.create(null);\n const lexicalDistance = new LexicalDistance(input);\n const threshold = Math.floor(input.length * 0.4) + 1;\n\n for (const option of options) {\n const distance = lexicalDistance.measure(option, threshold);\n\n if (distance !== undefined) {\n optionsByDistance[option] = distance;\n }\n }\n\n return Object.keys(optionsByDistance).sort((a, b) => {\n const distanceDiff = optionsByDistance[a] - optionsByDistance[b];\n return distanceDiff !== 0 ? distanceDiff : a.localeCompare(b);\n });\n}\n/**\n * Computes the lexical distance between strings A and B.\n *\n * The \"distance\" between two strings is given by counting the minimum number\n * of edits needed to transform string A into string B. An edit can be an\n * insertion, deletion, or substitution of a single character, or a swap of two\n * adjacent characters.\n *\n * Includes a custom alteration from Damerau-Levenshtein to treat case changes\n * as a single edit which helps identify mis-cased values with an edit distance\n * of 1.\n *\n * This distance can be useful for detecting typos in input or sorting\n */\n\nclass LexicalDistance {\n constructor(input) {\n this._input = input;\n this._inputLowerCase = input.toLowerCase();\n this._inputArray = stringToArray(this._inputLowerCase);\n this._rows = [new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0)];\n }\n\n measure(option, threshold) {\n if (this._input === option) {\n return 0;\n }\n\n const optionLowerCase = option.toLowerCase(); // Any case change counts as a single edit\n\n if (this._inputLowerCase === optionLowerCase) {\n return 1;\n }\n\n let a = stringToArray(optionLowerCase);\n let b = this._inputArray;\n\n if (a.length < b.length) {\n const tmp = a;\n a = b;\n b = tmp;\n }\n\n const aLength = a.length;\n const bLength = b.length;\n\n if (aLength - bLength > threshold) {\n return undefined;\n }\n\n const rows = this._rows;\n\n for (let j = 0; j <= bLength; j++) {\n rows[0][j] = j;\n }\n\n for (let i = 1; i <= aLength; i++) {\n const upRow = rows[(i - 1) % 3];\n const currentRow = rows[i % 3];\n let smallestCell = currentRow[0] = i;\n\n for (let j = 1; j <= bLength; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n let currentCell = Math.min(upRow[j] + 1, // delete\n currentRow[j - 1] + 1, // insert\n upRow[j - 1] + cost // substitute\n );\n\n if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {\n // transposition\n const doubleDiagonalCell = rows[(i - 2) % 3][j - 2];\n currentCell = Math.min(currentCell, doubleDiagonalCell + 1);\n }\n\n if (currentCell < smallestCell) {\n smallestCell = currentCell;\n }\n\n currentRow[j] = currentCell;\n } // Early exit, since distance can't go smaller than smallest element of the previous row.\n\n\n if (smallestCell > threshold) {\n return undefined;\n }\n }\n\n const distance = rows[aLength % 3][bLength];\n return distance <= threshold ? distance : undefined;\n }\n\n}\n\nfunction stringToArray(str) {\n const strLength = str.length;\n const array = new Array(strLength);\n\n for (let i = 0; i < strLength; ++i) {\n array[i] = str.charCodeAt(i);\n }\n\n return array;\n}\n","import { visit } from \"./visitor.mjs\";\nimport { printBlockString } from \"./blockString.mjs\";\n/**\n * Converts an AST into a string, using one set of reasonable\n * formatting rules.\n */\n\nexport function print(ast) {\n return visit(ast, {\n leave: printDocASTReducer\n });\n}\nconst MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future\n\nconst printDocASTReducer = {\n Name: node => node.value,\n Variable: node => '$' + node.name,\n // Document\n Document: node => join(node.definitions, '\\n\\n') + '\\n',\n\n OperationDefinition(node) {\n const op = node.operation;\n const name = node.name;\n const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');\n const directives = join(node.directives, ' ');\n const selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use\n // the query short form.\n\n return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');\n },\n\n VariableDefinition: ({\n variable,\n type,\n defaultValue,\n directives\n }) => variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' ')),\n SelectionSet: ({\n selections\n }) => block(selections),\n Field: ({\n alias,\n name,\n arguments: args,\n directives,\n selectionSet\n }) => {\n const prefix = wrap('', alias, ': ') + name;\n let argsLine = prefix + wrap('(', join(args, ', '), ')');\n\n if (argsLine.length > MAX_LINE_LENGTH) {\n argsLine = prefix + wrap('(\\n', indent(join(args, '\\n')), '\\n)');\n }\n\n return join([argsLine, join(directives, ' '), selectionSet], ' ');\n },\n Argument: ({\n name,\n value\n }) => name + ': ' + value,\n // Fragments\n FragmentSpread: ({\n name,\n directives\n }) => '...' + name + wrap(' ', join(directives, ' ')),\n InlineFragment: ({\n typeCondition,\n directives,\n selectionSet\n }) => join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' '),\n FragmentDefinition: ({\n name,\n typeCondition,\n variableDefinitions,\n directives,\n selectionSet\n }) => // Note: fragment variable definitions are experimental and may be changed\n // or removed in the future.\n `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` + `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` + selectionSet,\n // Value\n IntValue: ({\n value\n }) => value,\n FloatValue: ({\n value\n }) => value,\n StringValue: ({\n value,\n block: isBlockString\n }, key) => isBlockString ? printBlockString(value, key === 'description' ? '' : ' ') : JSON.stringify(value),\n BooleanValue: ({\n value\n }) => value ? 'true' : 'false',\n NullValue: () => 'null',\n EnumValue: ({\n value\n }) => value,\n ListValue: ({\n values\n }) => '[' + join(values, ', ') + ']',\n ObjectValue: ({\n fields\n }) => '{' + join(fields, ', ') + '}',\n ObjectField: ({\n name,\n value\n }) => name + ': ' + value,\n // Directive\n Directive: ({\n name,\n arguments: args\n }) => '@' + name + wrap('(', join(args, ', '), ')'),\n // Type\n NamedType: ({\n name\n }) => name,\n ListType: ({\n type\n }) => '[' + type + ']',\n NonNullType: ({\n type\n }) => type + '!',\n // Type System Definitions\n SchemaDefinition: addDescription(({\n directives,\n operationTypes\n }) => join(['schema', join(directives, ' '), block(operationTypes)], ' ')),\n OperationTypeDefinition: ({\n operation,\n type\n }) => operation + ': ' + type,\n ScalarTypeDefinition: addDescription(({\n name,\n directives\n }) => join(['scalar', name, join(directives, ' ')], ' ')),\n ObjectTypeDefinition: addDescription(({\n name,\n interfaces,\n directives,\n fields\n }) => join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ')),\n FieldDefinition: addDescription(({\n name,\n arguments: args,\n type,\n directives\n }) => name + (hasMultilineItems(args) ? wrap('(\\n', indent(join(args, '\\n')), '\\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '))),\n InputValueDefinition: addDescription(({\n name,\n type,\n defaultValue,\n directives\n }) => join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ')),\n InterfaceTypeDefinition: addDescription(({\n name,\n interfaces,\n directives,\n fields\n }) => join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ')),\n UnionTypeDefinition: addDescription(({\n name,\n directives,\n types\n }) => join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ')),\n EnumTypeDefinition: addDescription(({\n name,\n directives,\n values\n }) => join(['enum', name, join(directives, ' '), block(values)], ' ')),\n EnumValueDefinition: addDescription(({\n name,\n directives\n }) => join([name, join(directives, ' ')], ' ')),\n InputObjectTypeDefinition: addDescription(({\n name,\n directives,\n fields\n }) => join(['input', name, join(directives, ' '), block(fields)], ' ')),\n DirectiveDefinition: addDescription(({\n name,\n arguments: args,\n repeatable,\n locations\n }) => 'directive @' + name + (hasMultilineItems(args) ? wrap('(\\n', indent(join(args, '\\n')), '\\n)') : wrap('(', join(args, ', '), ')')) + (repeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | ')),\n SchemaExtension: ({\n directives,\n operationTypes\n }) => join(['extend schema', join(directives, ' '), block(operationTypes)], ' '),\n ScalarTypeExtension: ({\n name,\n directives\n }) => join(['extend scalar', name, join(directives, ' ')], ' '),\n ObjectTypeExtension: ({\n name,\n interfaces,\n directives,\n fields\n }) => join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),\n InterfaceTypeExtension: ({\n name,\n interfaces,\n directives,\n fields\n }) => join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),\n UnionTypeExtension: ({\n name,\n directives,\n types\n }) => join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' '),\n EnumTypeExtension: ({\n name,\n directives,\n values\n }) => join(['extend enum', name, join(directives, ' '), block(values)], ' '),\n InputObjectTypeExtension: ({\n name,\n directives,\n fields\n }) => join(['extend input', name, join(directives, ' '), block(fields)], ' ')\n};\n\nfunction addDescription(cb) {\n return node => join([node.description, cb(node)], '\\n');\n}\n/**\n * Given maybeArray, print an empty string if it is null or empty, otherwise\n * print all items together separated by separator if provided\n */\n\n\nfunction join(maybeArray, separator = '') {\n return maybeArray?.filter(x => x).join(separator) ?? '';\n}\n/**\n * Given array, print each item on its own line, wrapped in an\n * indented \"{ }\" block.\n */\n\n\nfunction block(array) {\n return wrap('{\\n', indent(join(array, '\\n')), '\\n}');\n}\n/**\n * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.\n */\n\n\nfunction wrap(start, maybeString, end = '') {\n return maybeString != null && maybeString !== '' ? start + maybeString + end : '';\n}\n\nfunction indent(str) {\n return wrap(' ', str.replace(/\\n/g, '\\n '));\n}\n\nfunction isMultiline(str) {\n return str.indexOf('\\n') !== -1;\n}\n\nfunction hasMultilineItems(maybeArray) {\n return maybeArray != null && maybeArray.some(isMultiline);\n}\n","export default function invariant(condition, message) {\n const booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')\n\n if (!booleanCondition) {\n throw new Error(message != null ? message : 'Unexpected invariant triggered.');\n }\n}\n","import inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport keyValMap from \"../jsutils/keyValMap.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\n\n/**\n * Produces a JavaScript value given a GraphQL Value AST.\n *\n * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value\n * will reflect the provided GraphQL value AST.\n *\n * | GraphQL Value | JavaScript Value |\n * | -------------------- | ---------------- |\n * | Input Object | Object |\n * | List | Array |\n * | Boolean | Boolean |\n * | String / Enum | String |\n * | Int / Float | Number |\n * | Null | null |\n *\n */\nexport function valueFromASTUntyped(valueNode, variables) {\n switch (valueNode.kind) {\n case Kind.NULL:\n return null;\n\n case Kind.INT:\n return parseInt(valueNode.value, 10);\n\n case Kind.FLOAT:\n return parseFloat(valueNode.value);\n\n case Kind.STRING:\n case Kind.ENUM:\n case Kind.BOOLEAN:\n return valueNode.value;\n\n case Kind.LIST:\n return valueNode.values.map(node => valueFromASTUntyped(node, variables));\n\n case Kind.OBJECT:\n return keyValMap(valueNode.fields, field => field.name.value, field => valueFromASTUntyped(field.value, variables));\n\n case Kind.VARIABLE:\n return variables?.[valueNode.name.value];\n } // istanbul ignore next (Not reachable. All possible value nodes have been considered)\n\n\n false || invariant(0, 'Unexpected value node: ' + inspect(valueNode));\n}\n","import objectEntries from \"../polyfills/objectEntries.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport keyMap from \"../jsutils/keyMap.mjs\";\nimport mapValue from \"../jsutils/mapValue.mjs\";\nimport toObjMap from \"../jsutils/toObjMap.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport keyValMap from \"../jsutils/keyValMap.mjs\";\nimport instanceOf from \"../jsutils/instanceOf.mjs\";\nimport didYouMean from \"../jsutils/didYouMean.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport identityFunc from \"../jsutils/identityFunc.mjs\";\nimport suggestionList from \"../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { print } from \"../language/printer.mjs\";\nimport { valueFromASTUntyped } from \"../utilities/valueFromASTUntyped.mjs\";\nexport function isType(type) {\n return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type) || isListType(type) || isNonNullType(type);\n}\nexport function assertType(type) {\n if (!isType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL type.`);\n }\n\n return type;\n}\n/**\n * There are predicates for each kind of GraphQL type.\n */\n\n// eslint-disable-next-line no-redeclare\nexport function isScalarType(type) {\n return instanceOf(type, GraphQLScalarType);\n}\nexport function assertScalarType(type) {\n if (!isScalarType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Scalar type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isObjectType(type) {\n return instanceOf(type, GraphQLObjectType);\n}\nexport function assertObjectType(type) {\n if (!isObjectType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Object type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isInterfaceType(type) {\n return instanceOf(type, GraphQLInterfaceType);\n}\nexport function assertInterfaceType(type) {\n if (!isInterfaceType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Interface type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isUnionType(type) {\n return instanceOf(type, GraphQLUnionType);\n}\nexport function assertUnionType(type) {\n if (!isUnionType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Union type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isEnumType(type) {\n return instanceOf(type, GraphQLEnumType);\n}\nexport function assertEnumType(type) {\n if (!isEnumType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Enum type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isInputObjectType(type) {\n return instanceOf(type, GraphQLInputObjectType);\n}\nexport function assertInputObjectType(type) {\n if (!isInputObjectType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Input Object type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isListType(type) {\n return instanceOf(type, GraphQLList);\n}\nexport function assertListType(type) {\n if (!isListType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL List type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isNonNullType(type) {\n return instanceOf(type, GraphQLNonNull);\n}\nexport function assertNonNullType(type) {\n if (!isNonNullType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Non-Null type.`);\n }\n\n return type;\n}\n/**\n * These types may be used as input types for arguments and directives.\n */\n\nexport function isInputType(type) {\n return isScalarType(type) || isEnumType(type) || isInputObjectType(type) || isWrappingType(type) && isInputType(type.ofType);\n}\nexport function assertInputType(type) {\n if (!isInputType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL input type.`);\n }\n\n return type;\n}\n/**\n * These types may be used as output types as the result of fields.\n */\n\nexport function isOutputType(type) {\n return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isWrappingType(type) && isOutputType(type.ofType);\n}\nexport function assertOutputType(type) {\n if (!isOutputType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL output type.`);\n }\n\n return type;\n}\n/**\n * These types may describe types which may be leaf values.\n */\n\nexport function isLeafType(type) {\n return isScalarType(type) || isEnumType(type);\n}\nexport function assertLeafType(type) {\n if (!isLeafType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL leaf type.`);\n }\n\n return type;\n}\n/**\n * These types may describe the parent context of a selection set.\n */\n\nexport function isCompositeType(type) {\n return isObjectType(type) || isInterfaceType(type) || isUnionType(type);\n}\nexport function assertCompositeType(type) {\n if (!isCompositeType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL composite type.`);\n }\n\n return type;\n}\n/**\n * These types may describe the parent context of a selection set.\n */\n\nexport function isAbstractType(type) {\n return isInterfaceType(type) || isUnionType(type);\n}\nexport function assertAbstractType(type) {\n if (!isAbstractType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL abstract type.`);\n }\n\n return type;\n}\n/**\n * List Type Wrapper\n *\n * A list is a wrapping type which points to another type.\n * Lists are often created within the context of defining the fields of\n * an object type.\n *\n * Example:\n *\n * const PersonType = new GraphQLObjectType({\n * name: 'Person',\n * fields: () => ({\n * parents: { type: new GraphQLList(PersonType) },\n * children: { type: new GraphQLList(PersonType) },\n * })\n * })\n *\n */\n\nexport class GraphQLList {\n constructor(ofType) {\n isType(ofType) || devAssert(0, `Expected ${inspect(ofType)} to be a GraphQL type.`);\n this.ofType = ofType;\n }\n\n toString() {\n return '[' + String(this.ofType) + ']';\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLList';\n }\n\n}\n/**\n * Non-Null Type Wrapper\n *\n * A non-null is a wrapping type which points to another type.\n * Non-null types enforce that their values are never null and can ensure\n * an error is raised if this ever occurs during a request. It is useful for\n * fields which you can make a strong guarantee on non-nullability, for example\n * usually the id field of a database row will never be null.\n *\n * Example:\n *\n * const RowType = new GraphQLObjectType({\n * name: 'Row',\n * fields: () => ({\n * id: { type: new GraphQLNonNull(GraphQLString) },\n * })\n * })\n *\n * Note: the enforcement of non-nullability occurs within the executor.\n */\n\nexport class GraphQLNonNull {\n constructor(ofType) {\n isNullableType(ofType) || devAssert(0, `Expected ${inspect(ofType)} to be a GraphQL nullable type.`);\n this.ofType = ofType;\n }\n\n toString() {\n return String(this.ofType) + '!';\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLNonNull';\n }\n\n}\n/**\n * These types wrap and modify other types\n */\n\nexport function isWrappingType(type) {\n return isListType(type) || isNonNullType(type);\n}\nexport function assertWrappingType(type) {\n if (!isWrappingType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL wrapping type.`);\n }\n\n return type;\n}\n/**\n * These types can all accept null as a value.\n */\n\nexport function isNullableType(type) {\n return isType(type) && !isNonNullType(type);\n}\nexport function assertNullableType(type) {\n if (!isNullableType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL nullable type.`);\n }\n\n return type;\n}\n/* eslint-disable no-redeclare */\n\nexport function getNullableType(type) {\n /* eslint-enable no-redeclare */\n if (type) {\n return isNonNullType(type) ? type.ofType : type;\n }\n}\n/**\n * These named types do not include modifiers like List or NonNull.\n */\n\nexport function isNamedType(type) {\n return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type);\n}\nexport function assertNamedType(type) {\n if (!isNamedType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL named type.`);\n }\n\n return type;\n}\n/* eslint-disable no-redeclare */\n\nexport function getNamedType(type) {\n /* eslint-enable no-redeclare */\n if (type) {\n let unwrappedType = type;\n\n while (isWrappingType(unwrappedType)) {\n unwrappedType = unwrappedType.ofType;\n }\n\n return unwrappedType;\n }\n}\n/**\n * Used while defining GraphQL types to allow for circular references in\n * otherwise immutable type definitions.\n */\n\nfunction resolveThunk(thunk) {\n // $FlowFixMe[incompatible-use]\n return typeof thunk === 'function' ? thunk() : thunk;\n}\n\nfunction undefineIfEmpty(arr) {\n return arr && arr.length > 0 ? arr : undefined;\n}\n/**\n * Scalar Type Definition\n *\n * The leaf values of any request and input values to arguments are\n * Scalars (or Enums) and are defined with a name and a series of functions\n * used to parse input from ast or variables and to ensure validity.\n *\n * If a type's serialize function does not return a value (i.e. it returns\n * `undefined`) then an error will be raised and a `null` value will be returned\n * in the response. If the serialize function returns `null`, then no error will\n * be included in the response.\n *\n * Example:\n *\n * const OddType = new GraphQLScalarType({\n * name: 'Odd',\n * serialize(value) {\n * if (value % 2 === 1) {\n * return value;\n * }\n * }\n * });\n *\n */\n\n\nexport class GraphQLScalarType {\n constructor(config) {\n const parseValue = config.parseValue ?? identityFunc;\n this.name = config.name;\n this.description = config.description;\n this.specifiedByUrl = config.specifiedByUrl;\n this.serialize = config.serialize ?? identityFunc;\n this.parseValue = parseValue;\n\n this.parseLiteral = config.parseLiteral ?? ((node, variables) => parseValue(valueFromASTUntyped(node, variables)));\n\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n config.specifiedByUrl == null || typeof config.specifiedByUrl === 'string' || devAssert(0, `${this.name} must provide \"specifiedByUrl\" as a string, ` + `but got: ${inspect(config.specifiedByUrl)}.`);\n config.serialize == null || typeof config.serialize === 'function' || devAssert(0, `${this.name} must provide \"serialize\" function. If this custom Scalar is also used as an input type, ensure \"parseValue\" and \"parseLiteral\" functions are also provided.`);\n\n if (config.parseLiteral) {\n typeof config.parseValue === 'function' && typeof config.parseLiteral === 'function' || devAssert(0, `${this.name} must provide both \"parseValue\" and \"parseLiteral\" functions.`);\n }\n }\n\n toConfig() {\n return {\n name: this.name,\n description: this.description,\n specifiedByUrl: this.specifiedByUrl,\n serialize: this.serialize,\n parseValue: this.parseValue,\n parseLiteral: this.parseLiteral,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLScalarType';\n }\n\n}\n\n/**\n * Object Type Definition\n *\n * Almost all of the GraphQL types you define will be object types. Object types\n * have a name, but most importantly describe their fields.\n *\n * Example:\n *\n * const AddressType = new GraphQLObjectType({\n * name: 'Address',\n * fields: {\n * street: { type: GraphQLString },\n * number: { type: GraphQLInt },\n * formatted: {\n * type: GraphQLString,\n * resolve(obj) {\n * return obj.number + ' ' + obj.street\n * }\n * }\n * }\n * });\n *\n * When two types need to refer to each other, or a type needs to refer to\n * itself in a field, you can use a function expression (aka a closure or a\n * thunk) to supply the fields lazily.\n *\n * Example:\n *\n * const PersonType = new GraphQLObjectType({\n * name: 'Person',\n * fields: () => ({\n * name: { type: GraphQLString },\n * bestFriend: { type: PersonType },\n * })\n * });\n *\n */\nexport class GraphQLObjectType {\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.isTypeOf = config.isTypeOf;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n this._fields = defineFieldMap.bind(undefined, config);\n this._interfaces = defineInterfaces.bind(undefined, config);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n config.isTypeOf == null || typeof config.isTypeOf === 'function' || devAssert(0, `${this.name} must provide \"isTypeOf\" as a function, ` + `but got: ${inspect(config.isTypeOf)}.`);\n }\n\n getFields() {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n\n return this._fields;\n }\n\n getInterfaces() {\n if (typeof this._interfaces === 'function') {\n this._interfaces = this._interfaces();\n }\n\n return this._interfaces;\n }\n\n toConfig() {\n return {\n name: this.name,\n description: this.description,\n interfaces: this.getInterfaces(),\n fields: fieldsToFieldsConfig(this.getFields()),\n isTypeOf: this.isTypeOf,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes || []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLObjectType';\n }\n\n}\n\nfunction defineInterfaces(config) {\n const interfaces = resolveThunk(config.interfaces) ?? [];\n Array.isArray(interfaces) || devAssert(0, `${config.name} interfaces must be an Array or a function which returns an Array.`);\n return interfaces;\n}\n\nfunction defineFieldMap(config) {\n const fieldMap = resolveThunk(config.fields);\n isPlainObj(fieldMap) || devAssert(0, `${config.name} fields must be an object with field names as keys or a function which returns such an object.`);\n return mapValue(fieldMap, (fieldConfig, fieldName) => {\n isPlainObj(fieldConfig) || devAssert(0, `${config.name}.${fieldName} field config must be an object.`);\n fieldConfig.resolve == null || typeof fieldConfig.resolve === 'function' || devAssert(0, `${config.name}.${fieldName} field resolver must be a function if ` + `provided, but got: ${inspect(fieldConfig.resolve)}.`);\n const argsConfig = fieldConfig.args ?? {};\n isPlainObj(argsConfig) || devAssert(0, `${config.name}.${fieldName} args must be an object with argument names as keys.`);\n const args = objectEntries(argsConfig).map(([argName, argConfig]) => ({\n name: argName,\n description: argConfig.description,\n type: argConfig.type,\n defaultValue: argConfig.defaultValue,\n deprecationReason: argConfig.deprecationReason,\n extensions: argConfig.extensions && toObjMap(argConfig.extensions),\n astNode: argConfig.astNode\n }));\n return {\n name: fieldName,\n description: fieldConfig.description,\n type: fieldConfig.type,\n args,\n resolve: fieldConfig.resolve,\n subscribe: fieldConfig.subscribe,\n deprecationReason: fieldConfig.deprecationReason,\n extensions: fieldConfig.extensions && toObjMap(fieldConfig.extensions),\n astNode: fieldConfig.astNode\n };\n });\n}\n\nfunction isPlainObj(obj) {\n return isObjectLike(obj) && !Array.isArray(obj);\n}\n\nfunction fieldsToFieldsConfig(fields) {\n return mapValue(fields, field => ({\n description: field.description,\n type: field.type,\n args: argsToArgsConfig(field.args),\n resolve: field.resolve,\n subscribe: field.subscribe,\n deprecationReason: field.deprecationReason,\n extensions: field.extensions,\n astNode: field.astNode\n }));\n}\n/**\n * @internal\n */\n\n\nexport function argsToArgsConfig(args) {\n return keyValMap(args, arg => arg.name, arg => ({\n description: arg.description,\n type: arg.type,\n defaultValue: arg.defaultValue,\n deprecationReason: arg.deprecationReason,\n extensions: arg.extensions,\n astNode: arg.astNode\n }));\n}\nexport function isRequiredArgument(arg) {\n return isNonNullType(arg.type) && arg.defaultValue === undefined;\n}\n\n/**\n * Interface Type Definition\n *\n * When a field can return one of a heterogeneous set of types, a Interface type\n * is used to describe what types are possible, what fields are in common across\n * all types, as well as a function to determine which type is actually used\n * when the field is resolved.\n *\n * Example:\n *\n * const EntityType = new GraphQLInterfaceType({\n * name: 'Entity',\n * fields: {\n * name: { type: GraphQLString }\n * }\n * });\n *\n */\nexport class GraphQLInterfaceType {\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.resolveType = config.resolveType;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n this._fields = defineFieldMap.bind(undefined, config);\n this._interfaces = defineInterfaces.bind(undefined, config);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n config.resolveType == null || typeof config.resolveType === 'function' || devAssert(0, `${this.name} must provide \"resolveType\" as a function, ` + `but got: ${inspect(config.resolveType)}.`);\n }\n\n getFields() {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n\n return this._fields;\n }\n\n getInterfaces() {\n if (typeof this._interfaces === 'function') {\n this._interfaces = this._interfaces();\n }\n\n return this._interfaces;\n }\n\n toConfig() {\n return {\n name: this.name,\n description: this.description,\n interfaces: this.getInterfaces(),\n fields: fieldsToFieldsConfig(this.getFields()),\n resolveType: this.resolveType,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLInterfaceType';\n }\n\n}\n\n/**\n * Union Type Definition\n *\n * When a field can return one of a heterogeneous set of types, a Union type\n * is used to describe what types are possible as well as providing a function\n * to determine which type is actually used when the field is resolved.\n *\n * Example:\n *\n * const PetType = new GraphQLUnionType({\n * name: 'Pet',\n * types: [ DogType, CatType ],\n * resolveType(value) {\n * if (value instanceof Dog) {\n * return DogType;\n * }\n * if (value instanceof Cat) {\n * return CatType;\n * }\n * }\n * });\n *\n */\nexport class GraphQLUnionType {\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.resolveType = config.resolveType;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n this._types = defineTypes.bind(undefined, config);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n config.resolveType == null || typeof config.resolveType === 'function' || devAssert(0, `${this.name} must provide \"resolveType\" as a function, ` + `but got: ${inspect(config.resolveType)}.`);\n }\n\n getTypes() {\n if (typeof this._types === 'function') {\n this._types = this._types();\n }\n\n return this._types;\n }\n\n toConfig() {\n return {\n name: this.name,\n description: this.description,\n types: this.getTypes(),\n resolveType: this.resolveType,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLUnionType';\n }\n\n}\n\nfunction defineTypes(config) {\n const types = resolveThunk(config.types);\n Array.isArray(types) || devAssert(0, `Must provide Array of types or a function which returns such an array for Union ${config.name}.`);\n return types;\n}\n\n/**\n * Enum Type Definition\n *\n * Some leaf values of requests and input values are Enums. GraphQL serializes\n * Enum values as strings, however internally Enums can be represented by any\n * kind of type, often integers.\n *\n * Example:\n *\n * const RGBType = new GraphQLEnumType({\n * name: 'RGB',\n * values: {\n * RED: { value: 0 },\n * GREEN: { value: 1 },\n * BLUE: { value: 2 }\n * }\n * });\n *\n * Note: If a value is not provided in a definition, the name of the enum value\n * will be used as its internal value.\n */\nexport class GraphQLEnumType\n/* */\n{\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n this._values = defineEnumValues(this.name, config.values);\n this._valueLookup = new Map(this._values.map(enumValue => [enumValue.value, enumValue]));\n this._nameLookup = keyMap(this._values, value => value.name);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n }\n\n getValues() {\n return this._values;\n }\n\n getValue(name) {\n return this._nameLookup[name];\n }\n\n serialize(outputValue) {\n const enumValue = this._valueLookup.get(outputValue);\n\n if (enumValue === undefined) {\n throw new GraphQLError(`Enum \"${this.name}\" cannot represent value: ${inspect(outputValue)}`);\n }\n\n return enumValue.name;\n }\n\n parseValue(inputValue)\n /* T */\n {\n if (typeof inputValue !== 'string') {\n const valueStr = inspect(inputValue);\n throw new GraphQLError(`Enum \"${this.name}\" cannot represent non-string value: ${valueStr}.` + didYouMeanEnumValue(this, valueStr));\n }\n\n const enumValue = this.getValue(inputValue);\n\n if (enumValue == null) {\n throw new GraphQLError(`Value \"${inputValue}\" does not exist in \"${this.name}\" enum.` + didYouMeanEnumValue(this, inputValue));\n }\n\n return enumValue.value;\n }\n\n parseLiteral(valueNode, _variables)\n /* T */\n {\n // Note: variables will be resolved to a value before calling this function.\n if (valueNode.kind !== Kind.ENUM) {\n const valueStr = print(valueNode);\n throw new GraphQLError(`Enum \"${this.name}\" cannot represent non-enum value: ${valueStr}.` + didYouMeanEnumValue(this, valueStr), valueNode);\n }\n\n const enumValue = this.getValue(valueNode.value);\n\n if (enumValue == null) {\n const valueStr = print(valueNode);\n throw new GraphQLError(`Value \"${valueStr}\" does not exist in \"${this.name}\" enum.` + didYouMeanEnumValue(this, valueStr), valueNode);\n }\n\n return enumValue.value;\n }\n\n toConfig() {\n const values = keyValMap(this.getValues(), value => value.name, value => ({\n description: value.description,\n value: value.value,\n deprecationReason: value.deprecationReason,\n extensions: value.extensions,\n astNode: value.astNode\n }));\n return {\n name: this.name,\n description: this.description,\n values,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLEnumType';\n }\n\n}\n\nfunction didYouMeanEnumValue(enumType, unknownValueStr) {\n const allNames = enumType.getValues().map(value => value.name);\n const suggestedValues = suggestionList(unknownValueStr, allNames);\n return didYouMean('the enum value', suggestedValues);\n}\n\nfunction defineEnumValues(typeName, valueMap) {\n isPlainObj(valueMap) || devAssert(0, `${typeName} values must be an object with value names as keys.`);\n return objectEntries(valueMap).map(([valueName, valueConfig]) => {\n isPlainObj(valueConfig) || devAssert(0, `${typeName}.${valueName} must refer to an object with a \"value\" key ` + `representing an internal value but got: ${inspect(valueConfig)}.`);\n return {\n name: valueName,\n description: valueConfig.description,\n value: valueConfig.value !== undefined ? valueConfig.value : valueName,\n deprecationReason: valueConfig.deprecationReason,\n extensions: valueConfig.extensions && toObjMap(valueConfig.extensions),\n astNode: valueConfig.astNode\n };\n });\n}\n\n/**\n * Input Object Type Definition\n *\n * An input object defines a structured collection of fields which may be\n * supplied to a field argument.\n *\n * Using `NonNull` will ensure that a value must be provided by the query\n *\n * Example:\n *\n * const GeoPoint = new GraphQLInputObjectType({\n * name: 'GeoPoint',\n * fields: {\n * lat: { type: new GraphQLNonNull(GraphQLFloat) },\n * lon: { type: new GraphQLNonNull(GraphQLFloat) },\n * alt: { type: GraphQLFloat, defaultValue: 0 },\n * }\n * });\n *\n */\nexport class GraphQLInputObjectType {\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n this._fields = defineInputFieldMap.bind(undefined, config);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n }\n\n getFields() {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n\n return this._fields;\n }\n\n toConfig() {\n const fields = mapValue(this.getFields(), field => ({\n description: field.description,\n type: field.type,\n defaultValue: field.defaultValue,\n extensions: field.extensions,\n astNode: field.astNode\n }));\n return {\n name: this.name,\n description: this.description,\n fields,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLInputObjectType';\n }\n\n}\n\nfunction defineInputFieldMap(config) {\n const fieldMap = resolveThunk(config.fields);\n isPlainObj(fieldMap) || devAssert(0, `${config.name} fields must be an object with field names as keys or a function which returns such an object.`);\n return mapValue(fieldMap, (fieldConfig, fieldName) => {\n !('resolve' in fieldConfig) || devAssert(0, `${config.name}.${fieldName} field has a resolve property, but Input Types cannot define resolvers.`);\n return {\n name: fieldName,\n description: fieldConfig.description,\n type: fieldConfig.type,\n defaultValue: fieldConfig.defaultValue,\n deprecationReason: fieldConfig.deprecationReason,\n extensions: fieldConfig.extensions && toObjMap(fieldConfig.extensions),\n astNode: fieldConfig.astNode\n };\n });\n}\n\nexport function isRequiredInputField(field) {\n return isNonNullType(field.type) && field.defaultValue === undefined;\n}\n","import { isInterfaceType, isObjectType, isListType, isNonNullType, isAbstractType } from \"../type/definition.mjs\";\n/**\n * Provided two types, return true if the types are equal (invariant).\n */\n\nexport function isEqualType(typeA, typeB) {\n // Equivalent types are equal.\n if (typeA === typeB) {\n return true;\n } // If either type is non-null, the other must also be non-null.\n\n\n if (isNonNullType(typeA) && isNonNullType(typeB)) {\n return isEqualType(typeA.ofType, typeB.ofType);\n } // If either type is a list, the other must also be a list.\n\n\n if (isListType(typeA) && isListType(typeB)) {\n return isEqualType(typeA.ofType, typeB.ofType);\n } // Otherwise the types are not equal.\n\n\n return false;\n}\n/**\n * Provided a type and a super type, return true if the first type is either\n * equal or a subset of the second super type (covariant).\n */\n\nexport function isTypeSubTypeOf(schema, maybeSubType, superType) {\n // Equivalent type is a valid subtype\n if (maybeSubType === superType) {\n return true;\n } // If superType is non-null, maybeSubType must also be non-null.\n\n\n if (isNonNullType(superType)) {\n if (isNonNullType(maybeSubType)) {\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);\n }\n\n return false;\n }\n\n if (isNonNullType(maybeSubType)) {\n // If superType is nullable, maybeSubType may be non-null or nullable.\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);\n } // If superType type is a list, maybeSubType type must also be a list.\n\n\n if (isListType(superType)) {\n if (isListType(maybeSubType)) {\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);\n }\n\n return false;\n }\n\n if (isListType(maybeSubType)) {\n // If superType is not a list, maybeSubType must also be not a list.\n return false;\n } // If superType type is an abstract type, check if it is super type of maybeSubType.\n // Otherwise, the child type is not a valid subtype of the parent type.\n\n\n return isAbstractType(superType) && (isInterfaceType(maybeSubType) || isObjectType(maybeSubType)) && schema.isSubType(superType, maybeSubType);\n}\n/**\n * Provided two composite types, determine if they \"overlap\". Two composite\n * types overlap when the Sets of possible concrete types for each intersect.\n *\n * This is often used to determine if a fragment of a given type could possibly\n * be visited in a context of another type.\n *\n * This function is commutative.\n */\n\nexport function doTypesOverlap(schema, typeA, typeB) {\n // Equivalent types overlap\n if (typeA === typeB) {\n return true;\n }\n\n if (isAbstractType(typeA)) {\n if (isAbstractType(typeB)) {\n // If both types are abstract, then determine if there is any intersection\n // between possible concrete types of each.\n return schema.getPossibleTypes(typeA).some(type => schema.isSubType(typeB, type));\n } // Determine if the latter type is a possible concrete type of the former.\n\n\n return schema.isSubType(typeA, typeB);\n }\n\n if (isAbstractType(typeB)) {\n // Determine if the former type is a possible concrete type of the latter.\n return schema.isSubType(typeB, typeA);\n } // Otherwise the types do not overlap.\n\n\n return false;\n}\n","import inspect from \"../jsutils/inspect.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { print } from \"../language/printer.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nimport { GraphQLScalarType } from \"./definition.mjs\"; // As per the GraphQL Spec, Integers are only treated as valid when a valid\n// 32-bit signed integer, providing the broadest support across platforms.\n//\n// n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because\n// they are internally represented as IEEE 754 doubles.\n\nconst MAX_INT = 2147483647;\nconst MIN_INT = -2147483648;\n\nfunction serializeInt(outputValue) {\n const coercedValue = serializeObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 1 : 0;\n }\n\n let num = coercedValue;\n\n if (typeof coercedValue === 'string' && coercedValue !== '') {\n num = Number(coercedValue);\n }\n\n if (typeof num !== 'number' || !Number.isInteger(num)) {\n throw new GraphQLError(`Int cannot represent non-integer value: ${inspect(coercedValue)}`);\n }\n\n if (num > MAX_INT || num < MIN_INT) {\n throw new GraphQLError('Int cannot represent non 32-bit signed integer value: ' + inspect(coercedValue));\n }\n\n return num;\n}\n\nfunction coerceInt(inputValue) {\n if (typeof inputValue !== 'number' || !Number.isInteger(inputValue)) {\n throw new GraphQLError(`Int cannot represent non-integer value: ${inspect(inputValue)}`);\n }\n\n if (inputValue > MAX_INT || inputValue < MIN_INT) {\n throw new GraphQLError(`Int cannot represent non 32-bit signed integer value: ${inputValue}`);\n }\n\n return inputValue;\n}\n\nexport const GraphQLInt = new GraphQLScalarType({\n name: 'Int',\n description: 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.',\n serialize: serializeInt,\n parseValue: coerceInt,\n\n parseLiteral(valueNode) {\n if (valueNode.kind !== Kind.INT) {\n throw new GraphQLError(`Int cannot represent non-integer value: ${print(valueNode)}`, valueNode);\n }\n\n const num = parseInt(valueNode.value, 10);\n\n if (num > MAX_INT || num < MIN_INT) {\n throw new GraphQLError(`Int cannot represent non 32-bit signed integer value: ${valueNode.value}`, valueNode);\n }\n\n return num;\n }\n\n});\n\nfunction serializeFloat(outputValue) {\n const coercedValue = serializeObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 1 : 0;\n }\n\n let num = coercedValue;\n\n if (typeof coercedValue === 'string' && coercedValue !== '') {\n num = Number(coercedValue);\n }\n\n if (typeof num !== 'number' || !Number.isFinite(num)) {\n throw new GraphQLError(`Float cannot represent non numeric value: ${inspect(coercedValue)}`);\n }\n\n return num;\n}\n\nfunction coerceFloat(inputValue) {\n if (typeof inputValue !== 'number' || !Number.isFinite(inputValue)) {\n throw new GraphQLError(`Float cannot represent non numeric value: ${inspect(inputValue)}`);\n }\n\n return inputValue;\n}\n\nexport const GraphQLFloat = new GraphQLScalarType({\n name: 'Float',\n description: 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).',\n serialize: serializeFloat,\n parseValue: coerceFloat,\n\n parseLiteral(valueNode) {\n if (valueNode.kind !== Kind.FLOAT && valueNode.kind !== Kind.INT) {\n throw new GraphQLError(`Float cannot represent non numeric value: ${print(valueNode)}`, valueNode);\n }\n\n return parseFloat(valueNode.value);\n }\n\n}); // Support serializing objects with custom valueOf() or toJSON() functions -\n// a common way to represent a complex value which can be represented as\n// a string (ex: MongoDB id objects).\n\nfunction serializeObject(outputValue) {\n if (isObjectLike(outputValue)) {\n if (typeof outputValue.valueOf === 'function') {\n const valueOfResult = outputValue.valueOf();\n\n if (!isObjectLike(valueOfResult)) {\n return valueOfResult;\n }\n }\n\n if (typeof outputValue.toJSON === 'function') {\n // $FlowFixMe[incompatible-use]\n return outputValue.toJSON();\n }\n }\n\n return outputValue;\n}\n\nfunction serializeString(outputValue) {\n const coercedValue = serializeObject(outputValue); // Serialize string, boolean and number values to a string, but do not\n // attempt to coerce object, function, symbol, or other types as strings.\n\n if (typeof coercedValue === 'string') {\n return coercedValue;\n }\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 'true' : 'false';\n }\n\n if (typeof coercedValue === 'number' && Number.isFinite(coercedValue)) {\n return coercedValue.toString();\n }\n\n throw new GraphQLError(`String cannot represent value: ${inspect(outputValue)}`);\n}\n\nfunction coerceString(inputValue) {\n if (typeof inputValue !== 'string') {\n throw new GraphQLError(`String cannot represent a non string value: ${inspect(inputValue)}`);\n }\n\n return inputValue;\n}\n\nexport const GraphQLString = new GraphQLScalarType({\n name: 'String',\n description: 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.',\n serialize: serializeString,\n parseValue: coerceString,\n\n parseLiteral(valueNode) {\n if (valueNode.kind !== Kind.STRING) {\n throw new GraphQLError(`String cannot represent a non string value: ${print(valueNode)}`, valueNode);\n }\n\n return valueNode.value;\n }\n\n});\n\nfunction serializeBoolean(outputValue) {\n const coercedValue = serializeObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue;\n }\n\n if (Number.isFinite(coercedValue)) {\n return coercedValue !== 0;\n }\n\n throw new GraphQLError(`Boolean cannot represent a non boolean value: ${inspect(coercedValue)}`);\n}\n\nfunction coerceBoolean(inputValue) {\n if (typeof inputValue !== 'boolean') {\n throw new GraphQLError(`Boolean cannot represent a non boolean value: ${inspect(inputValue)}`);\n }\n\n return inputValue;\n}\n\nexport const GraphQLBoolean = new GraphQLScalarType({\n name: 'Boolean',\n description: 'The `Boolean` scalar type represents `true` or `false`.',\n serialize: serializeBoolean,\n parseValue: coerceBoolean,\n\n parseLiteral(valueNode) {\n if (valueNode.kind !== Kind.BOOLEAN) {\n throw new GraphQLError(`Boolean cannot represent a non boolean value: ${print(valueNode)}`, valueNode);\n }\n\n return valueNode.value;\n }\n\n});\n\nfunction serializeID(outputValue) {\n const coercedValue = serializeObject(outputValue);\n\n if (typeof coercedValue === 'string') {\n return coercedValue;\n }\n\n if (Number.isInteger(coercedValue)) {\n return String(coercedValue);\n }\n\n throw new GraphQLError(`ID cannot represent value: ${inspect(outputValue)}`);\n}\n\nfunction coerceID(inputValue) {\n if (typeof inputValue === 'string') {\n return inputValue;\n }\n\n if (typeof inputValue === 'number' && Number.isInteger(inputValue)) {\n return inputValue.toString();\n }\n\n throw new GraphQLError(`ID cannot represent value: ${inspect(inputValue)}`);\n}\n\nexport const GraphQLID = new GraphQLScalarType({\n name: 'ID',\n description: '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.',\n serialize: serializeID,\n parseValue: coerceID,\n\n parseLiteral(valueNode) {\n if (valueNode.kind !== Kind.STRING && valueNode.kind !== Kind.INT) {\n throw new GraphQLError('ID cannot represent a non-string and non-integer value: ' + print(valueNode), valueNode);\n }\n\n return valueNode.value;\n }\n\n});\nexport const specifiedScalarTypes = Object.freeze([GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLID]);\nexport function isSpecifiedScalarType(type) {\n return specifiedScalarTypes.some(({\n name\n }) => type.name === name);\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport isCollection from \"../jsutils/isCollection.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { GraphQLID } from \"../type/scalars.mjs\";\nimport { isLeafType, isEnumType, isInputObjectType, isListType, isNonNullType } from \"../type/definition.mjs\";\n/**\n * Produces a GraphQL Value AST given a JavaScript object.\n * Function will match JavaScript/JSON values to GraphQL AST schema format\n * by using suggested GraphQLInputType. For example:\n *\n * astFromValue(\"value\", GraphQLString)\n *\n * A GraphQL type must be provided, which will be used to interpret different\n * JavaScript values.\n *\n * | JSON Value | GraphQL Value |\n * | ------------- | -------------------- |\n * | Object | Input Object |\n * | Array | List |\n * | Boolean | Boolean |\n * | String | String / Enum Value |\n * | Number | Int / Float |\n * | Mixed | Enum Value |\n * | null | NullValue |\n *\n */\n\nexport function astFromValue(value, type) {\n if (isNonNullType(type)) {\n const astValue = astFromValue(value, type.ofType);\n\n if (astValue?.kind === Kind.NULL) {\n return null;\n }\n\n return astValue;\n } // only explicit null, not undefined, NaN\n\n\n if (value === null) {\n return {\n kind: Kind.NULL\n };\n } // undefined\n\n\n if (value === undefined) {\n return null;\n } // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but\n // the value is not an array, convert the value using the list's item type.\n\n\n if (isListType(type)) {\n const itemType = type.ofType;\n\n if (isCollection(value)) {\n const valuesNodes = []; // Since we transpile for-of in loose mode it doesn't support iterators\n // and it's required to first convert iteratable into array\n\n for (const item of Array.from(value)) {\n const itemNode = astFromValue(item, itemType);\n\n if (itemNode != null) {\n valuesNodes.push(itemNode);\n }\n }\n\n return {\n kind: Kind.LIST,\n values: valuesNodes\n };\n }\n\n return astFromValue(value, itemType);\n } // Populate the fields of the input object by creating ASTs from each value\n // in the JavaScript object according to the fields in the input type.\n\n\n if (isInputObjectType(type)) {\n if (!isObjectLike(value)) {\n return null;\n }\n\n const fieldNodes = [];\n\n for (const field of objectValues(type.getFields())) {\n const fieldValue = astFromValue(value[field.name], field.type);\n\n if (fieldValue) {\n fieldNodes.push({\n kind: Kind.OBJECT_FIELD,\n name: {\n kind: Kind.NAME,\n value: field.name\n },\n value: fieldValue\n });\n }\n }\n\n return {\n kind: Kind.OBJECT,\n fields: fieldNodes\n };\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isLeafType(type)) {\n // Since value is an internally represented value, it must be serialized\n // to an externally represented value before converting into an AST.\n const serialized = type.serialize(value);\n\n if (serialized == null) {\n return null;\n } // Others serialize based on their corresponding JavaScript scalar types.\n\n\n if (typeof serialized === 'boolean') {\n return {\n kind: Kind.BOOLEAN,\n value: serialized\n };\n } // JavaScript numbers can be Int or Float values.\n\n\n if (typeof serialized === 'number' && Number.isFinite(serialized)) {\n const stringNum = String(serialized);\n return integerStringRegExp.test(stringNum) ? {\n kind: Kind.INT,\n value: stringNum\n } : {\n kind: Kind.FLOAT,\n value: stringNum\n };\n }\n\n if (typeof serialized === 'string') {\n // Enum types use Enum literals.\n if (isEnumType(type)) {\n return {\n kind: Kind.ENUM,\n value: serialized\n };\n } // ID types can use Int literals.\n\n\n if (type === GraphQLID && integerStringRegExp.test(serialized)) {\n return {\n kind: Kind.INT,\n value: serialized\n };\n }\n\n return {\n kind: Kind.STRING,\n value: serialized\n };\n }\n\n throw new TypeError(`Cannot convert value to AST: ${inspect(serialized)}.`);\n } // istanbul ignore next (Not reachable. All possible input types have been considered)\n\n\n false || invariant(0, 'Unexpected input type: ' + inspect(type));\n}\n/**\n * IntValue:\n * - NegativeSign? 0\n * - NegativeSign? NonZeroDigit ( Digit+ )?\n */\n\nconst integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/;\n","/**\n * Returns true if the provided object is an Object (i.e. not a string literal)\n * and is either Iterable or Array-like.\n *\n * This may be used in place of [Array.isArray()][isArray] to determine if an\n * object should be iterated-over. It always excludes string literals and\n * includes Arrays (regardless of if it is Iterable). It also includes other\n * Array-like objects such as NodeList, TypedArray, and Buffer.\n *\n * @example\n *\n * isCollection([ 1, 2, 3 ]) // true\n * isCollection('ABC') // false\n * isCollection({ length: 1, 0: 'Alpha' }) // true\n * isCollection({ key: 'value' }) // false\n * isCollection(new Map()) // true\n *\n * @param obj\n * An Object value which might implement the Iterable or Array-like protocols.\n * @return {boolean} true if Iterable or Array-like Object.\n */\n// eslint-disable-next-line no-redeclare\nexport default function isCollection(obj) {\n if (obj == null || typeof obj !== 'object') {\n return false;\n } // Is Array like?\n\n\n const length = obj.length;\n\n if (typeof length === 'number' && length >= 0 && length % 1 === 0) {\n return true;\n } // Is Iterable?\n\n\n return typeof obj[Symbol.iterator] === 'function';\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport { print } from \"../language/printer.mjs\";\nimport { DirectiveLocation } from \"../language/directiveLocation.mjs\";\nimport { astFromValue } from \"../utilities/astFromValue.mjs\";\nimport { GraphQLString, GraphQLBoolean } from \"./scalars.mjs\";\nimport { GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLEnumType, isScalarType, isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isListType, isNonNullType, isAbstractType } from \"./definition.mjs\";\nexport const __Schema = new GraphQLObjectType({\n name: '__Schema',\n description: 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.',\n fields: () => ({\n description: {\n type: GraphQLString,\n resolve: schema => schema.description\n },\n types: {\n description: 'A list of all types supported by this server.',\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Type))),\n\n resolve(schema) {\n return objectValues(schema.getTypeMap());\n }\n\n },\n queryType: {\n description: 'The type that query operations will be rooted at.',\n type: new GraphQLNonNull(__Type),\n resolve: schema => schema.getQueryType()\n },\n mutationType: {\n description: 'If this server supports mutation, the type that mutation operations will be rooted at.',\n type: __Type,\n resolve: schema => schema.getMutationType()\n },\n subscriptionType: {\n description: 'If this server support subscription, the type that subscription operations will be rooted at.',\n type: __Type,\n resolve: schema => schema.getSubscriptionType()\n },\n directives: {\n description: 'A list of all directives supported by this server.',\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Directive))),\n resolve: schema => schema.getDirectives()\n }\n })\n});\nexport const __Directive = new GraphQLObjectType({\n name: '__Directive',\n description: \"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\\n\\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.\",\n fields: () => ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: directive => directive.name\n },\n description: {\n type: GraphQLString,\n resolve: directive => directive.description\n },\n isRepeatable: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: directive => directive.isRepeatable\n },\n locations: {\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__DirectiveLocation))),\n resolve: directive => directive.locations\n },\n args: {\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__InputValue))),\n resolve: directive => directive.args\n }\n })\n});\nexport const __DirectiveLocation = new GraphQLEnumType({\n name: '__DirectiveLocation',\n description: 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.',\n values: {\n QUERY: {\n value: DirectiveLocation.QUERY,\n description: 'Location adjacent to a query operation.'\n },\n MUTATION: {\n value: DirectiveLocation.MUTATION,\n description: 'Location adjacent to a mutation operation.'\n },\n SUBSCRIPTION: {\n value: DirectiveLocation.SUBSCRIPTION,\n description: 'Location adjacent to a subscription operation.'\n },\n FIELD: {\n value: DirectiveLocation.FIELD,\n description: 'Location adjacent to a field.'\n },\n FRAGMENT_DEFINITION: {\n value: DirectiveLocation.FRAGMENT_DEFINITION,\n description: 'Location adjacent to a fragment definition.'\n },\n FRAGMENT_SPREAD: {\n value: DirectiveLocation.FRAGMENT_SPREAD,\n description: 'Location adjacent to a fragment spread.'\n },\n INLINE_FRAGMENT: {\n value: DirectiveLocation.INLINE_FRAGMENT,\n description: 'Location adjacent to an inline fragment.'\n },\n VARIABLE_DEFINITION: {\n value: DirectiveLocation.VARIABLE_DEFINITION,\n description: 'Location adjacent to a variable definition.'\n },\n SCHEMA: {\n value: DirectiveLocation.SCHEMA,\n description: 'Location adjacent to a schema definition.'\n },\n SCALAR: {\n value: DirectiveLocation.SCALAR,\n description: 'Location adjacent to a scalar definition.'\n },\n OBJECT: {\n value: DirectiveLocation.OBJECT,\n description: 'Location adjacent to an object type definition.'\n },\n FIELD_DEFINITION: {\n value: DirectiveLocation.FIELD_DEFINITION,\n description: 'Location adjacent to a field definition.'\n },\n ARGUMENT_DEFINITION: {\n value: DirectiveLocation.ARGUMENT_DEFINITION,\n description: 'Location adjacent to an argument definition.'\n },\n INTERFACE: {\n value: DirectiveLocation.INTERFACE,\n description: 'Location adjacent to an interface definition.'\n },\n UNION: {\n value: DirectiveLocation.UNION,\n description: 'Location adjacent to a union definition.'\n },\n ENUM: {\n value: DirectiveLocation.ENUM,\n description: 'Location adjacent to an enum definition.'\n },\n ENUM_VALUE: {\n value: DirectiveLocation.ENUM_VALUE,\n description: 'Location adjacent to an enum value definition.'\n },\n INPUT_OBJECT: {\n value: DirectiveLocation.INPUT_OBJECT,\n description: 'Location adjacent to an input object type definition.'\n },\n INPUT_FIELD_DEFINITION: {\n value: DirectiveLocation.INPUT_FIELD_DEFINITION,\n description: 'Location adjacent to an input object field definition.'\n }\n }\n});\nexport const __Type = new GraphQLObjectType({\n name: '__Type',\n description: 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\\n\\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByUrl`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.',\n fields: () => ({\n kind: {\n type: new GraphQLNonNull(__TypeKind),\n\n resolve(type) {\n if (isScalarType(type)) {\n return TypeKind.SCALAR;\n }\n\n if (isObjectType(type)) {\n return TypeKind.OBJECT;\n }\n\n if (isInterfaceType(type)) {\n return TypeKind.INTERFACE;\n }\n\n if (isUnionType(type)) {\n return TypeKind.UNION;\n }\n\n if (isEnumType(type)) {\n return TypeKind.ENUM;\n }\n\n if (isInputObjectType(type)) {\n return TypeKind.INPUT_OBJECT;\n }\n\n if (isListType(type)) {\n return TypeKind.LIST;\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isNonNullType(type)) {\n return TypeKind.NON_NULL;\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, `Unexpected type: \"${inspect(type)}\".`);\n }\n\n },\n name: {\n type: GraphQLString,\n resolve: type => type.name !== undefined ? type.name : undefined\n },\n description: {\n type: GraphQLString,\n resolve: type => type.description !== undefined ? type.description : undefined\n },\n specifiedByUrl: {\n type: GraphQLString,\n resolve: obj => obj.specifiedByUrl !== undefined ? obj.specifiedByUrl : undefined\n },\n fields: {\n type: new GraphQLList(new GraphQLNonNull(__Field)),\n args: {\n includeDeprecated: {\n type: GraphQLBoolean,\n defaultValue: false\n }\n },\n\n resolve(type, {\n includeDeprecated\n }) {\n if (isObjectType(type) || isInterfaceType(type)) {\n const fields = objectValues(type.getFields());\n return includeDeprecated ? fields : fields.filter(field => field.deprecationReason == null);\n }\n }\n\n },\n interfaces: {\n type: new GraphQLList(new GraphQLNonNull(__Type)),\n\n resolve(type) {\n if (isObjectType(type) || isInterfaceType(type)) {\n return type.getInterfaces();\n }\n }\n\n },\n possibleTypes: {\n type: new GraphQLList(new GraphQLNonNull(__Type)),\n\n resolve(type, _args, _context, {\n schema\n }) {\n if (isAbstractType(type)) {\n return schema.getPossibleTypes(type);\n }\n }\n\n },\n enumValues: {\n type: new GraphQLList(new GraphQLNonNull(__EnumValue)),\n args: {\n includeDeprecated: {\n type: GraphQLBoolean,\n defaultValue: false\n }\n },\n\n resolve(type, {\n includeDeprecated\n }) {\n if (isEnumType(type)) {\n const values = type.getValues();\n return includeDeprecated ? values : values.filter(field => field.deprecationReason == null);\n }\n }\n\n },\n inputFields: {\n type: new GraphQLList(new GraphQLNonNull(__InputValue)),\n args: {\n includeDeprecated: {\n type: GraphQLBoolean,\n defaultValue: false\n }\n },\n\n resolve(type, {\n includeDeprecated\n }) {\n if (isInputObjectType(type)) {\n const values = objectValues(type.getFields());\n return includeDeprecated ? values : values.filter(field => field.deprecationReason == null);\n }\n }\n\n },\n ofType: {\n type: __Type,\n resolve: type => type.ofType !== undefined ? type.ofType : undefined\n }\n })\n});\nexport const __Field = new GraphQLObjectType({\n name: '__Field',\n description: 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.',\n fields: () => ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: field => field.name\n },\n description: {\n type: GraphQLString,\n resolve: field => field.description\n },\n args: {\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__InputValue))),\n args: {\n includeDeprecated: {\n type: GraphQLBoolean,\n defaultValue: false\n }\n },\n\n resolve(field, {\n includeDeprecated\n }) {\n return includeDeprecated ? field.args : field.args.filter(arg => arg.deprecationReason == null);\n }\n\n },\n type: {\n type: new GraphQLNonNull(__Type),\n resolve: field => field.type\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: field => field.deprecationReason != null\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: field => field.deprecationReason\n }\n })\n});\nexport const __InputValue = new GraphQLObjectType({\n name: '__InputValue',\n description: 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.',\n fields: () => ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: inputValue => inputValue.name\n },\n description: {\n type: GraphQLString,\n resolve: inputValue => inputValue.description\n },\n type: {\n type: new GraphQLNonNull(__Type),\n resolve: inputValue => inputValue.type\n },\n defaultValue: {\n type: GraphQLString,\n description: 'A GraphQL-formatted string representing the default value for this input value.',\n\n resolve(inputValue) {\n const {\n type,\n defaultValue\n } = inputValue;\n const valueAST = astFromValue(defaultValue, type);\n return valueAST ? print(valueAST) : null;\n }\n\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: field => field.deprecationReason != null\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: obj => obj.deprecationReason\n }\n })\n});\nexport const __EnumValue = new GraphQLObjectType({\n name: '__EnumValue',\n description: 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.',\n fields: () => ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: enumValue => enumValue.name\n },\n description: {\n type: GraphQLString,\n resolve: enumValue => enumValue.description\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: enumValue => enumValue.deprecationReason != null\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: enumValue => enumValue.deprecationReason\n }\n })\n});\nexport const TypeKind = Object.freeze({\n SCALAR: 'SCALAR',\n OBJECT: 'OBJECT',\n INTERFACE: 'INTERFACE',\n UNION: 'UNION',\n ENUM: 'ENUM',\n INPUT_OBJECT: 'INPUT_OBJECT',\n LIST: 'LIST',\n NON_NULL: 'NON_NULL'\n});\nexport const __TypeKind = new GraphQLEnumType({\n name: '__TypeKind',\n description: 'An enum describing what kind of type a given `__Type` is.',\n values: {\n SCALAR: {\n value: TypeKind.SCALAR,\n description: 'Indicates this type is a scalar.'\n },\n OBJECT: {\n value: TypeKind.OBJECT,\n description: 'Indicates this type is an object. `fields` and `interfaces` are valid fields.'\n },\n INTERFACE: {\n value: TypeKind.INTERFACE,\n description: 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.'\n },\n UNION: {\n value: TypeKind.UNION,\n description: 'Indicates this type is a union. `possibleTypes` is a valid field.'\n },\n ENUM: {\n value: TypeKind.ENUM,\n description: 'Indicates this type is an enum. `enumValues` is a valid field.'\n },\n INPUT_OBJECT: {\n value: TypeKind.INPUT_OBJECT,\n description: 'Indicates this type is an input object. `inputFields` is a valid field.'\n },\n LIST: {\n value: TypeKind.LIST,\n description: 'Indicates this type is a list. `ofType` is a valid field.'\n },\n NON_NULL: {\n value: TypeKind.NON_NULL,\n description: 'Indicates this type is a non-null. `ofType` is a valid field.'\n }\n }\n});\n/**\n * Note that these are GraphQLField and not GraphQLFieldConfig,\n * so the format for args is different.\n */\n\nexport const SchemaMetaFieldDef = {\n name: '__schema',\n type: new GraphQLNonNull(__Schema),\n description: 'Access the current type schema of this server.',\n args: [],\n resolve: (_source, _args, _context, {\n schema\n }) => schema,\n deprecationReason: undefined,\n extensions: undefined,\n astNode: undefined\n};\nexport const TypeMetaFieldDef = {\n name: '__type',\n type: __Type,\n description: 'Request the type information of a single type.',\n args: [{\n name: 'name',\n description: undefined,\n type: new GraphQLNonNull(GraphQLString),\n defaultValue: undefined,\n deprecationReason: undefined,\n extensions: undefined,\n astNode: undefined\n }],\n resolve: (_source, {\n name\n }, _context, {\n schema\n }) => schema.getType(name),\n deprecationReason: undefined,\n extensions: undefined,\n astNode: undefined\n};\nexport const TypeNameMetaFieldDef = {\n name: '__typename',\n type: new GraphQLNonNull(GraphQLString),\n description: 'The name of the current Object type at runtime.',\n args: [],\n resolve: (_source, _args, _context, {\n parentType\n }) => parentType.name,\n deprecationReason: undefined,\n extensions: undefined,\n astNode: undefined\n};\nexport const introspectionTypes = Object.freeze([__Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind]);\nexport function isIntrospectionType(type) {\n return introspectionTypes.some(({\n name\n }) => type.name === name);\n}\n","import objectEntries from \"../polyfills/objectEntries.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport toObjMap from \"../jsutils/toObjMap.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport instanceOf from \"../jsutils/instanceOf.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport { DirectiveLocation } from \"../language/directiveLocation.mjs\";\nimport { GraphQLString, GraphQLBoolean } from \"./scalars.mjs\";\nimport { argsToArgsConfig, GraphQLNonNull } from \"./definition.mjs\";\n/**\n * Test if the given value is a GraphQL directive.\n */\n\n// eslint-disable-next-line no-redeclare\nexport function isDirective(directive) {\n return instanceOf(directive, GraphQLDirective);\n}\nexport function assertDirective(directive) {\n if (!isDirective(directive)) {\n throw new Error(`Expected ${inspect(directive)} to be a GraphQL directive.`);\n }\n\n return directive;\n}\n/**\n * Directives are used by the GraphQL runtime as a way of modifying execution\n * behavior. Type system creators will usually not create these directly.\n */\n\nexport class GraphQLDirective {\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.locations = config.locations;\n this.isRepeatable = config.isRepeatable ?? false;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n config.name || devAssert(0, 'Directive must be named.');\n Array.isArray(config.locations) || devAssert(0, `@${config.name} locations must be an Array.`);\n const args = config.args ?? {};\n isObjectLike(args) && !Array.isArray(args) || devAssert(0, `@${config.name} args must be an object with argument names as keys.`);\n this.args = objectEntries(args).map(([argName, argConfig]) => ({\n name: argName,\n description: argConfig.description,\n type: argConfig.type,\n defaultValue: argConfig.defaultValue,\n deprecationReason: argConfig.deprecationReason,\n extensions: argConfig.extensions && toObjMap(argConfig.extensions),\n astNode: argConfig.astNode\n }));\n }\n\n toConfig() {\n return {\n name: this.name,\n description: this.description,\n locations: this.locations,\n args: argsToArgsConfig(this.args),\n isRepeatable: this.isRepeatable,\n extensions: this.extensions,\n astNode: this.astNode\n };\n }\n\n toString() {\n return '@' + this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLDirective';\n }\n\n}\n\n/**\n * Used to conditionally include fields or fragments.\n */\nexport const GraphQLIncludeDirective = new GraphQLDirective({\n name: 'include',\n description: 'Directs the executor to include this field or fragment only when the `if` argument is true.',\n locations: [DirectiveLocation.FIELD, DirectiveLocation.FRAGMENT_SPREAD, DirectiveLocation.INLINE_FRAGMENT],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Included when true.'\n }\n }\n});\n/**\n * Used to conditionally skip (exclude) fields or fragments.\n */\n\nexport const GraphQLSkipDirective = new GraphQLDirective({\n name: 'skip',\n description: 'Directs the executor to skip this field or fragment when the `if` argument is true.',\n locations: [DirectiveLocation.FIELD, DirectiveLocation.FRAGMENT_SPREAD, DirectiveLocation.INLINE_FRAGMENT],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Skipped when true.'\n }\n }\n});\n/**\n * Constant string used for default reason for a deprecation.\n */\n\nexport const DEFAULT_DEPRECATION_REASON = 'No longer supported';\n/**\n * Used to declare element of a GraphQL schema as deprecated.\n */\n\nexport const GraphQLDeprecatedDirective = new GraphQLDirective({\n name: 'deprecated',\n description: 'Marks an element of a GraphQL schema as no longer supported.',\n locations: [DirectiveLocation.FIELD_DEFINITION, DirectiveLocation.ARGUMENT_DEFINITION, DirectiveLocation.INPUT_FIELD_DEFINITION, DirectiveLocation.ENUM_VALUE],\n args: {\n reason: {\n type: GraphQLString,\n description: 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).',\n defaultValue: DEFAULT_DEPRECATION_REASON\n }\n }\n});\n/**\n * Used to provide a URL for specifying the behaviour of custom scalar definitions.\n */\n\nexport const GraphQLSpecifiedByDirective = new GraphQLDirective({\n name: 'specifiedBy',\n description: 'Exposes a URL that specifies the behaviour of this scalar.',\n locations: [DirectiveLocation.SCALAR],\n args: {\n url: {\n type: new GraphQLNonNull(GraphQLString),\n description: 'The URL that specifies the behaviour of this scalar.'\n }\n }\n});\n/**\n * The full list of specified directives.\n */\n\nexport const specifiedDirectives = Object.freeze([GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective]);\nexport function isSpecifiedDirective(directive) {\n return specifiedDirectives.some(({\n name\n }) => name === directive.name);\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport toObjMap from \"../jsutils/toObjMap.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport instanceOf from \"../jsutils/instanceOf.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport { __Schema } from \"./introspection.mjs\";\nimport { GraphQLDirective, isDirective, specifiedDirectives } from \"./directives.mjs\";\nimport { isObjectType, isInterfaceType, isUnionType, isInputObjectType, getNamedType } from \"./definition.mjs\";\n/**\n * Test if the given value is a GraphQL schema.\n */\n\n// eslint-disable-next-line no-redeclare\nexport function isSchema(schema) {\n return instanceOf(schema, GraphQLSchema);\n}\nexport function assertSchema(schema) {\n if (!isSchema(schema)) {\n throw new Error(`Expected ${inspect(schema)} to be a GraphQL schema.`);\n }\n\n return schema;\n}\n/**\n * Schema Definition\n *\n * A Schema is created by supplying the root types of each type of operation,\n * query and mutation (optional). A schema definition is then supplied to the\n * validator and executor.\n *\n * Example:\n *\n * const MyAppSchema = new GraphQLSchema({\n * query: MyAppQueryRootType,\n * mutation: MyAppMutationRootType,\n * })\n *\n * Note: When the schema is constructed, by default only the types that are\n * reachable by traversing the root types are included, other types must be\n * explicitly referenced.\n *\n * Example:\n *\n * const characterInterface = new GraphQLInterfaceType({\n * name: 'Character',\n * ...\n * });\n *\n * const humanType = new GraphQLObjectType({\n * name: 'Human',\n * interfaces: [characterInterface],\n * ...\n * });\n *\n * const droidType = new GraphQLObjectType({\n * name: 'Droid',\n * interfaces: [characterInterface],\n * ...\n * });\n *\n * const schema = new GraphQLSchema({\n * query: new GraphQLObjectType({\n * name: 'Query',\n * fields: {\n * hero: { type: characterInterface, ... },\n * }\n * }),\n * ...\n * // Since this schema references only the `Character` interface it's\n * // necessary to explicitly list the types that implement it if\n * // you want them to be included in the final schema.\n * types: [humanType, droidType],\n * })\n *\n * Note: If an array of `directives` are provided to GraphQLSchema, that will be\n * the exact list of directives represented and allowed. If `directives` is not\n * provided then a default set of the specified directives (e.g. @include and\n * @skip) will be used. If you wish to provide *additional* directives to these\n * specified directives, you must explicitly declare them. Example:\n *\n * const MyAppSchema = new GraphQLSchema({\n * ...\n * directives: specifiedDirectives.concat([ myCustomDirective ]),\n * })\n *\n */\n\nexport class GraphQLSchema {\n // Used as a cache for validateSchema().\n constructor(config) {\n // If this schema was built from a source known to be valid, then it may be\n // marked with assumeValid to avoid an additional type system validation.\n this.__validationErrors = config.assumeValid === true ? [] : undefined; // Check for common mistakes during construction to produce early errors.\n\n isObjectLike(config) || devAssert(0, 'Must provide configuration object.');\n !config.types || Array.isArray(config.types) || devAssert(0, `\"types\" must be Array if provided but got: ${inspect(config.types)}.`);\n !config.directives || Array.isArray(config.directives) || devAssert(0, '\"directives\" must be Array if provided but got: ' + `${inspect(config.directives)}.`);\n this.description = config.description;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes;\n this._queryType = config.query;\n this._mutationType = config.mutation;\n this._subscriptionType = config.subscription; // Provide specified directives (e.g. @include and @skip) by default.\n\n this._directives = config.directives ?? specifiedDirectives; // To preserve order of user-provided types, we add first to add them to\n // the set of \"collected\" types, so `collectReferencedTypes` ignore them.\n\n const allReferencedTypes = new Set(config.types);\n\n if (config.types != null) {\n for (const type of config.types) {\n // When we ready to process this type, we remove it from \"collected\" types\n // and then add it together with all dependent types in the correct position.\n allReferencedTypes.delete(type);\n collectReferencedTypes(type, allReferencedTypes);\n }\n }\n\n if (this._queryType != null) {\n collectReferencedTypes(this._queryType, allReferencedTypes);\n }\n\n if (this._mutationType != null) {\n collectReferencedTypes(this._mutationType, allReferencedTypes);\n }\n\n if (this._subscriptionType != null) {\n collectReferencedTypes(this._subscriptionType, allReferencedTypes);\n }\n\n for (const directive of this._directives) {\n // Directives are not validated until validateSchema() is called.\n if (isDirective(directive)) {\n for (const arg of directive.args) {\n collectReferencedTypes(arg.type, allReferencedTypes);\n }\n }\n }\n\n collectReferencedTypes(__Schema, allReferencedTypes); // Storing the resulting map for reference by the schema.\n\n this._typeMap = Object.create(null);\n this._subTypeMap = Object.create(null); // Keep track of all implementations by interface name.\n\n this._implementationsMap = Object.create(null);\n\n for (const namedType of Array.from(allReferencedTypes)) {\n if (namedType == null) {\n continue;\n }\n\n const typeName = namedType.name;\n typeName || devAssert(0, 'One of the provided types for building the Schema is missing a name.');\n\n if (this._typeMap[typeName] !== undefined) {\n throw new Error(`Schema must contain uniquely named types but contains multiple types named \"${typeName}\".`);\n }\n\n this._typeMap[typeName] = namedType;\n\n if (isInterfaceType(namedType)) {\n // Store implementations by interface.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n\n if (implementations === undefined) {\n implementations = this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: []\n };\n }\n\n implementations.interfaces.push(namedType);\n }\n }\n } else if (isObjectType(namedType)) {\n // Store implementations by objects.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n\n if (implementations === undefined) {\n implementations = this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: []\n };\n }\n\n implementations.objects.push(namedType);\n }\n }\n }\n }\n }\n\n getQueryType() {\n return this._queryType;\n }\n\n getMutationType() {\n return this._mutationType;\n }\n\n getSubscriptionType() {\n return this._subscriptionType;\n }\n\n getTypeMap() {\n return this._typeMap;\n }\n\n getType(name) {\n return this.getTypeMap()[name];\n }\n\n getPossibleTypes(abstractType) {\n return isUnionType(abstractType) ? abstractType.getTypes() : this.getImplementations(abstractType).objects;\n }\n\n getImplementations(interfaceType) {\n const implementations = this._implementationsMap[interfaceType.name];\n return implementations ?? {\n objects: [],\n interfaces: []\n };\n }\n\n isSubType(abstractType, maybeSubType) {\n let map = this._subTypeMap[abstractType.name];\n\n if (map === undefined) {\n map = Object.create(null);\n\n if (isUnionType(abstractType)) {\n for (const type of abstractType.getTypes()) {\n map[type.name] = true;\n }\n } else {\n const implementations = this.getImplementations(abstractType);\n\n for (const type of implementations.objects) {\n map[type.name] = true;\n }\n\n for (const type of implementations.interfaces) {\n map[type.name] = true;\n }\n }\n\n this._subTypeMap[abstractType.name] = map;\n }\n\n return map[maybeSubType.name] !== undefined;\n }\n\n getDirectives() {\n return this._directives;\n }\n\n getDirective(name) {\n return this.getDirectives().find(directive => directive.name === name);\n }\n\n toConfig() {\n return {\n description: this.description,\n query: this.getQueryType(),\n mutation: this.getMutationType(),\n subscription: this.getSubscriptionType(),\n types: objectValues(this.getTypeMap()),\n directives: this.getDirectives().slice(),\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? [],\n assumeValid: this.__validationErrors !== undefined\n };\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLSchema';\n }\n\n}\n\nfunction collectReferencedTypes(type, typeSet) {\n const namedType = getNamedType(type);\n\n if (!typeSet.has(namedType)) {\n typeSet.add(namedType);\n\n if (isUnionType(namedType)) {\n for (const memberType of namedType.getTypes()) {\n collectReferencedTypes(memberType, typeSet);\n }\n } else if (isObjectType(namedType) || isInterfaceType(namedType)) {\n for (const interfaceType of namedType.getInterfaces()) {\n collectReferencedTypes(interfaceType, typeSet);\n }\n\n for (const field of objectValues(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n\n for (const arg of field.args) {\n collectReferencedTypes(arg.type, typeSet);\n }\n }\n } else if (isInputObjectType(namedType)) {\n for (const field of objectValues(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n }\n }\n }\n\n return typeSet;\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nimport { locatedError } from \"../error/locatedError.mjs\";\nimport { isValidNameError } from \"../utilities/assertValidName.mjs\";\nimport { isEqualType, isTypeSubTypeOf } from \"../utilities/typeComparators.mjs\";\nimport { assertSchema } from \"./schema.mjs\";\nimport { isIntrospectionType } from \"./introspection.mjs\";\nimport { isDirective, GraphQLDeprecatedDirective } from \"./directives.mjs\";\nimport { isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isNamedType, isNonNullType, isInputType, isOutputType, isRequiredArgument, isRequiredInputField } from \"./definition.mjs\";\n/**\n * Implements the \"Type Validation\" sub-sections of the specification's\n * \"Type System\" section.\n *\n * Validation runs synchronously, returning an array of encountered errors, or\n * an empty array if no errors were encountered and the Schema is valid.\n */\n\nexport function validateSchema(schema) {\n // First check to ensure the provided value is in fact a GraphQLSchema.\n assertSchema(schema); // If this Schema has already been validated, return the previous results.\n\n if (schema.__validationErrors) {\n return schema.__validationErrors;\n } // Validate the schema, producing a list of errors.\n\n\n const context = new SchemaValidationContext(schema);\n validateRootTypes(context);\n validateDirectives(context);\n validateTypes(context); // Persist the results of validation before returning to ensure validation\n // does not run multiple times for this schema.\n\n const errors = context.getErrors();\n schema.__validationErrors = errors;\n return errors;\n}\n/**\n * Utility function which asserts a schema is valid by throwing an error if\n * it is invalid.\n */\n\nexport function assertValidSchema(schema) {\n const errors = validateSchema(schema);\n\n if (errors.length !== 0) {\n throw new Error(errors.map(error => error.message).join('\\n\\n'));\n }\n}\n\nclass SchemaValidationContext {\n constructor(schema) {\n this._errors = [];\n this.schema = schema;\n }\n\n reportError(message, nodes) {\n const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;\n\n this.addError(new GraphQLError(message, _nodes));\n }\n\n addError(error) {\n this._errors.push(error);\n }\n\n getErrors() {\n return this._errors;\n }\n\n}\n\nfunction validateRootTypes(context) {\n const schema = context.schema;\n const queryType = schema.getQueryType();\n\n if (!queryType) {\n context.reportError('Query root type must be provided.', schema.astNode);\n } else if (!isObjectType(queryType)) {\n context.reportError(`Query root type must be Object type, it cannot be ${inspect(queryType)}.`, getOperationTypeNode(schema, 'query') ?? queryType.astNode);\n }\n\n const mutationType = schema.getMutationType();\n\n if (mutationType && !isObjectType(mutationType)) {\n context.reportError('Mutation root type must be Object type if provided, it cannot be ' + `${inspect(mutationType)}.`, getOperationTypeNode(schema, 'mutation') ?? mutationType.astNode);\n }\n\n const subscriptionType = schema.getSubscriptionType();\n\n if (subscriptionType && !isObjectType(subscriptionType)) {\n context.reportError('Subscription root type must be Object type if provided, it cannot be ' + `${inspect(subscriptionType)}.`, getOperationTypeNode(schema, 'subscription') ?? subscriptionType.astNode);\n }\n}\n\nfunction getOperationTypeNode(schema, operation) {\n const operationNodes = getAllSubNodes(schema, node => node.operationTypes);\n\n for (const node of operationNodes) {\n if (node.operation === operation) {\n return node.type;\n }\n }\n\n return undefined;\n}\n\nfunction validateDirectives(context) {\n for (const directive of context.schema.getDirectives()) {\n // Ensure all directives are in fact GraphQL directives.\n if (!isDirective(directive)) {\n context.reportError(`Expected directive but got: ${inspect(directive)}.`, directive?.astNode);\n continue;\n } // Ensure they are named correctly.\n\n\n validateName(context, directive); // TODO: Ensure proper locations.\n // Ensure the arguments are valid.\n\n for (const arg of directive.args) {\n // Ensure they are named correctly.\n validateName(context, arg); // Ensure the type is an input type.\n\n if (!isInputType(arg.type)) {\n context.reportError(`The type of @${directive.name}(${arg.name}:) must be Input Type ` + `but got: ${inspect(arg.type)}.`, arg.astNode);\n }\n\n if (isRequiredArgument(arg) && arg.deprecationReason != null) {\n context.reportError(`Required argument @${directive.name}(${arg.name}:) cannot be deprecated.`, [getDeprecatedDirectiveNode(arg.astNode), // istanbul ignore next (TODO need to write coverage tests)\n arg.astNode?.type]);\n }\n }\n }\n}\n\nfunction validateName(context, node) {\n // Ensure names are valid, however introspection types opt out.\n const error = isValidNameError(node.name);\n\n if (error) {\n context.addError(locatedError(error, node.astNode));\n }\n}\n\nfunction validateTypes(context) {\n const validateInputObjectCircularRefs = createInputObjectCircularRefsValidator(context);\n const typeMap = context.schema.getTypeMap();\n\n for (const type of objectValues(typeMap)) {\n // Ensure all provided types are in fact GraphQL type.\n if (!isNamedType(type)) {\n context.reportError(`Expected GraphQL named type but got: ${inspect(type)}.`, type.astNode);\n continue;\n } // Ensure it is named correctly (excluding introspection types).\n\n\n if (!isIntrospectionType(type)) {\n validateName(context, type);\n }\n\n if (isObjectType(type)) {\n // Ensure fields are valid\n validateFields(context, type); // Ensure objects implement the interfaces they claim to.\n\n validateInterfaces(context, type);\n } else if (isInterfaceType(type)) {\n // Ensure fields are valid.\n validateFields(context, type); // Ensure interfaces implement the interfaces they claim to.\n\n validateInterfaces(context, type);\n } else if (isUnionType(type)) {\n // Ensure Unions include valid member types.\n validateUnionMembers(context, type);\n } else if (isEnumType(type)) {\n // Ensure Enums have valid values.\n validateEnumValues(context, type);\n } else if (isInputObjectType(type)) {\n // Ensure Input Object fields are valid.\n validateInputFields(context, type); // Ensure Input Objects do not contain non-nullable circular references\n\n validateInputObjectCircularRefs(type);\n }\n }\n}\n\nfunction validateFields(context, type) {\n const fields = objectValues(type.getFields()); // Objects and Interfaces both must define one or more fields.\n\n if (fields.length === 0) {\n context.reportError(`Type ${type.name} must define one or more fields.`, getAllNodes(type));\n }\n\n for (const field of fields) {\n // Ensure they are named correctly.\n validateName(context, field); // Ensure the type is an output type\n\n if (!isOutputType(field.type)) {\n context.reportError(`The type of ${type.name}.${field.name} must be Output Type ` + `but got: ${inspect(field.type)}.`, field.astNode?.type);\n } // Ensure the arguments are valid\n\n\n for (const arg of field.args) {\n const argName = arg.name; // Ensure they are named correctly.\n\n validateName(context, arg); // Ensure the type is an input type\n\n if (!isInputType(arg.type)) {\n context.reportError(`The type of ${type.name}.${field.name}(${argName}:) must be Input ` + `Type but got: ${inspect(arg.type)}.`, arg.astNode?.type);\n }\n\n if (isRequiredArgument(arg) && arg.deprecationReason != null) {\n context.reportError(`Required argument ${type.name}.${field.name}(${argName}:) cannot be deprecated.`, [getDeprecatedDirectiveNode(arg.astNode), // istanbul ignore next (TODO need to write coverage tests)\n arg.astNode?.type]);\n }\n }\n }\n}\n\nfunction validateInterfaces(context, type) {\n const ifaceTypeNames = Object.create(null);\n\n for (const iface of type.getInterfaces()) {\n if (!isInterfaceType(iface)) {\n context.reportError(`Type ${inspect(type)} must only implement Interface types, ` + `it cannot implement ${inspect(iface)}.`, getAllImplementsInterfaceNodes(type, iface));\n continue;\n }\n\n if (type === iface) {\n context.reportError(`Type ${type.name} cannot implement itself because it would create a circular reference.`, getAllImplementsInterfaceNodes(type, iface));\n continue;\n }\n\n if (ifaceTypeNames[iface.name]) {\n context.reportError(`Type ${type.name} can only implement ${iface.name} once.`, getAllImplementsInterfaceNodes(type, iface));\n continue;\n }\n\n ifaceTypeNames[iface.name] = true;\n validateTypeImplementsAncestors(context, type, iface);\n validateTypeImplementsInterface(context, type, iface);\n }\n}\n\nfunction validateTypeImplementsInterface(context, type, iface) {\n const typeFieldMap = type.getFields(); // Assert each interface field is implemented.\n\n for (const ifaceField of objectValues(iface.getFields())) {\n const fieldName = ifaceField.name;\n const typeField = typeFieldMap[fieldName]; // Assert interface field exists on type.\n\n if (!typeField) {\n context.reportError(`Interface field ${iface.name}.${fieldName} expected but ${type.name} does not provide it.`, [ifaceField.astNode, ...getAllNodes(type)]);\n continue;\n } // Assert interface field type is satisfied by type field type, by being\n // a valid subtype. (covariant)\n\n\n if (!isTypeSubTypeOf(context.schema, typeField.type, ifaceField.type)) {\n context.reportError(`Interface field ${iface.name}.${fieldName} expects type ` + `${inspect(ifaceField.type)} but ${type.name}.${fieldName} ` + `is type ${inspect(typeField.type)}.`, [// istanbul ignore next (TODO need to write coverage tests)\n ifaceField.astNode?.type, // istanbul ignore next (TODO need to write coverage tests)\n typeField.astNode?.type]);\n } // Assert each interface field arg is implemented.\n\n\n for (const ifaceArg of ifaceField.args) {\n const argName = ifaceArg.name;\n const typeArg = typeField.args.find(arg => arg.name === argName); // Assert interface field arg exists on object field.\n\n if (!typeArg) {\n context.reportError(`Interface field argument ${iface.name}.${fieldName}(${argName}:) expected but ${type.name}.${fieldName} does not provide it.`, [ifaceArg.astNode, typeField.astNode]);\n continue;\n } // Assert interface field arg type matches object field arg type.\n // (invariant)\n // TODO: change to contravariant?\n\n\n if (!isEqualType(ifaceArg.type, typeArg.type)) {\n context.reportError(`Interface field argument ${iface.name}.${fieldName}(${argName}:) ` + `expects type ${inspect(ifaceArg.type)} but ` + `${type.name}.${fieldName}(${argName}:) is type ` + `${inspect(typeArg.type)}.`, [// istanbul ignore next (TODO need to write coverage tests)\n ifaceArg.astNode?.type, // istanbul ignore next (TODO need to write coverage tests)\n typeArg.astNode?.type]);\n } // TODO: validate default values?\n\n } // Assert additional arguments must not be required.\n\n\n for (const typeArg of typeField.args) {\n const argName = typeArg.name;\n const ifaceArg = ifaceField.args.find(arg => arg.name === argName);\n\n if (!ifaceArg && isRequiredArgument(typeArg)) {\n context.reportError(`Object field ${type.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${iface.name}.${fieldName}.`, [typeArg.astNode, ifaceField.astNode]);\n }\n }\n }\n}\n\nfunction validateTypeImplementsAncestors(context, type, iface) {\n const ifaceInterfaces = type.getInterfaces();\n\n for (const transitive of iface.getInterfaces()) {\n if (ifaceInterfaces.indexOf(transitive) === -1) {\n context.reportError(transitive === type ? `Type ${type.name} cannot implement ${iface.name} because it would create a circular reference.` : `Type ${type.name} must implement ${transitive.name} because it is implemented by ${iface.name}.`, [...getAllImplementsInterfaceNodes(iface, transitive), ...getAllImplementsInterfaceNodes(type, iface)]);\n }\n }\n}\n\nfunction validateUnionMembers(context, union) {\n const memberTypes = union.getTypes();\n\n if (memberTypes.length === 0) {\n context.reportError(`Union type ${union.name} must define one or more member types.`, getAllNodes(union));\n }\n\n const includedTypeNames = Object.create(null);\n\n for (const memberType of memberTypes) {\n if (includedTypeNames[memberType.name]) {\n context.reportError(`Union type ${union.name} can only include type ${memberType.name} once.`, getUnionMemberTypeNodes(union, memberType.name));\n continue;\n }\n\n includedTypeNames[memberType.name] = true;\n\n if (!isObjectType(memberType)) {\n context.reportError(`Union type ${union.name} can only include Object types, ` + `it cannot include ${inspect(memberType)}.`, getUnionMemberTypeNodes(union, String(memberType)));\n }\n }\n}\n\nfunction validateEnumValues(context, enumType) {\n const enumValues = enumType.getValues();\n\n if (enumValues.length === 0) {\n context.reportError(`Enum type ${enumType.name} must define one or more values.`, getAllNodes(enumType));\n }\n\n for (const enumValue of enumValues) {\n const valueName = enumValue.name; // Ensure valid name.\n\n validateName(context, enumValue);\n\n if (valueName === 'true' || valueName === 'false' || valueName === 'null') {\n context.reportError(`Enum type ${enumType.name} cannot include value: ${valueName}.`, enumValue.astNode);\n }\n }\n}\n\nfunction validateInputFields(context, inputObj) {\n const fields = objectValues(inputObj.getFields());\n\n if (fields.length === 0) {\n context.reportError(`Input Object type ${inputObj.name} must define one or more fields.`, getAllNodes(inputObj));\n } // Ensure the arguments are valid\n\n\n for (const field of fields) {\n // Ensure they are named correctly.\n validateName(context, field); // Ensure the type is an input type\n\n if (!isInputType(field.type)) {\n context.reportError(`The type of ${inputObj.name}.${field.name} must be Input Type ` + `but got: ${inspect(field.type)}.`, field.astNode?.type);\n }\n\n if (isRequiredInputField(field) && field.deprecationReason != null) {\n context.reportError(`Required input field ${inputObj.name}.${field.name} cannot be deprecated.`, [getDeprecatedDirectiveNode(field.astNode), // istanbul ignore next (TODO need to write coverage tests)\n field.astNode?.type]);\n }\n }\n}\n\nfunction createInputObjectCircularRefsValidator(context) {\n // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'.\n // Tracks already visited types to maintain O(N) and to ensure that cycles\n // are not redundantly reported.\n const visitedTypes = Object.create(null); // Array of types nodes used to produce meaningful errors\n\n const fieldPath = []; // Position in the type path\n\n const fieldPathIndexByTypeName = Object.create(null);\n return detectCycleRecursive; // This does a straight-forward DFS to find cycles.\n // It does not terminate when a cycle was found but continues to explore\n // the graph to find all possible cycles.\n\n function detectCycleRecursive(inputObj) {\n if (visitedTypes[inputObj.name]) {\n return;\n }\n\n visitedTypes[inputObj.name] = true;\n fieldPathIndexByTypeName[inputObj.name] = fieldPath.length;\n const fields = objectValues(inputObj.getFields());\n\n for (const field of fields) {\n if (isNonNullType(field.type) && isInputObjectType(field.type.ofType)) {\n const fieldType = field.type.ofType;\n const cycleIndex = fieldPathIndexByTypeName[fieldType.name];\n fieldPath.push(field);\n\n if (cycleIndex === undefined) {\n detectCycleRecursive(fieldType);\n } else {\n const cyclePath = fieldPath.slice(cycleIndex);\n const pathStr = cyclePath.map(fieldObj => fieldObj.name).join('.');\n context.reportError(`Cannot reference Input Object \"${fieldType.name}\" within itself through a series of non-null fields: \"${pathStr}\".`, cyclePath.map(fieldObj => fieldObj.astNode));\n }\n\n fieldPath.pop();\n }\n }\n\n fieldPathIndexByTypeName[inputObj.name] = undefined;\n }\n}\n\nfunction getAllNodes(object) {\n const {\n astNode,\n extensionASTNodes\n } = object;\n return astNode ? extensionASTNodes ? [astNode].concat(extensionASTNodes) : [astNode] : extensionASTNodes ?? [];\n}\n\nfunction getAllSubNodes(object, getter) {\n let subNodes = [];\n\n for (const node of getAllNodes(object)) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n subNodes = subNodes.concat(getter(node) ?? []);\n }\n\n return subNodes;\n}\n\nfunction getAllImplementsInterfaceNodes(type, iface) {\n return getAllSubNodes(type, typeNode => typeNode.interfaces).filter(ifaceNode => ifaceNode.name.value === iface.name);\n}\n\nfunction getUnionMemberTypeNodes(union, typeName) {\n return getAllSubNodes(union, unionNode => unionNode.types).filter(typeNode => typeNode.name.value === typeName);\n}\n\nfunction getDeprecatedDirectiveNode(definitionNode) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n return definitionNode?.directives?.find(node => node.name.value === GraphQLDeprecatedDirective.name);\n}\n","import inspect from \"../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"./GraphQLError.mjs\";\n/**\n * Given an arbitrary value, presumably thrown while attempting to execute a\n * GraphQL operation, produce a new GraphQLError aware of the location in the\n * document responsible for the original Error.\n */\n\nexport function locatedError(rawOriginalError, nodes, path) {\n // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.\n const originalError = rawOriginalError instanceof Error ? rawOriginalError : new Error('Unexpected error value: ' + inspect(rawOriginalError)); // Note: this uses a brand-check to support GraphQL errors originating from other contexts.\n\n if (Array.isArray(originalError.path)) {\n return originalError;\n }\n\n return new GraphQLError(originalError.message, originalError.nodes ?? nodes, originalError.source, originalError.positions, path, originalError);\n}\n","import inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { GraphQLList, GraphQLNonNull } from \"../type/definition.mjs\";\n/**\n * Given a Schema and an AST node describing a type, return a GraphQLType\n * definition which applies to that type. For example, if provided the parsed\n * AST node for `[User]`, a GraphQLList instance will be returned, containing\n * the type called \"User\" found in the schema. If a type called \"User\" is not\n * found in the schema, then undefined will be returned.\n */\n\n/* eslint-disable no-redeclare */\n\nexport function typeFromAST(schema, typeNode) {\n /* eslint-enable no-redeclare */\n let innerType;\n\n if (typeNode.kind === Kind.LIST_TYPE) {\n innerType = typeFromAST(schema, typeNode.type);\n return innerType && new GraphQLList(innerType);\n }\n\n if (typeNode.kind === Kind.NON_NULL_TYPE) {\n innerType = typeFromAST(schema, typeNode.type);\n return innerType && new GraphQLNonNull(innerType);\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (typeNode.kind === Kind.NAMED_TYPE) {\n return schema.getType(typeNode.name.value);\n } // istanbul ignore next (Not reachable. All possible type nodes have been considered)\n\n\n false || invariant(0, 'Unexpected type node: ' + inspect(typeNode));\n}\n","import { Kind } from \"../language/kinds.mjs\";\nimport { isNode } from \"../language/ast.mjs\";\nimport { getVisitFn } from \"../language/visitor.mjs\";\nimport { isObjectType, isInterfaceType, isEnumType, isInputObjectType, isListType, isCompositeType, isInputType, isOutputType, getNullableType, getNamedType } from \"../type/definition.mjs\";\nimport { SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef } from \"../type/introspection.mjs\";\nimport { typeFromAST } from \"./typeFromAST.mjs\";\n/**\n * TypeInfo is a utility class which, given a GraphQL schema, can keep track\n * of the current field and type definitions at any point in a GraphQL document\n * AST during a recursive descent by calling `enter(node)` and `leave(node)`.\n */\n\nexport class TypeInfo {\n constructor(schema, // NOTE: this experimental optional second parameter is only needed in order\n // to support non-spec-compliant code bases. You should never need to use it.\n // It may disappear in the future.\n getFieldDefFn, // Initial type may be provided in rare cases to facilitate traversals\n // beginning somewhere other than documents.\n initialType) {\n this._schema = schema;\n this._typeStack = [];\n this._parentTypeStack = [];\n this._inputTypeStack = [];\n this._fieldDefStack = [];\n this._defaultValueStack = [];\n this._directive = null;\n this._argument = null;\n this._enumValue = null;\n this._getFieldDef = getFieldDefFn ?? getFieldDef;\n\n if (initialType) {\n if (isInputType(initialType)) {\n this._inputTypeStack.push(initialType);\n }\n\n if (isCompositeType(initialType)) {\n this._parentTypeStack.push(initialType);\n }\n\n if (isOutputType(initialType)) {\n this._typeStack.push(initialType);\n }\n }\n }\n\n getType() {\n if (this._typeStack.length > 0) {\n return this._typeStack[this._typeStack.length - 1];\n }\n }\n\n getParentType() {\n if (this._parentTypeStack.length > 0) {\n return this._parentTypeStack[this._parentTypeStack.length - 1];\n }\n }\n\n getInputType() {\n if (this._inputTypeStack.length > 0) {\n return this._inputTypeStack[this._inputTypeStack.length - 1];\n }\n }\n\n getParentInputType() {\n if (this._inputTypeStack.length > 1) {\n return this._inputTypeStack[this._inputTypeStack.length - 2];\n }\n }\n\n getFieldDef() {\n if (this._fieldDefStack.length > 0) {\n return this._fieldDefStack[this._fieldDefStack.length - 1];\n }\n }\n\n getDefaultValue() {\n if (this._defaultValueStack.length > 0) {\n return this._defaultValueStack[this._defaultValueStack.length - 1];\n }\n }\n\n getDirective() {\n return this._directive;\n }\n\n getArgument() {\n return this._argument;\n }\n\n getEnumValue() {\n return this._enumValue;\n }\n\n enter(node) {\n const schema = this._schema; // Note: many of the types below are explicitly typed as \"mixed\" to drop\n // any assumptions of a valid schema to ensure runtime types are properly\n // checked before continuing since TypeInfo is used as part of validation\n // which occurs before guarantees of schema and document validity.\n\n switch (node.kind) {\n case Kind.SELECTION_SET:\n {\n const namedType = getNamedType(this.getType());\n\n this._parentTypeStack.push(isCompositeType(namedType) ? namedType : undefined);\n\n break;\n }\n\n case Kind.FIELD:\n {\n const parentType = this.getParentType();\n let fieldDef;\n let fieldType;\n\n if (parentType) {\n fieldDef = this._getFieldDef(schema, parentType, node);\n\n if (fieldDef) {\n fieldType = fieldDef.type;\n }\n }\n\n this._fieldDefStack.push(fieldDef);\n\n this._typeStack.push(isOutputType(fieldType) ? fieldType : undefined);\n\n break;\n }\n\n case Kind.DIRECTIVE:\n this._directive = schema.getDirective(node.name.value);\n break;\n\n case Kind.OPERATION_DEFINITION:\n {\n let type;\n\n switch (node.operation) {\n case 'query':\n type = schema.getQueryType();\n break;\n\n case 'mutation':\n type = schema.getMutationType();\n break;\n\n case 'subscription':\n type = schema.getSubscriptionType();\n break;\n }\n\n this._typeStack.push(isObjectType(type) ? type : undefined);\n\n break;\n }\n\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION:\n {\n const typeConditionAST = node.typeCondition;\n const outputType = typeConditionAST ? typeFromAST(schema, typeConditionAST) : getNamedType(this.getType());\n\n this._typeStack.push(isOutputType(outputType) ? outputType : undefined);\n\n break;\n }\n\n case Kind.VARIABLE_DEFINITION:\n {\n const inputType = typeFromAST(schema, node.type);\n\n this._inputTypeStack.push(isInputType(inputType) ? inputType : undefined);\n\n break;\n }\n\n case Kind.ARGUMENT:\n {\n let argDef;\n let argType;\n const fieldOrDirective = this.getDirective() ?? this.getFieldDef();\n\n if (fieldOrDirective) {\n argDef = fieldOrDirective.args.find(arg => arg.name === node.name.value);\n\n if (argDef) {\n argType = argDef.type;\n }\n }\n\n this._argument = argDef;\n\n this._defaultValueStack.push(argDef ? argDef.defaultValue : undefined);\n\n this._inputTypeStack.push(isInputType(argType) ? argType : undefined);\n\n break;\n }\n\n case Kind.LIST:\n {\n const listType = getNullableType(this.getInputType());\n const itemType = isListType(listType) ? listType.ofType : listType; // List positions never have a default value.\n\n this._defaultValueStack.push(undefined);\n\n this._inputTypeStack.push(isInputType(itemType) ? itemType : undefined);\n\n break;\n }\n\n case Kind.OBJECT_FIELD:\n {\n const objectType = getNamedType(this.getInputType());\n let inputFieldType;\n let inputField;\n\n if (isInputObjectType(objectType)) {\n inputField = objectType.getFields()[node.name.value];\n\n if (inputField) {\n inputFieldType = inputField.type;\n }\n }\n\n this._defaultValueStack.push(inputField ? inputField.defaultValue : undefined);\n\n this._inputTypeStack.push(isInputType(inputFieldType) ? inputFieldType : undefined);\n\n break;\n }\n\n case Kind.ENUM:\n {\n const enumType = getNamedType(this.getInputType());\n let enumValue;\n\n if (isEnumType(enumType)) {\n enumValue = enumType.getValue(node.value);\n }\n\n this._enumValue = enumValue;\n break;\n }\n }\n }\n\n leave(node) {\n switch (node.kind) {\n case Kind.SELECTION_SET:\n this._parentTypeStack.pop();\n\n break;\n\n case Kind.FIELD:\n this._fieldDefStack.pop();\n\n this._typeStack.pop();\n\n break;\n\n case Kind.DIRECTIVE:\n this._directive = null;\n break;\n\n case Kind.OPERATION_DEFINITION:\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION:\n this._typeStack.pop();\n\n break;\n\n case Kind.VARIABLE_DEFINITION:\n this._inputTypeStack.pop();\n\n break;\n\n case Kind.ARGUMENT:\n this._argument = null;\n\n this._defaultValueStack.pop();\n\n this._inputTypeStack.pop();\n\n break;\n\n case Kind.LIST:\n case Kind.OBJECT_FIELD:\n this._defaultValueStack.pop();\n\n this._inputTypeStack.pop();\n\n break;\n\n case Kind.ENUM:\n this._enumValue = null;\n break;\n }\n }\n\n}\n/**\n * Not exactly the same as the executor's definition of getFieldDef, in this\n * statically evaluated environment we do not always have an Object type,\n * and need to handle Interface and Union types.\n */\n\nfunction getFieldDef(schema, parentType, fieldNode) {\n const name = fieldNode.name.value;\n\n if (name === SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {\n return SchemaMetaFieldDef;\n }\n\n if (name === TypeMetaFieldDef.name && schema.getQueryType() === parentType) {\n return TypeMetaFieldDef;\n }\n\n if (name === TypeNameMetaFieldDef.name && isCompositeType(parentType)) {\n return TypeNameMetaFieldDef;\n }\n\n if (isObjectType(parentType) || isInterfaceType(parentType)) {\n return parentType.getFields()[name];\n }\n}\n/**\n * Creates a new visitor instance which maintains a provided TypeInfo instance\n * along with visiting visitor.\n */\n\n\nexport function visitWithTypeInfo(typeInfo, visitor) {\n return {\n enter(node) {\n typeInfo.enter(node);\n const fn = getVisitFn(visitor, node.kind,\n /* isLeaving */\n false);\n\n if (fn) {\n const result = fn.apply(visitor, arguments);\n\n if (result !== undefined) {\n typeInfo.leave(node);\n\n if (isNode(result)) {\n typeInfo.enter(result);\n }\n }\n\n return result;\n }\n },\n\n leave(node) {\n const fn = getVisitFn(visitor, node.kind,\n /* isLeaving */\n true);\n let result;\n\n if (fn) {\n result = fn.apply(visitor, arguments);\n }\n\n typeInfo.leave(node);\n return result;\n }\n\n };\n}\n","import { Kind } from \"./kinds.mjs\";\nexport function isDefinitionNode(node) {\n return isExecutableDefinitionNode(node) || isTypeSystemDefinitionNode(node) || isTypeSystemExtensionNode(node);\n}\nexport function isExecutableDefinitionNode(node) {\n return node.kind === Kind.OPERATION_DEFINITION || node.kind === Kind.FRAGMENT_DEFINITION;\n}\nexport function isSelectionNode(node) {\n return node.kind === Kind.FIELD || node.kind === Kind.FRAGMENT_SPREAD || node.kind === Kind.INLINE_FRAGMENT;\n}\nexport function isValueNode(node) {\n return node.kind === Kind.VARIABLE || node.kind === Kind.INT || node.kind === Kind.FLOAT || node.kind === Kind.STRING || node.kind === Kind.BOOLEAN || node.kind === Kind.NULL || node.kind === Kind.ENUM || node.kind === Kind.LIST || node.kind === Kind.OBJECT;\n}\nexport function isTypeNode(node) {\n return node.kind === Kind.NAMED_TYPE || node.kind === Kind.LIST_TYPE || node.kind === Kind.NON_NULL_TYPE;\n}\nexport function isTypeSystemDefinitionNode(node) {\n return node.kind === Kind.SCHEMA_DEFINITION || isTypeDefinitionNode(node) || node.kind === Kind.DIRECTIVE_DEFINITION;\n}\nexport function isTypeDefinitionNode(node) {\n return node.kind === Kind.SCALAR_TYPE_DEFINITION || node.kind === Kind.OBJECT_TYPE_DEFINITION || node.kind === Kind.INTERFACE_TYPE_DEFINITION || node.kind === Kind.UNION_TYPE_DEFINITION || node.kind === Kind.ENUM_TYPE_DEFINITION || node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION;\n}\nexport function isTypeSystemExtensionNode(node) {\n return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);\n}\nexport function isTypeExtensionNode(node) {\n return node.kind === Kind.SCALAR_TYPE_EXTENSION || node.kind === Kind.OBJECT_TYPE_EXTENSION || node.kind === Kind.INTERFACE_TYPE_EXTENSION || node.kind === Kind.UNION_TYPE_EXTENSION || node.kind === Kind.ENUM_TYPE_EXTENSION || node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION;\n}\n","import didYouMean from \"../../jsutils/didYouMean.mjs\";\nimport suggestionList from \"../../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { isTypeDefinitionNode, isTypeSystemDefinitionNode, isTypeSystemExtensionNode } from \"../../language/predicates.mjs\";\nimport { specifiedScalarTypes } from \"../../type/scalars.mjs\";\nimport { introspectionTypes } from \"../../type/introspection.mjs\";\n\n/**\n * Known type names\n *\n * A GraphQL document is only valid if referenced types (specifically\n * variable definitions and fragment conditions) are defined by the type schema.\n */\nexport function KnownTypeNamesRule(context) {\n const schema = context.getSchema();\n const existingTypesMap = schema ? schema.getTypeMap() : Object.create(null);\n const definedTypes = Object.create(null);\n\n for (const def of context.getDocument().definitions) {\n if (isTypeDefinitionNode(def)) {\n definedTypes[def.name.value] = true;\n }\n }\n\n const typeNames = Object.keys(existingTypesMap).concat(Object.keys(definedTypes));\n return {\n NamedType(node, _1, parent, _2, ancestors) {\n const typeName = node.name.value;\n\n if (!existingTypesMap[typeName] && !definedTypes[typeName]) {\n const definitionNode = ancestors[2] ?? parent;\n const isSDL = definitionNode != null && isSDLNode(definitionNode);\n\n if (isSDL && isStandardTypeName(typeName)) {\n return;\n }\n\n const suggestedTypes = suggestionList(typeName, isSDL ? standardTypeNames.concat(typeNames) : typeNames);\n context.reportError(new GraphQLError(`Unknown type \"${typeName}\".` + didYouMean(suggestedTypes), node));\n }\n }\n\n };\n}\nconst standardTypeNames = [...specifiedScalarTypes, ...introspectionTypes].map(type => type.name);\n\nfunction isStandardTypeName(typeName) {\n return standardTypeNames.indexOf(typeName) !== -1;\n}\n\nfunction isSDLNode(value) {\n return !Array.isArray(value) && (isTypeSystemDefinitionNode(value) || isTypeSystemExtensionNode(value));\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * No unused fragments\n *\n * A GraphQL document is only valid if all fragment definitions are spread\n * within operations, or spread within other fragments spread within operations.\n */\nexport function NoUnusedFragmentsRule(context) {\n const operationDefs = [];\n const fragmentDefs = [];\n return {\n OperationDefinition(node) {\n operationDefs.push(node);\n return false;\n },\n\n FragmentDefinition(node) {\n fragmentDefs.push(node);\n return false;\n },\n\n Document: {\n leave() {\n const fragmentNameUsed = Object.create(null);\n\n for (const operation of operationDefs) {\n for (const fragment of context.getRecursivelyReferencedFragments(operation)) {\n fragmentNameUsed[fragment.name.value] = true;\n }\n }\n\n for (const fragmentDef of fragmentDefs) {\n const fragName = fragmentDef.name.value;\n\n if (fragmentNameUsed[fragName] !== true) {\n context.reportError(new GraphQLError(`Fragment \"${fragName}\" is never used.`, fragmentDef));\n }\n }\n }\n\n }\n };\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport invariant from \"../../jsutils/invariant.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { DirectiveLocation } from \"../../language/directiveLocation.mjs\";\nimport { specifiedDirectives } from \"../../type/directives.mjs\";\n\n/**\n * Known directives\n *\n * A GraphQL document is only valid if all `@directives` are known by the\n * schema and legally positioned.\n */\nexport function KnownDirectivesRule(context) {\n const locationsMap = Object.create(null);\n const schema = context.getSchema();\n const definedDirectives = schema ? schema.getDirectives() : specifiedDirectives;\n\n for (const directive of definedDirectives) {\n locationsMap[directive.name] = directive.locations;\n }\n\n const astDefinitions = context.getDocument().definitions;\n\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n locationsMap[def.name.value] = def.locations.map(name => name.value);\n }\n }\n\n return {\n Directive(node, _key, _parent, _path, ancestors) {\n const name = node.name.value;\n const locations = locationsMap[name];\n\n if (!locations) {\n context.reportError(new GraphQLError(`Unknown directive \"@${name}\".`, node));\n return;\n }\n\n const candidateLocation = getDirectiveLocationForASTPath(ancestors);\n\n if (candidateLocation && locations.indexOf(candidateLocation) === -1) {\n context.reportError(new GraphQLError(`Directive \"@${name}\" may not be used on ${candidateLocation}.`, node));\n }\n }\n\n };\n}\n\nfunction getDirectiveLocationForASTPath(ancestors) {\n const appliedTo = ancestors[ancestors.length - 1];\n !Array.isArray(appliedTo) || invariant(0);\n\n switch (appliedTo.kind) {\n case Kind.OPERATION_DEFINITION:\n return getDirectiveLocationForOperation(appliedTo.operation);\n\n case Kind.FIELD:\n return DirectiveLocation.FIELD;\n\n case Kind.FRAGMENT_SPREAD:\n return DirectiveLocation.FRAGMENT_SPREAD;\n\n case Kind.INLINE_FRAGMENT:\n return DirectiveLocation.INLINE_FRAGMENT;\n\n case Kind.FRAGMENT_DEFINITION:\n return DirectiveLocation.FRAGMENT_DEFINITION;\n\n case Kind.VARIABLE_DEFINITION:\n return DirectiveLocation.VARIABLE_DEFINITION;\n\n case Kind.SCHEMA_DEFINITION:\n case Kind.SCHEMA_EXTENSION:\n return DirectiveLocation.SCHEMA;\n\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.SCALAR_TYPE_EXTENSION:\n return DirectiveLocation.SCALAR;\n\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_EXTENSION:\n return DirectiveLocation.OBJECT;\n\n case Kind.FIELD_DEFINITION:\n return DirectiveLocation.FIELD_DEFINITION;\n\n case Kind.INTERFACE_TYPE_DEFINITION:\n case Kind.INTERFACE_TYPE_EXTENSION:\n return DirectiveLocation.INTERFACE;\n\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.UNION_TYPE_EXTENSION:\n return DirectiveLocation.UNION;\n\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_EXTENSION:\n return DirectiveLocation.ENUM;\n\n case Kind.ENUM_VALUE_DEFINITION:\n return DirectiveLocation.ENUM_VALUE;\n\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_EXTENSION:\n return DirectiveLocation.INPUT_OBJECT;\n\n case Kind.INPUT_VALUE_DEFINITION:\n {\n const parentNode = ancestors[ancestors.length - 3];\n return parentNode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ? DirectiveLocation.INPUT_FIELD_DEFINITION : DirectiveLocation.ARGUMENT_DEFINITION;\n }\n }\n}\n\nfunction getDirectiveLocationForOperation(operation) {\n switch (operation) {\n case 'query':\n return DirectiveLocation.QUERY;\n\n case 'mutation':\n return DirectiveLocation.MUTATION;\n\n case 'subscription':\n return DirectiveLocation.SUBSCRIPTION;\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, 'Unexpected operation: ' + inspect(operation));\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { isTypeDefinitionNode, isTypeExtensionNode } from \"../../language/predicates.mjs\";\nimport { specifiedDirectives } from \"../../type/directives.mjs\";\n\n/**\n * Unique directive names per location\n *\n * A GraphQL document is only valid if all non-repeatable directives at\n * a given location are uniquely named.\n */\nexport function UniqueDirectivesPerLocationRule(context) {\n const uniqueDirectiveMap = Object.create(null);\n const schema = context.getSchema();\n const definedDirectives = schema ? schema.getDirectives() : specifiedDirectives;\n\n for (const directive of definedDirectives) {\n uniqueDirectiveMap[directive.name] = !directive.isRepeatable;\n }\n\n const astDefinitions = context.getDocument().definitions;\n\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n uniqueDirectiveMap[def.name.value] = !def.repeatable;\n }\n }\n\n const schemaDirectives = Object.create(null);\n const typeDirectivesMap = Object.create(null);\n return {\n // Many different AST nodes may contain directives. Rather than listing\n // them all, just listen for entering any node, and check to see if it\n // defines any directives.\n enter(node) {\n if (node.directives == null) {\n return;\n }\n\n let seenDirectives;\n\n if (node.kind === Kind.SCHEMA_DEFINITION || node.kind === Kind.SCHEMA_EXTENSION) {\n seenDirectives = schemaDirectives;\n } else if (isTypeDefinitionNode(node) || isTypeExtensionNode(node)) {\n const typeName = node.name.value;\n seenDirectives = typeDirectivesMap[typeName];\n\n if (seenDirectives === undefined) {\n typeDirectivesMap[typeName] = seenDirectives = Object.create(null);\n }\n } else {\n seenDirectives = Object.create(null);\n }\n\n for (const directive of node.directives) {\n const directiveName = directive.name.value;\n\n if (uniqueDirectiveMap[directiveName]) {\n if (seenDirectives[directiveName]) {\n context.reportError(new GraphQLError(`The directive \"@${directiveName}\" can only be used once at this location.`, [seenDirectives[directiveName], directive]));\n } else {\n seenDirectives[directiveName] = directive;\n }\n }\n }\n }\n\n };\n}\n","import didYouMean from \"../../jsutils/didYouMean.mjs\";\nimport suggestionList from \"../../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { specifiedDirectives } from \"../../type/directives.mjs\";\n\n/**\n * Known argument names\n *\n * A GraphQL field is only valid if all supplied arguments are defined by\n * that field.\n */\nexport function KnownArgumentNamesRule(context) {\n return { // eslint-disable-next-line new-cap\n ...KnownArgumentNamesOnDirectivesRule(context),\n\n Argument(argNode) {\n const argDef = context.getArgument();\n const fieldDef = context.getFieldDef();\n const parentType = context.getParentType();\n\n if (!argDef && fieldDef && parentType) {\n const argName = argNode.name.value;\n const knownArgsNames = fieldDef.args.map(arg => arg.name);\n const suggestions = suggestionList(argName, knownArgsNames);\n context.reportError(new GraphQLError(`Unknown argument \"${argName}\" on field \"${parentType.name}.${fieldDef.name}\".` + didYouMean(suggestions), argNode));\n }\n }\n\n };\n}\n/**\n * @internal\n */\n\nexport function KnownArgumentNamesOnDirectivesRule(context) {\n const directiveArgs = Object.create(null);\n const schema = context.getSchema();\n const definedDirectives = schema ? schema.getDirectives() : specifiedDirectives;\n\n for (const directive of definedDirectives) {\n directiveArgs[directive.name] = directive.args.map(arg => arg.name);\n }\n\n const astDefinitions = context.getDocument().definitions;\n\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argsNodes = def.arguments ?? [];\n directiveArgs[def.name.value] = argsNodes.map(arg => arg.name.value);\n }\n }\n\n return {\n Directive(directiveNode) {\n const directiveName = directiveNode.name.value;\n const knownArgs = directiveArgs[directiveName];\n\n if (directiveNode.arguments && knownArgs) {\n for (const argNode of directiveNode.arguments) {\n const argName = argNode.name.value;\n\n if (knownArgs.indexOf(argName) === -1) {\n const suggestions = suggestionList(argName, knownArgs);\n context.reportError(new GraphQLError(`Unknown argument \"${argName}\" on directive \"@${directiveName}\".` + didYouMean(suggestions), argNode));\n }\n }\n }\n\n return false;\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique argument names\n *\n * A GraphQL field or directive is only valid if all supplied arguments are\n * uniquely named.\n */\nexport function UniqueArgumentNamesRule(context) {\n let knownArgNames = Object.create(null);\n return {\n Field() {\n knownArgNames = Object.create(null);\n },\n\n Directive() {\n knownArgNames = Object.create(null);\n },\n\n Argument(node) {\n const argName = node.name.value;\n\n if (knownArgNames[argName]) {\n context.reportError(new GraphQLError(`There can be only one argument named \"${argName}\".`, [knownArgNames[argName], node.name]));\n } else {\n knownArgNames[argName] = node.name;\n }\n\n return false;\n }\n\n };\n}\n","import objectValues from \"../../polyfills/objectValues.mjs\";\nimport keyMap from \"../../jsutils/keyMap.mjs\";\nimport inspect from \"../../jsutils/inspect.mjs\";\nimport didYouMean from \"../../jsutils/didYouMean.mjs\";\nimport suggestionList from \"../../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { print } from \"../../language/printer.mjs\";\nimport { isLeafType, isInputObjectType, isListType, isNonNullType, isRequiredInputField, getNullableType, getNamedType } from \"../../type/definition.mjs\";\n\n/**\n * Value literals of correct type\n *\n * A GraphQL document is only valid if all value literals are of the type\n * expected at their position.\n */\nexport function ValuesOfCorrectTypeRule(context) {\n return {\n ListValue(node) {\n // Note: TypeInfo will traverse into a list's item type, so look to the\n // parent input type to check if it is a list.\n const type = getNullableType(context.getParentInputType());\n\n if (!isListType(type)) {\n isValidValueNode(context, node);\n return false; // Don't traverse further.\n }\n },\n\n ObjectValue(node) {\n const type = getNamedType(context.getInputType());\n\n if (!isInputObjectType(type)) {\n isValidValueNode(context, node);\n return false; // Don't traverse further.\n } // Ensure every required field exists.\n\n\n const fieldNodeMap = keyMap(node.fields, field => field.name.value);\n\n for (const fieldDef of objectValues(type.getFields())) {\n const fieldNode = fieldNodeMap[fieldDef.name];\n\n if (!fieldNode && isRequiredInputField(fieldDef)) {\n const typeStr = inspect(fieldDef.type);\n context.reportError(new GraphQLError(`Field \"${type.name}.${fieldDef.name}\" of required type \"${typeStr}\" was not provided.`, node));\n }\n }\n },\n\n ObjectField(node) {\n const parentType = getNamedType(context.getParentInputType());\n const fieldType = context.getInputType();\n\n if (!fieldType && isInputObjectType(parentType)) {\n const suggestions = suggestionList(node.name.value, Object.keys(parentType.getFields()));\n context.reportError(new GraphQLError(`Field \"${node.name.value}\" is not defined by type \"${parentType.name}\".` + didYouMean(suggestions), node));\n }\n },\n\n NullValue(node) {\n const type = context.getInputType();\n\n if (isNonNullType(type)) {\n context.reportError(new GraphQLError(`Expected value of type \"${inspect(type)}\", found ${print(node)}.`, node));\n }\n },\n\n EnumValue: node => isValidValueNode(context, node),\n IntValue: node => isValidValueNode(context, node),\n FloatValue: node => isValidValueNode(context, node),\n StringValue: node => isValidValueNode(context, node),\n BooleanValue: node => isValidValueNode(context, node)\n };\n}\n/**\n * Any value literal may be a valid representation of a Scalar, depending on\n * that scalar type.\n */\n\nfunction isValidValueNode(context, node) {\n // Report any error at the full type expected by the location.\n const locationType = context.getInputType();\n\n if (!locationType) {\n return;\n }\n\n const type = getNamedType(locationType);\n\n if (!isLeafType(type)) {\n const typeStr = inspect(locationType);\n context.reportError(new GraphQLError(`Expected value of type \"${typeStr}\", found ${print(node)}.`, node));\n return;\n } // Scalars and Enums determine if a literal value is valid via parseLiteral(),\n // which may throw or return an invalid value to indicate failure.\n\n\n try {\n const parseResult = type.parseLiteral(node, undefined\n /* variables */\n );\n\n if (parseResult === undefined) {\n const typeStr = inspect(locationType);\n context.reportError(new GraphQLError(`Expected value of type \"${typeStr}\", found ${print(node)}.`, node));\n }\n } catch (error) {\n const typeStr = inspect(locationType);\n\n if (error instanceof GraphQLError) {\n context.reportError(error);\n } else {\n context.reportError(new GraphQLError(`Expected value of type \"${typeStr}\", found ${print(node)}; ` + error.message, node, undefined, undefined, undefined, error));\n }\n }\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport keyMap from \"../../jsutils/keyMap.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { print } from \"../../language/printer.mjs\";\nimport { specifiedDirectives } from \"../../type/directives.mjs\";\nimport { isType, isRequiredArgument } from \"../../type/definition.mjs\";\n\n/**\n * Provided required arguments\n *\n * A field or directive is only valid if all required (non-null without a\n * default value) field arguments have been provided.\n */\nexport function ProvidedRequiredArgumentsRule(context) {\n return { // eslint-disable-next-line new-cap\n ...ProvidedRequiredArgumentsOnDirectivesRule(context),\n Field: {\n // Validate on leave to allow for deeper errors to appear first.\n leave(fieldNode) {\n const fieldDef = context.getFieldDef();\n\n if (!fieldDef) {\n return false;\n } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n\n const argNodes = fieldNode.arguments ?? [];\n const argNodeMap = keyMap(argNodes, arg => arg.name.value);\n\n for (const argDef of fieldDef.args) {\n const argNode = argNodeMap[argDef.name];\n\n if (!argNode && isRequiredArgument(argDef)) {\n const argTypeStr = inspect(argDef.type);\n context.reportError(new GraphQLError(`Field \"${fieldDef.name}\" argument \"${argDef.name}\" of type \"${argTypeStr}\" is required, but it was not provided.`, fieldNode));\n }\n }\n }\n\n }\n };\n}\n/**\n * @internal\n */\n\nexport function ProvidedRequiredArgumentsOnDirectivesRule(context) {\n const requiredArgsMap = Object.create(null);\n const schema = context.getSchema();\n const definedDirectives = schema ? schema.getDirectives() : specifiedDirectives;\n\n for (const directive of definedDirectives) {\n requiredArgsMap[directive.name] = keyMap(directive.args.filter(isRequiredArgument), arg => arg.name);\n }\n\n const astDefinitions = context.getDocument().definitions;\n\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argNodes = def.arguments ?? [];\n requiredArgsMap[def.name.value] = keyMap(argNodes.filter(isRequiredArgumentNode), arg => arg.name.value);\n }\n }\n\n return {\n Directive: {\n // Validate on leave to allow for deeper errors to appear first.\n leave(directiveNode) {\n const directiveName = directiveNode.name.value;\n const requiredArgs = requiredArgsMap[directiveName];\n\n if (requiredArgs) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argNodes = directiveNode.arguments ?? [];\n const argNodeMap = keyMap(argNodes, arg => arg.name.value);\n\n for (const argName of Object.keys(requiredArgs)) {\n if (!argNodeMap[argName]) {\n const argType = requiredArgs[argName].type;\n const argTypeStr = isType(argType) ? inspect(argType) : print(argType);\n context.reportError(new GraphQLError(`Directive \"@${directiveName}\" argument \"${argName}\" of type \"${argTypeStr}\" is required, but it was not provided.`, directiveNode));\n }\n }\n }\n }\n\n }\n };\n}\n\nfunction isRequiredArgumentNode(arg) {\n return arg.type.kind === Kind.NON_NULL_TYPE && arg.defaultValue == null;\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { isNonNullType } from \"../../type/definition.mjs\";\nimport { typeFromAST } from \"../../utilities/typeFromAST.mjs\";\nimport { isTypeSubTypeOf } from \"../../utilities/typeComparators.mjs\";\n\n/**\n * Variables passed to field arguments conform to type\n */\nexport function VariablesInAllowedPositionRule(context) {\n let varDefMap = Object.create(null);\n return {\n OperationDefinition: {\n enter() {\n varDefMap = Object.create(null);\n },\n\n leave(operation) {\n const usages = context.getRecursiveVariableUsages(operation);\n\n for (const {\n node,\n type,\n defaultValue\n } of usages) {\n const varName = node.name.value;\n const varDef = varDefMap[varName];\n\n if (varDef && type) {\n // A var type is allowed if it is the same or more strict (e.g. is\n // a subtype of) than the expected type. It can be more strict if\n // the variable type is non-null when the expected type is nullable.\n // If both are list types, the variable item type can be more strict\n // than the expected item type (contravariant).\n const schema = context.getSchema();\n const varType = typeFromAST(schema, varDef.type);\n\n if (varType && !allowedVariableUsage(schema, varType, varDef.defaultValue, type, defaultValue)) {\n const varTypeStr = inspect(varType);\n const typeStr = inspect(type);\n context.reportError(new GraphQLError(`Variable \"$${varName}\" of type \"${varTypeStr}\" used in position expecting type \"${typeStr}\".`, [varDef, node]));\n }\n }\n }\n }\n\n },\n\n VariableDefinition(node) {\n varDefMap[node.variable.name.value] = node;\n }\n\n };\n}\n/**\n * Returns true if the variable is allowed in the location it was found,\n * which includes considering if default values exist for either the variable\n * or the location at which it is located.\n */\n\nfunction allowedVariableUsage(schema, varType, varDefaultValue, locationType, locationDefaultValue) {\n if (isNonNullType(locationType) && !isNonNullType(varType)) {\n const hasNonNullVariableDefaultValue = varDefaultValue != null && varDefaultValue.kind !== Kind.NULL;\n const hasLocationDefaultValue = locationDefaultValue !== undefined;\n\n if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) {\n return false;\n }\n\n const nullableLocationType = locationType.ofType;\n return isTypeSubTypeOf(schema, varType, nullableLocationType);\n }\n\n return isTypeSubTypeOf(schema, varType, locationType);\n}\n","import objectEntries from \"../../polyfills/objectEntries.mjs\";\nimport inspect from \"../../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { print } from \"../../language/printer.mjs\";\nimport { getNamedType, isNonNullType, isLeafType, isObjectType, isListType, isInterfaceType } from \"../../type/definition.mjs\";\nimport { typeFromAST } from \"../../utilities/typeFromAST.mjs\";\n\nfunction reasonMessage(reason) {\n if (Array.isArray(reason)) {\n return reason.map(([responseName, subReason]) => `subfields \"${responseName}\" conflict because ` + reasonMessage(subReason)).join(' and ');\n }\n\n return reason;\n}\n/**\n * Overlapping fields can be merged\n *\n * A selection set is only valid if all fields (including spreading any\n * fragments) either correspond to distinct response names or can be merged\n * without ambiguity.\n */\n\n\nexport function OverlappingFieldsCanBeMergedRule(context) {\n // A memoization for when two fragments are compared \"between\" each other for\n // conflicts. Two fragments may be compared many times, so memoizing this can\n // dramatically improve the performance of this validator.\n const comparedFragmentPairs = new PairSet(); // A cache for the \"field map\" and list of fragment names found in any given\n // selection set. Selection sets may be asked for this information multiple\n // times, so this improves the performance of this validator.\n\n const cachedFieldsAndFragmentNames = new Map();\n return {\n SelectionSet(selectionSet) {\n const conflicts = findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, context.getParentType(), selectionSet);\n\n for (const [[responseName, reason], fields1, fields2] of conflicts) {\n const reasonMsg = reasonMessage(reason);\n context.reportError(new GraphQLError(`Fields \"${responseName}\" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`, fields1.concat(fields2)));\n }\n }\n\n };\n}\n\n/**\n * Algorithm:\n *\n * Conflicts occur when two fields exist in a query which will produce the same\n * response name, but represent differing values, thus creating a conflict.\n * The algorithm below finds all conflicts via making a series of comparisons\n * between fields. In order to compare as few fields as possible, this makes\n * a series of comparisons \"within\" sets of fields and \"between\" sets of fields.\n *\n * Given any selection set, a collection produces both a set of fields by\n * also including all inline fragments, as well as a list of fragments\n * referenced by fragment spreads.\n *\n * A) Each selection set represented in the document first compares \"within\" its\n * collected set of fields, finding any conflicts between every pair of\n * overlapping fields.\n * Note: This is the *only time* that a the fields \"within\" a set are compared\n * to each other. After this only fields \"between\" sets are compared.\n *\n * B) Also, if any fragment is referenced in a selection set, then a\n * comparison is made \"between\" the original set of fields and the\n * referenced fragment.\n *\n * C) Also, if multiple fragments are referenced, then comparisons\n * are made \"between\" each referenced fragment.\n *\n * D) When comparing \"between\" a set of fields and a referenced fragment, first\n * a comparison is made between each field in the original set of fields and\n * each field in the the referenced set of fields.\n *\n * E) Also, if any fragment is referenced in the referenced selection set,\n * then a comparison is made \"between\" the original set of fields and the\n * referenced fragment (recursively referring to step D).\n *\n * F) When comparing \"between\" two fragments, first a comparison is made between\n * each field in the first referenced set of fields and each field in the the\n * second referenced set of fields.\n *\n * G) Also, any fragments referenced by the first must be compared to the\n * second, and any fragments referenced by the second must be compared to the\n * first (recursively referring to step F).\n *\n * H) When comparing two fields, if both have selection sets, then a comparison\n * is made \"between\" both selection sets, first comparing the set of fields in\n * the first selection set with the set of fields in the second.\n *\n * I) Also, if any fragment is referenced in either selection set, then a\n * comparison is made \"between\" the other set of fields and the\n * referenced fragment.\n *\n * J) Also, if two fragments are referenced in both selection sets, then a\n * comparison is made \"between\" the two fragments.\n *\n */\n// Find all conflicts found \"within\" a selection set, including those found\n// via spreading in fragments. Called when visiting each SelectionSet in the\n// GraphQL Document.\nfunction findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentType, selectionSet) {\n const conflicts = [];\n const [fieldMap, fragmentNames] = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet); // (A) Find find all conflicts \"within\" the fields of this selection set.\n // Note: this is the *only place* `collectConflictsWithin` is called.\n\n collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, fieldMap);\n\n if (fragmentNames.length !== 0) {\n // (B) Then collect conflicts between these fields and those represented by\n // each spread fragment name found.\n for (let i = 0; i < fragmentNames.length; i++) {\n collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, fieldMap, fragmentNames[i]); // (C) Then compare this fragment with all other fragments found in this\n // selection set to collect conflicts between fragments spread together.\n // This compares each item in the list of fragment names to every other\n // item in that same list (except for itself).\n\n for (let j = i + 1; j < fragmentNames.length; j++) {\n collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, fragmentNames[i], fragmentNames[j]);\n }\n }\n }\n\n return conflicts;\n} // Collect all conflicts found between a set of fields and a fragment reference\n// including via spreading in any nested fragments.\n\n\nfunction collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {\n const fragment = context.getFragment(fragmentName);\n\n if (!fragment) {\n return;\n }\n\n const [fieldMap2, fragmentNames2] = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment); // Do not compare a fragment's fieldMap to itself.\n\n if (fieldMap === fieldMap2) {\n return;\n } // (D) First collect any conflicts between the provided collection of fields\n // and the collection of fields represented by the given fragment.\n\n\n collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fieldMap2); // (E) Then collect any conflicts between the provided collection of fields\n // and any fragment names found in the given fragment.\n\n for (let i = 0; i < fragmentNames2.length; i++) {\n collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentNames2[i]);\n }\n} // Collect all conflicts found between two fragments, including via spreading in\n// any nested fragments.\n\n\nfunction collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentName1, fragmentName2) {\n // No need to compare a fragment to itself.\n if (fragmentName1 === fragmentName2) {\n return;\n } // Memoize so two fragments are not compared for conflicts more than once.\n\n\n if (comparedFragmentPairs.has(fragmentName1, fragmentName2, areMutuallyExclusive)) {\n return;\n }\n\n comparedFragmentPairs.add(fragmentName1, fragmentName2, areMutuallyExclusive);\n const fragment1 = context.getFragment(fragmentName1);\n const fragment2 = context.getFragment(fragmentName2);\n\n if (!fragment1 || !fragment2) {\n return;\n }\n\n const [fieldMap1, fragmentNames1] = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment1);\n const [fieldMap2, fragmentNames2] = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2); // (F) First, collect all conflicts between these two collections of fields\n // (not including any nested fragments).\n\n collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fieldMap2); // (G) Then collect conflicts between the first fragment and any nested\n // fragments spread in the second fragment.\n\n for (let j = 0; j < fragmentNames2.length; j++) {\n collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentName1, fragmentNames2[j]);\n } // (G) Then collect conflicts between the second fragment and any nested\n // fragments spread in the first fragment.\n\n\n for (let i = 0; i < fragmentNames1.length; i++) {\n collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentNames1[i], fragmentName2);\n }\n} // Find all conflicts found between two selection sets, including those found\n// via spreading in fragments. Called when determining if conflicts exist\n// between the sub-fields of two overlapping fields.\n\n\nfunction findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, parentType1, selectionSet1, parentType2, selectionSet2) {\n const conflicts = [];\n const [fieldMap1, fragmentNames1] = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType1, selectionSet1);\n const [fieldMap2, fragmentNames2] = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType2, selectionSet2); // (H) First, collect all conflicts between these two collections of field.\n\n collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fieldMap2); // (I) Then collect conflicts between the first collection of fields and\n // those referenced by each fragment name associated with the second.\n\n if (fragmentNames2.length !== 0) {\n for (let j = 0; j < fragmentNames2.length; j++) {\n collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fragmentNames2[j]);\n }\n } // (I) Then collect conflicts between the second collection of fields and\n // those referenced by each fragment name associated with the first.\n\n\n if (fragmentNames1.length !== 0) {\n for (let i = 0; i < fragmentNames1.length; i++) {\n collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap2, fragmentNames1[i]);\n }\n } // (J) Also collect conflicts between any fragment names by the first and\n // fragment names by the second. This compares each item in the first set of\n // names to each item in the second set of names.\n\n\n for (let i = 0; i < fragmentNames1.length; i++) {\n for (let j = 0; j < fragmentNames2.length; j++) {\n collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentNames1[i], fragmentNames2[j]);\n }\n }\n\n return conflicts;\n} // Collect all Conflicts \"within\" one collection of fields.\n\n\nfunction collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, fieldMap) {\n // A field map is a keyed collection, where each key represents a response\n // name and the value at that key is a list of all fields which provide that\n // response name. For every response name, if there are multiple fields, they\n // must be compared to find a potential conflict.\n for (const [responseName, fields] of objectEntries(fieldMap)) {\n // This compares every field in the list to every other field in this list\n // (except to itself). If the list only has one item, nothing needs to\n // be compared.\n if (fields.length > 1) {\n for (let i = 0; i < fields.length; i++) {\n for (let j = i + 1; j < fields.length; j++) {\n const conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, // within one collection is never mutually exclusive\n responseName, fields[i], fields[j]);\n\n if (conflict) {\n conflicts.push(conflict);\n }\n }\n }\n }\n }\n} // Collect all Conflicts between two collections of fields. This is similar to,\n// but different from the `collectConflictsWithin` function above. This check\n// assumes that `collectConflictsWithin` has already been called on each\n// provided collection of fields. This is true because this validator traverses\n// each individual selection set.\n\n\nfunction collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, fieldMap1, fieldMap2) {\n // A field map is a keyed collection, where each key represents a response\n // name and the value at that key is a list of all fields which provide that\n // response name. For any response name which appears in both provided field\n // maps, each field from the first field map must be compared to every field\n // in the second field map to find potential conflicts.\n for (const responseName of Object.keys(fieldMap1)) {\n const fields2 = fieldMap2[responseName];\n\n if (fields2) {\n const fields1 = fieldMap1[responseName];\n\n for (let i = 0; i < fields1.length; i++) {\n for (let j = 0; j < fields2.length; j++) {\n const conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, fields1[i], fields2[j]);\n\n if (conflict) {\n conflicts.push(conflict);\n }\n }\n }\n }\n }\n} // Determines if there is a conflict between two particular fields, including\n// comparing their sub-fields.\n\n\nfunction findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, field1, field2) {\n const [parentType1, node1, def1] = field1;\n const [parentType2, node2, def2] = field2; // If it is known that two fields could not possibly apply at the same\n // time, due to the parent types, then it is safe to permit them to diverge\n // in aliased field or arguments used as they will not present any ambiguity\n // by differing.\n // It is known that two parent types could never overlap if they are\n // different Object types. Interface or Union types might overlap - if not\n // in the current state of the schema, then perhaps in some future version,\n // thus may not safely diverge.\n\n const areMutuallyExclusive = parentFieldsAreMutuallyExclusive || parentType1 !== parentType2 && isObjectType(parentType1) && isObjectType(parentType2);\n\n if (!areMutuallyExclusive) {\n // Two aliases must refer to the same field.\n const name1 = node1.name.value;\n const name2 = node2.name.value;\n\n if (name1 !== name2) {\n return [[responseName, `\"${name1}\" and \"${name2}\" are different fields`], [node1], [node2]];\n } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n\n const args1 = node1.arguments ?? []; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n const args2 = node2.arguments ?? []; // Two field calls must have the same arguments.\n\n if (!sameArguments(args1, args2)) {\n return [[responseName, 'they have differing arguments'], [node1], [node2]];\n }\n } // The return type for each field.\n\n\n const type1 = def1?.type;\n const type2 = def2?.type;\n\n if (type1 && type2 && doTypesConflict(type1, type2)) {\n return [[responseName, `they return conflicting types \"${inspect(type1)}\" and \"${inspect(type2)}\"`], [node1], [node2]];\n } // Collect and compare sub-fields. Use the same \"visited fragment names\" list\n // for both collections so fields in a fragment reference are never\n // compared to themselves.\n\n\n const selectionSet1 = node1.selectionSet;\n const selectionSet2 = node2.selectionSet;\n\n if (selectionSet1 && selectionSet2) {\n const conflicts = findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, getNamedType(type1), selectionSet1, getNamedType(type2), selectionSet2);\n return subfieldConflicts(conflicts, responseName, node1, node2);\n }\n}\n\nfunction sameArguments(arguments1, arguments2) {\n if (arguments1.length !== arguments2.length) {\n return false;\n }\n\n return arguments1.every(argument1 => {\n const argument2 = arguments2.find(argument => argument.name.value === argument1.name.value);\n\n if (!argument2) {\n return false;\n }\n\n return sameValue(argument1.value, argument2.value);\n });\n}\n\nfunction sameValue(value1, value2) {\n return print(value1) === print(value2);\n} // Two types conflict if both types could not apply to a value simultaneously.\n// Composite types are ignored as their individual field types will be compared\n// later recursively. However List and Non-Null types must match.\n\n\nfunction doTypesConflict(type1, type2) {\n if (isListType(type1)) {\n return isListType(type2) ? doTypesConflict(type1.ofType, type2.ofType) : true;\n }\n\n if (isListType(type2)) {\n return true;\n }\n\n if (isNonNullType(type1)) {\n return isNonNullType(type2) ? doTypesConflict(type1.ofType, type2.ofType) : true;\n }\n\n if (isNonNullType(type2)) {\n return true;\n }\n\n if (isLeafType(type1) || isLeafType(type2)) {\n return type1 !== type2;\n }\n\n return false;\n} // Given a selection set, return the collection of fields (a mapping of response\n// name to field nodes and definitions) as well as a list of fragment names\n// referenced via fragment spreads.\n\n\nfunction getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet) {\n let cached = cachedFieldsAndFragmentNames.get(selectionSet);\n\n if (!cached) {\n const nodeAndDefs = Object.create(null);\n const fragmentNames = Object.create(null);\n\n _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames);\n\n cached = [nodeAndDefs, Object.keys(fragmentNames)];\n cachedFieldsAndFragmentNames.set(selectionSet, cached);\n }\n\n return cached;\n} // Given a reference to a fragment, return the represented collection of fields\n// as well as a list of nested fragment names referenced via fragment spreads.\n\n\nfunction getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment) {\n // Short-circuit building a type from the node if possible.\n const cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet);\n\n if (cached) {\n return cached;\n }\n\n const fragmentType = typeFromAST(context.getSchema(), fragment.typeCondition);\n return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment.selectionSet);\n}\n\nfunction _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD:\n {\n const fieldName = selection.name.value;\n let fieldDef;\n\n if (isObjectType(parentType) || isInterfaceType(parentType)) {\n fieldDef = parentType.getFields()[fieldName];\n }\n\n const responseName = selection.alias ? selection.alias.value : fieldName;\n\n if (!nodeAndDefs[responseName]) {\n nodeAndDefs[responseName] = [];\n }\n\n nodeAndDefs[responseName].push([parentType, selection, fieldDef]);\n break;\n }\n\n case Kind.FRAGMENT_SPREAD:\n fragmentNames[selection.name.value] = true;\n break;\n\n case Kind.INLINE_FRAGMENT:\n {\n const typeCondition = selection.typeCondition;\n const inlineFragmentType = typeCondition ? typeFromAST(context.getSchema(), typeCondition) : parentType;\n\n _collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);\n\n break;\n }\n }\n }\n} // Given a series of Conflicts which occurred between two sub-fields, generate\n// a single Conflict.\n\n\nfunction subfieldConflicts(conflicts, responseName, node1, node2) {\n if (conflicts.length > 0) {\n return [[responseName, conflicts.map(([reason]) => reason)], conflicts.reduce((allFields, [, fields1]) => allFields.concat(fields1), [node1]), conflicts.reduce((allFields, [,, fields2]) => allFields.concat(fields2), [node2])];\n }\n}\n/**\n * A way to keep track of pairs of things when the ordering of the pair does\n * not matter. We do this by maintaining a sort of double adjacency sets.\n */\n\n\nclass PairSet {\n constructor() {\n this._data = Object.create(null);\n }\n\n has(a, b, areMutuallyExclusive) {\n const first = this._data[a];\n const result = first && first[b];\n\n if (result === undefined) {\n return false;\n } // areMutuallyExclusive being false is a superset of being true,\n // hence if we want to know if this PairSet \"has\" these two with no\n // exclusivity, we have to ensure it was added as such.\n\n\n if (areMutuallyExclusive === false) {\n return result === false;\n }\n\n return true;\n }\n\n add(a, b, areMutuallyExclusive) {\n this._pairSetAdd(a, b, areMutuallyExclusive);\n\n this._pairSetAdd(b, a, areMutuallyExclusive);\n }\n\n _pairSetAdd(a, b, areMutuallyExclusive) {\n let map = this._data[a];\n\n if (!map) {\n map = Object.create(null);\n this._data[a] = map;\n }\n\n map[b] = areMutuallyExclusive;\n }\n\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique input field names\n *\n * A GraphQL input object value is only valid if all supplied fields are\n * uniquely named.\n */\nexport function UniqueInputFieldNamesRule(context) {\n const knownNameStack = [];\n let knownNames = Object.create(null);\n return {\n ObjectValue: {\n enter() {\n knownNameStack.push(knownNames);\n knownNames = Object.create(null);\n },\n\n leave() {\n knownNames = knownNameStack.pop();\n }\n\n },\n\n ObjectField(node) {\n const fieldName = node.name.value;\n\n if (knownNames[fieldName]) {\n context.reportError(new GraphQLError(`There can be only one input field named \"${fieldName}\".`, [knownNames[fieldName], node.name]));\n } else {\n knownNames[fieldName] = node.name;\n }\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { isObjectType, isInterfaceType, isInputObjectType } from \"../../type/definition.mjs\";\n\n/**\n * Unique field definition names\n *\n * A GraphQL complex type is only valid if all its fields are uniquely named.\n */\nexport function UniqueFieldDefinitionNamesRule(context) {\n const schema = context.getSchema();\n const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);\n const knownFieldNames = Object.create(null);\n return {\n InputObjectTypeDefinition: checkFieldUniqueness,\n InputObjectTypeExtension: checkFieldUniqueness,\n InterfaceTypeDefinition: checkFieldUniqueness,\n InterfaceTypeExtension: checkFieldUniqueness,\n ObjectTypeDefinition: checkFieldUniqueness,\n ObjectTypeExtension: checkFieldUniqueness\n };\n\n function checkFieldUniqueness(node) {\n const typeName = node.name.value;\n\n if (!knownFieldNames[typeName]) {\n knownFieldNames[typeName] = Object.create(null);\n } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n\n const fieldNodes = node.fields ?? [];\n const fieldNames = knownFieldNames[typeName];\n\n for (const fieldDef of fieldNodes) {\n const fieldName = fieldDef.name.value;\n\n if (hasField(existingTypeMap[typeName], fieldName)) {\n context.reportError(new GraphQLError(`Field \"${typeName}.${fieldName}\" already exists in the schema. It cannot also be defined in this type extension.`, fieldDef.name));\n } else if (fieldNames[fieldName]) {\n context.reportError(new GraphQLError(`Field \"${typeName}.${fieldName}\" can only be defined once.`, [fieldNames[fieldName], fieldDef.name]));\n } else {\n fieldNames[fieldName] = fieldDef.name;\n }\n }\n\n return false;\n }\n}\n\nfunction hasField(type, fieldName) {\n if (isObjectType(type) || isInterfaceType(type) || isInputObjectType(type)) {\n return type.getFields()[fieldName] != null;\n }\n\n return false;\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport invariant from \"../../jsutils/invariant.mjs\";\nimport didYouMean from \"../../jsutils/didYouMean.mjs\";\nimport suggestionList from \"../../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { isTypeDefinitionNode } from \"../../language/predicates.mjs\";\nimport { isScalarType, isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType } from \"../../type/definition.mjs\";\n\n/**\n * Possible type extension\n *\n * A type extension is only valid if the type is defined and has the same kind.\n */\nexport function PossibleTypeExtensionsRule(context) {\n const schema = context.getSchema();\n const definedTypes = Object.create(null);\n\n for (const def of context.getDocument().definitions) {\n if (isTypeDefinitionNode(def)) {\n definedTypes[def.name.value] = def;\n }\n }\n\n return {\n ScalarTypeExtension: checkExtension,\n ObjectTypeExtension: checkExtension,\n InterfaceTypeExtension: checkExtension,\n UnionTypeExtension: checkExtension,\n EnumTypeExtension: checkExtension,\n InputObjectTypeExtension: checkExtension\n };\n\n function checkExtension(node) {\n const typeName = node.name.value;\n const defNode = definedTypes[typeName];\n const existingType = schema?.getType(typeName);\n let expectedKind;\n\n if (defNode) {\n expectedKind = defKindToExtKind[defNode.kind];\n } else if (existingType) {\n expectedKind = typeToExtKind(existingType);\n }\n\n if (expectedKind) {\n if (expectedKind !== node.kind) {\n const kindStr = extensionKindToTypeName(node.kind);\n context.reportError(new GraphQLError(`Cannot extend non-${kindStr} type \"${typeName}\".`, defNode ? [defNode, node] : node));\n }\n } else {\n let allTypeNames = Object.keys(definedTypes);\n\n if (schema) {\n allTypeNames = allTypeNames.concat(Object.keys(schema.getTypeMap()));\n }\n\n const suggestedTypes = suggestionList(typeName, allTypeNames);\n context.reportError(new GraphQLError(`Cannot extend type \"${typeName}\" because it is not defined.` + didYouMean(suggestedTypes), node.name));\n }\n }\n}\nconst defKindToExtKind = {\n [Kind.SCALAR_TYPE_DEFINITION]: Kind.SCALAR_TYPE_EXTENSION,\n [Kind.OBJECT_TYPE_DEFINITION]: Kind.OBJECT_TYPE_EXTENSION,\n [Kind.INTERFACE_TYPE_DEFINITION]: Kind.INTERFACE_TYPE_EXTENSION,\n [Kind.UNION_TYPE_DEFINITION]: Kind.UNION_TYPE_EXTENSION,\n [Kind.ENUM_TYPE_DEFINITION]: Kind.ENUM_TYPE_EXTENSION,\n [Kind.INPUT_OBJECT_TYPE_DEFINITION]: Kind.INPUT_OBJECT_TYPE_EXTENSION\n};\n\nfunction typeToExtKind(type) {\n if (isScalarType(type)) {\n return Kind.SCALAR_TYPE_EXTENSION;\n }\n\n if (isObjectType(type)) {\n return Kind.OBJECT_TYPE_EXTENSION;\n }\n\n if (isInterfaceType(type)) {\n return Kind.INTERFACE_TYPE_EXTENSION;\n }\n\n if (isUnionType(type)) {\n return Kind.UNION_TYPE_EXTENSION;\n }\n\n if (isEnumType(type)) {\n return Kind.ENUM_TYPE_EXTENSION;\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isInputObjectType(type)) {\n return Kind.INPUT_OBJECT_TYPE_EXTENSION;\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, 'Unexpected type: ' + inspect(type));\n}\n\nfunction extensionKindToTypeName(kind) {\n switch (kind) {\n case Kind.SCALAR_TYPE_EXTENSION:\n return 'scalar';\n\n case Kind.OBJECT_TYPE_EXTENSION:\n return 'object';\n\n case Kind.INTERFACE_TYPE_EXTENSION:\n return 'interface';\n\n case Kind.UNION_TYPE_EXTENSION:\n return 'union';\n\n case Kind.ENUM_TYPE_EXTENSION:\n return 'enum';\n\n case Kind.INPUT_OBJECT_TYPE_EXTENSION:\n return 'input object';\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, 'Unexpected kind: ' + inspect(kind));\n}\n","// Spec Section: \"Executable Definitions\"\nimport { ExecutableDefinitionsRule } from \"./rules/ExecutableDefinitionsRule.mjs\"; // Spec Section: \"Operation Name Uniqueness\"\n\nimport { UniqueOperationNamesRule } from \"./rules/UniqueOperationNamesRule.mjs\"; // Spec Section: \"Lone Anonymous Operation\"\n\nimport { LoneAnonymousOperationRule } from \"./rules/LoneAnonymousOperationRule.mjs\"; // Spec Section: \"Subscriptions with Single Root Field\"\n\nimport { SingleFieldSubscriptionsRule } from \"./rules/SingleFieldSubscriptionsRule.mjs\"; // Spec Section: \"Fragment Spread Type Existence\"\n\nimport { KnownTypeNamesRule } from \"./rules/KnownTypeNamesRule.mjs\"; // Spec Section: \"Fragments on Composite Types\"\n\nimport { FragmentsOnCompositeTypesRule } from \"./rules/FragmentsOnCompositeTypesRule.mjs\"; // Spec Section: \"Variables are Input Types\"\n\nimport { VariablesAreInputTypesRule } from \"./rules/VariablesAreInputTypesRule.mjs\"; // Spec Section: \"Leaf Field Selections\"\n\nimport { ScalarLeafsRule } from \"./rules/ScalarLeafsRule.mjs\"; // Spec Section: \"Field Selections on Objects, Interfaces, and Unions Types\"\n\nimport { FieldsOnCorrectTypeRule } from \"./rules/FieldsOnCorrectTypeRule.mjs\"; // Spec Section: \"Fragment Name Uniqueness\"\n\nimport { UniqueFragmentNamesRule } from \"./rules/UniqueFragmentNamesRule.mjs\"; // Spec Section: \"Fragment spread target defined\"\n\nimport { KnownFragmentNamesRule } from \"./rules/KnownFragmentNamesRule.mjs\"; // Spec Section: \"Fragments must be used\"\n\nimport { NoUnusedFragmentsRule } from \"./rules/NoUnusedFragmentsRule.mjs\"; // Spec Section: \"Fragment spread is possible\"\n\nimport { PossibleFragmentSpreadsRule } from \"./rules/PossibleFragmentSpreadsRule.mjs\"; // Spec Section: \"Fragments must not form cycles\"\n\nimport { NoFragmentCyclesRule } from \"./rules/NoFragmentCyclesRule.mjs\"; // Spec Section: \"Variable Uniqueness\"\n\nimport { UniqueVariableNamesRule } from \"./rules/UniqueVariableNamesRule.mjs\"; // Spec Section: \"All Variable Used Defined\"\n\nimport { NoUndefinedVariablesRule } from \"./rules/NoUndefinedVariablesRule.mjs\"; // Spec Section: \"All Variables Used\"\n\nimport { NoUnusedVariablesRule } from \"./rules/NoUnusedVariablesRule.mjs\"; // Spec Section: \"Directives Are Defined\"\n\nimport { KnownDirectivesRule } from \"./rules/KnownDirectivesRule.mjs\"; // Spec Section: \"Directives Are Unique Per Location\"\n\nimport { UniqueDirectivesPerLocationRule } from \"./rules/UniqueDirectivesPerLocationRule.mjs\"; // Spec Section: \"Argument Names\"\n\nimport { KnownArgumentNamesRule, KnownArgumentNamesOnDirectivesRule } from \"./rules/KnownArgumentNamesRule.mjs\"; // Spec Section: \"Argument Uniqueness\"\n\nimport { UniqueArgumentNamesRule } from \"./rules/UniqueArgumentNamesRule.mjs\"; // Spec Section: \"Value Type Correctness\"\n\nimport { ValuesOfCorrectTypeRule } from \"./rules/ValuesOfCorrectTypeRule.mjs\"; // Spec Section: \"Argument Optionality\"\n\nimport { ProvidedRequiredArgumentsRule, ProvidedRequiredArgumentsOnDirectivesRule } from \"./rules/ProvidedRequiredArgumentsRule.mjs\"; // Spec Section: \"All Variable Usages Are Allowed\"\n\nimport { VariablesInAllowedPositionRule } from \"./rules/VariablesInAllowedPositionRule.mjs\"; // Spec Section: \"Field Selection Merging\"\n\nimport { OverlappingFieldsCanBeMergedRule } from \"./rules/OverlappingFieldsCanBeMergedRule.mjs\"; // Spec Section: \"Input Object Field Uniqueness\"\n\nimport { UniqueInputFieldNamesRule } from \"./rules/UniqueInputFieldNamesRule.mjs\"; // SDL-specific validation rules\n\nimport { LoneSchemaDefinitionRule } from \"./rules/LoneSchemaDefinitionRule.mjs\";\nimport { UniqueOperationTypesRule } from \"./rules/UniqueOperationTypesRule.mjs\";\nimport { UniqueTypeNamesRule } from \"./rules/UniqueTypeNamesRule.mjs\";\nimport { UniqueEnumValueNamesRule } from \"./rules/UniqueEnumValueNamesRule.mjs\";\nimport { UniqueFieldDefinitionNamesRule } from \"./rules/UniqueFieldDefinitionNamesRule.mjs\";\nimport { UniqueDirectiveNamesRule } from \"./rules/UniqueDirectiveNamesRule.mjs\";\nimport { PossibleTypeExtensionsRule } from \"./rules/PossibleTypeExtensionsRule.mjs\";\n/**\n * This set includes all validation rules defined by the GraphQL spec.\n *\n * The order of the rules in this list has been adjusted to lead to the\n * most clear output when encountering multiple validation errors.\n */\n\nexport const specifiedRules = Object.freeze([ExecutableDefinitionsRule, UniqueOperationNamesRule, LoneAnonymousOperationRule, SingleFieldSubscriptionsRule, KnownTypeNamesRule, FragmentsOnCompositeTypesRule, VariablesAreInputTypesRule, ScalarLeafsRule, FieldsOnCorrectTypeRule, UniqueFragmentNamesRule, KnownFragmentNamesRule, NoUnusedFragmentsRule, PossibleFragmentSpreadsRule, NoFragmentCyclesRule, UniqueVariableNamesRule, NoUndefinedVariablesRule, NoUnusedVariablesRule, KnownDirectivesRule, UniqueDirectivesPerLocationRule, KnownArgumentNamesRule, UniqueArgumentNamesRule, ValuesOfCorrectTypeRule, ProvidedRequiredArgumentsRule, VariablesInAllowedPositionRule, OverlappingFieldsCanBeMergedRule, UniqueInputFieldNamesRule]);\n/**\n * @internal\n */\n\nexport const specifiedSDLRules = Object.freeze([LoneSchemaDefinitionRule, UniqueOperationTypesRule, UniqueTypeNamesRule, UniqueEnumValueNamesRule, UniqueFieldDefinitionNamesRule, UniqueDirectiveNamesRule, KnownTypeNamesRule, KnownDirectivesRule, UniqueDirectivesPerLocationRule, PossibleTypeExtensionsRule, KnownArgumentNamesOnDirectivesRule, UniqueArgumentNamesRule, UniqueInputFieldNamesRule, ProvidedRequiredArgumentsOnDirectivesRule]);\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { isExecutableDefinitionNode } from \"../../language/predicates.mjs\";\n\n/**\n * Executable definitions\n *\n * A GraphQL document is only valid for execution if all definitions are either\n * operation or fragment definitions.\n */\nexport function ExecutableDefinitionsRule(context) {\n return {\n Document(node) {\n for (const definition of node.definitions) {\n if (!isExecutableDefinitionNode(definition)) {\n const defName = definition.kind === Kind.SCHEMA_DEFINITION || definition.kind === Kind.SCHEMA_EXTENSION ? 'schema' : '\"' + definition.name.value + '\"';\n context.reportError(new GraphQLError(`The ${defName} definition is not executable.`, definition));\n }\n }\n\n return false;\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique operation names\n *\n * A GraphQL document is only valid if all defined operations have unique names.\n */\nexport function UniqueOperationNamesRule(context) {\n const knownOperationNames = Object.create(null);\n return {\n OperationDefinition(node) {\n const operationName = node.name;\n\n if (operationName) {\n if (knownOperationNames[operationName.value]) {\n context.reportError(new GraphQLError(`There can be only one operation named \"${operationName.value}\".`, [knownOperationNames[operationName.value], operationName]));\n } else {\n knownOperationNames[operationName.value] = operationName;\n }\n }\n\n return false;\n },\n\n FragmentDefinition: () => false\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\n\n/**\n * Lone anonymous operation\n *\n * A GraphQL document is only valid if when it contains an anonymous operation\n * (the query short-hand) that it contains only that one operation definition.\n */\nexport function LoneAnonymousOperationRule(context) {\n let operationCount = 0;\n return {\n Document(node) {\n operationCount = node.definitions.filter(definition => definition.kind === Kind.OPERATION_DEFINITION).length;\n },\n\n OperationDefinition(node) {\n if (!node.name && operationCount > 1) {\n context.reportError(new GraphQLError('This anonymous operation must be the only defined operation.', node));\n }\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Subscriptions must only include one field.\n *\n * A GraphQL subscription is valid only if it contains a single root field.\n */\nexport function SingleFieldSubscriptionsRule(context) {\n return {\n OperationDefinition(node) {\n if (node.operation === 'subscription') {\n if (node.selectionSet.selections.length !== 1) {\n context.reportError(new GraphQLError(node.name ? `Subscription \"${node.name.value}\" must select only one top level field.` : 'Anonymous Subscription must select only one top level field.', node.selectionSet.selections.slice(1)));\n }\n }\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { print } from \"../../language/printer.mjs\";\nimport { isCompositeType } from \"../../type/definition.mjs\";\nimport { typeFromAST } from \"../../utilities/typeFromAST.mjs\";\n\n/**\n * Fragments on composite type\n *\n * Fragments use a type condition to determine if they apply, since fragments\n * can only be spread into a composite type (object, interface, or union), the\n * type condition must also be a composite type.\n */\nexport function FragmentsOnCompositeTypesRule(context) {\n return {\n InlineFragment(node) {\n const typeCondition = node.typeCondition;\n\n if (typeCondition) {\n const type = typeFromAST(context.getSchema(), typeCondition);\n\n if (type && !isCompositeType(type)) {\n const typeStr = print(typeCondition);\n context.reportError(new GraphQLError(`Fragment cannot condition on non composite type \"${typeStr}\".`, typeCondition));\n }\n }\n },\n\n FragmentDefinition(node) {\n const type = typeFromAST(context.getSchema(), node.typeCondition);\n\n if (type && !isCompositeType(type)) {\n const typeStr = print(node.typeCondition);\n context.reportError(new GraphQLError(`Fragment \"${node.name.value}\" cannot condition on non composite type \"${typeStr}\".`, node.typeCondition));\n }\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { print } from \"../../language/printer.mjs\";\nimport { isInputType } from \"../../type/definition.mjs\";\nimport { typeFromAST } from \"../../utilities/typeFromAST.mjs\";\n\n/**\n * Variables are input types\n *\n * A GraphQL operation is only valid if all the variables it defines are of\n * input types (scalar, enum, or input object).\n */\nexport function VariablesAreInputTypesRule(context) {\n return {\n VariableDefinition(node) {\n const type = typeFromAST(context.getSchema(), node.type);\n\n if (type && !isInputType(type)) {\n const variableName = node.variable.name.value;\n const typeName = print(node.type);\n context.reportError(new GraphQLError(`Variable \"$${variableName}\" cannot be non-input type \"${typeName}\".`, node.type));\n }\n }\n\n };\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { getNamedType, isLeafType } from \"../../type/definition.mjs\";\n\n/**\n * Scalar leafs\n *\n * A GraphQL document is valid only if all leaf fields (fields without\n * sub selections) are of scalar or enum types.\n */\nexport function ScalarLeafsRule(context) {\n return {\n Field(node) {\n const type = context.getType();\n const selectionSet = node.selectionSet;\n\n if (type) {\n if (isLeafType(getNamedType(type))) {\n if (selectionSet) {\n const fieldName = node.name.value;\n const typeStr = inspect(type);\n context.reportError(new GraphQLError(`Field \"${fieldName}\" must not have a selection since type \"${typeStr}\" has no subfields.`, selectionSet));\n }\n } else if (!selectionSet) {\n const fieldName = node.name.value;\n const typeStr = inspect(type);\n context.reportError(new GraphQLError(`Field \"${fieldName}\" of type \"${typeStr}\" must have a selection of subfields. Did you mean \"${fieldName} { ... }\"?`, node));\n }\n }\n }\n\n };\n}\n","import didYouMean from \"../../jsutils/didYouMean.mjs\";\nimport suggestionList from \"../../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { isObjectType, isInterfaceType, isAbstractType } from \"../../type/definition.mjs\";\n\n/**\n * Fields on correct type\n *\n * A GraphQL document is only valid if all fields selected are defined by the\n * parent type, or are an allowed meta field such as __typename.\n */\nexport function FieldsOnCorrectTypeRule(context) {\n return {\n Field(node) {\n const type = context.getParentType();\n\n if (type) {\n const fieldDef = context.getFieldDef();\n\n if (!fieldDef) {\n // This field doesn't exist, lets look for suggestions.\n const schema = context.getSchema();\n const fieldName = node.name.value; // First determine if there are any suggested types to condition on.\n\n let suggestion = didYouMean('to use an inline fragment on', getSuggestedTypeNames(schema, type, fieldName)); // If there are no suggested types, then perhaps this was a typo?\n\n if (suggestion === '') {\n suggestion = didYouMean(getSuggestedFieldNames(type, fieldName));\n } // Report an error, including helpful suggestions.\n\n\n context.reportError(new GraphQLError(`Cannot query field \"${fieldName}\" on type \"${type.name}\".` + suggestion, node));\n }\n }\n }\n\n };\n}\n/**\n * Go through all of the implementations of type, as well as the interfaces that\n * they implement. If any of those types include the provided field, suggest them,\n * sorted by how often the type is referenced.\n */\n\nfunction getSuggestedTypeNames(schema, type, fieldName) {\n if (!isAbstractType(type)) {\n // Must be an Object type, which does not have possible fields.\n return [];\n }\n\n const suggestedTypes = new Set();\n const usageCount = Object.create(null);\n\n for (const possibleType of schema.getPossibleTypes(type)) {\n if (!possibleType.getFields()[fieldName]) {\n continue;\n } // This object type defines this field.\n\n\n suggestedTypes.add(possibleType);\n usageCount[possibleType.name] = 1;\n\n for (const possibleInterface of possibleType.getInterfaces()) {\n if (!possibleInterface.getFields()[fieldName]) {\n continue;\n } // This interface type defines this field.\n\n\n suggestedTypes.add(possibleInterface);\n usageCount[possibleInterface.name] = (usageCount[possibleInterface.name] ?? 0) + 1;\n }\n }\n\n return Array.from(suggestedTypes).sort((typeA, typeB) => {\n // Suggest both interface and object types based on how common they are.\n const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name];\n\n if (usageCountDiff !== 0) {\n return usageCountDiff;\n } // Suggest super types first followed by subtypes\n\n\n if (isInterfaceType(typeA) && schema.isSubType(typeA, typeB)) {\n return -1;\n }\n\n if (isInterfaceType(typeB) && schema.isSubType(typeB, typeA)) {\n return 1;\n }\n\n return typeA.name.localeCompare(typeB.name);\n }).map(x => x.name);\n}\n/**\n * For the field name provided, determine if there are any similar field names\n * that may be the result of a typo.\n */\n\n\nfunction getSuggestedFieldNames(type, fieldName) {\n if (isObjectType(type) || isInterfaceType(type)) {\n const possibleFieldNames = Object.keys(type.getFields());\n return suggestionList(fieldName, possibleFieldNames);\n } // Otherwise, must be a Union type, which does not define fields.\n\n\n return [];\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique fragment names\n *\n * A GraphQL document is only valid if all defined fragments have unique names.\n */\nexport function UniqueFragmentNamesRule(context) {\n const knownFragmentNames = Object.create(null);\n return {\n OperationDefinition: () => false,\n\n FragmentDefinition(node) {\n const fragmentName = node.name.value;\n\n if (knownFragmentNames[fragmentName]) {\n context.reportError(new GraphQLError(`There can be only one fragment named \"${fragmentName}\".`, [knownFragmentNames[fragmentName], node.name]));\n } else {\n knownFragmentNames[fragmentName] = node.name;\n }\n\n return false;\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Known fragment names\n *\n * A GraphQL document is only valid if all `...Fragment` fragment spreads refer\n * to fragments defined in the same document.\n */\nexport function KnownFragmentNamesRule(context) {\n return {\n FragmentSpread(node) {\n const fragmentName = node.name.value;\n const fragment = context.getFragment(fragmentName);\n\n if (!fragment) {\n context.reportError(new GraphQLError(`Unknown fragment \"${fragmentName}\".`, node.name));\n }\n }\n\n };\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { isCompositeType } from \"../../type/definition.mjs\";\nimport { typeFromAST } from \"../../utilities/typeFromAST.mjs\";\nimport { doTypesOverlap } from \"../../utilities/typeComparators.mjs\";\n\n/**\n * Possible fragment spread\n *\n * A fragment spread is only valid if the type condition could ever possibly\n * be true: if there is a non-empty intersection of the possible parent types,\n * and possible types which pass the type condition.\n */\nexport function PossibleFragmentSpreadsRule(context) {\n return {\n InlineFragment(node) {\n const fragType = context.getType();\n const parentType = context.getParentType();\n\n if (isCompositeType(fragType) && isCompositeType(parentType) && !doTypesOverlap(context.getSchema(), fragType, parentType)) {\n const parentTypeStr = inspect(parentType);\n const fragTypeStr = inspect(fragType);\n context.reportError(new GraphQLError(`Fragment cannot be spread here as objects of type \"${parentTypeStr}\" can never be of type \"${fragTypeStr}\".`, node));\n }\n },\n\n FragmentSpread(node) {\n const fragName = node.name.value;\n const fragType = getFragmentType(context, fragName);\n const parentType = context.getParentType();\n\n if (fragType && parentType && !doTypesOverlap(context.getSchema(), fragType, parentType)) {\n const parentTypeStr = inspect(parentType);\n const fragTypeStr = inspect(fragType);\n context.reportError(new GraphQLError(`Fragment \"${fragName}\" cannot be spread here as objects of type \"${parentTypeStr}\" can never be of type \"${fragTypeStr}\".`, node));\n }\n }\n\n };\n}\n\nfunction getFragmentType(context, name) {\n const frag = context.getFragment(name);\n\n if (frag) {\n const type = typeFromAST(context.getSchema(), frag.typeCondition);\n\n if (isCompositeType(type)) {\n return type;\n }\n }\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nexport function NoFragmentCyclesRule(context) {\n // Tracks already visited fragments to maintain O(N) and to ensure that cycles\n // are not redundantly reported.\n const visitedFrags = Object.create(null); // Array of AST nodes used to produce meaningful errors\n\n const spreadPath = []; // Position in the spread path\n\n const spreadPathIndexByName = Object.create(null);\n return {\n OperationDefinition: () => false,\n\n FragmentDefinition(node) {\n detectCycleRecursive(node);\n return false;\n }\n\n }; // This does a straight-forward DFS to find cycles.\n // It does not terminate when a cycle was found but continues to explore\n // the graph to find all possible cycles.\n\n function detectCycleRecursive(fragment) {\n if (visitedFrags[fragment.name.value]) {\n return;\n }\n\n const fragmentName = fragment.name.value;\n visitedFrags[fragmentName] = true;\n const spreadNodes = context.getFragmentSpreads(fragment.selectionSet);\n\n if (spreadNodes.length === 0) {\n return;\n }\n\n spreadPathIndexByName[fragmentName] = spreadPath.length;\n\n for (const spreadNode of spreadNodes) {\n const spreadName = spreadNode.name.value;\n const cycleIndex = spreadPathIndexByName[spreadName];\n spreadPath.push(spreadNode);\n\n if (cycleIndex === undefined) {\n const spreadFragment = context.getFragment(spreadName);\n\n if (spreadFragment) {\n detectCycleRecursive(spreadFragment);\n }\n } else {\n const cyclePath = spreadPath.slice(cycleIndex);\n const viaPath = cyclePath.slice(0, -1).map(s => '\"' + s.name.value + '\"').join(', ');\n context.reportError(new GraphQLError(`Cannot spread fragment \"${spreadName}\" within itself` + (viaPath !== '' ? ` via ${viaPath}.` : '.'), cyclePath));\n }\n\n spreadPath.pop();\n }\n\n spreadPathIndexByName[fragmentName] = undefined;\n }\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique variable names\n *\n * A GraphQL operation is only valid if all its variables are uniquely named.\n */\nexport function UniqueVariableNamesRule(context) {\n let knownVariableNames = Object.create(null);\n return {\n OperationDefinition() {\n knownVariableNames = Object.create(null);\n },\n\n VariableDefinition(node) {\n const variableName = node.variable.name.value;\n\n if (knownVariableNames[variableName]) {\n context.reportError(new GraphQLError(`There can be only one variable named \"$${variableName}\".`, [knownVariableNames[variableName], node.variable.name]));\n } else {\n knownVariableNames[variableName] = node.variable.name;\n }\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * No undefined variables\n *\n * A GraphQL operation is only valid if all variables encountered, both directly\n * and via fragment spreads, are defined by that operation.\n */\nexport function NoUndefinedVariablesRule(context) {\n let variableNameDefined = Object.create(null);\n return {\n OperationDefinition: {\n enter() {\n variableNameDefined = Object.create(null);\n },\n\n leave(operation) {\n const usages = context.getRecursiveVariableUsages(operation);\n\n for (const {\n node\n } of usages) {\n const varName = node.name.value;\n\n if (variableNameDefined[varName] !== true) {\n context.reportError(new GraphQLError(operation.name ? `Variable \"$${varName}\" is not defined by operation \"${operation.name.value}\".` : `Variable \"$${varName}\" is not defined.`, [node, operation]));\n }\n }\n }\n\n },\n\n VariableDefinition(node) {\n variableNameDefined[node.variable.name.value] = true;\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * No unused variables\n *\n * A GraphQL operation is only valid if all variables defined by an operation\n * are used, either directly or within a spread fragment.\n */\nexport function NoUnusedVariablesRule(context) {\n let variableDefs = [];\n return {\n OperationDefinition: {\n enter() {\n variableDefs = [];\n },\n\n leave(operation) {\n const variableNameUsed = Object.create(null);\n const usages = context.getRecursiveVariableUsages(operation);\n\n for (const {\n node\n } of usages) {\n variableNameUsed[node.name.value] = true;\n }\n\n for (const variableDef of variableDefs) {\n const variableName = variableDef.variable.name.value;\n\n if (variableNameUsed[variableName] !== true) {\n context.reportError(new GraphQLError(operation.name ? `Variable \"$${variableName}\" is never used in operation \"${operation.name.value}\".` : `Variable \"$${variableName}\" is never used.`, variableDef));\n }\n }\n }\n\n },\n\n VariableDefinition(def) {\n variableDefs.push(def);\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Lone Schema definition\n *\n * A GraphQL document is only valid if it contains only one schema definition.\n */\nexport function LoneSchemaDefinitionRule(context) {\n const oldSchema = context.getSchema();\n const alreadyDefined = oldSchema?.astNode ?? oldSchema?.getQueryType() ?? oldSchema?.getMutationType() ?? oldSchema?.getSubscriptionType();\n let schemaDefinitionsCount = 0;\n return {\n SchemaDefinition(node) {\n if (alreadyDefined) {\n context.reportError(new GraphQLError('Cannot define a new schema within a schema extension.', node));\n return;\n }\n\n if (schemaDefinitionsCount > 0) {\n context.reportError(new GraphQLError('Must provide only one schema definition.', node));\n }\n\n ++schemaDefinitionsCount;\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique operation types\n *\n * A GraphQL document is only valid if it has only one type per operation.\n */\nexport function UniqueOperationTypesRule(context) {\n const schema = context.getSchema();\n const definedOperationTypes = Object.create(null);\n const existingOperationTypes = schema ? {\n query: schema.getQueryType(),\n mutation: schema.getMutationType(),\n subscription: schema.getSubscriptionType()\n } : {};\n return {\n SchemaDefinition: checkOperationTypes,\n SchemaExtension: checkOperationTypes\n };\n\n function checkOperationTypes(node) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const operationTypesNodes = node.operationTypes ?? [];\n\n for (const operationType of operationTypesNodes) {\n const operation = operationType.operation;\n const alreadyDefinedOperationType = definedOperationTypes[operation];\n\n if (existingOperationTypes[operation]) {\n context.reportError(new GraphQLError(`Type for ${operation} already defined in the schema. It cannot be redefined.`, operationType));\n } else if (alreadyDefinedOperationType) {\n context.reportError(new GraphQLError(`There can be only one ${operation} type in schema.`, [alreadyDefinedOperationType, operationType]));\n } else {\n definedOperationTypes[operation] = operationType;\n }\n }\n\n return false;\n }\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique type names\n *\n * A GraphQL document is only valid if all defined types have unique names.\n */\nexport function UniqueTypeNamesRule(context) {\n const knownTypeNames = Object.create(null);\n const schema = context.getSchema();\n return {\n ScalarTypeDefinition: checkTypeName,\n ObjectTypeDefinition: checkTypeName,\n InterfaceTypeDefinition: checkTypeName,\n UnionTypeDefinition: checkTypeName,\n EnumTypeDefinition: checkTypeName,\n InputObjectTypeDefinition: checkTypeName\n };\n\n function checkTypeName(node) {\n const typeName = node.name.value;\n\n if (schema?.getType(typeName)) {\n context.reportError(new GraphQLError(`Type \"${typeName}\" already exists in the schema. It cannot also be defined in this type definition.`, node.name));\n return;\n }\n\n if (knownTypeNames[typeName]) {\n context.reportError(new GraphQLError(`There can be only one type named \"${typeName}\".`, [knownTypeNames[typeName], node.name]));\n } else {\n knownTypeNames[typeName] = node.name;\n }\n\n return false;\n }\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { isEnumType } from \"../../type/definition.mjs\";\n\n/**\n * Unique enum value names\n *\n * A GraphQL enum type is only valid if all its values are uniquely named.\n */\nexport function UniqueEnumValueNamesRule(context) {\n const schema = context.getSchema();\n const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);\n const knownValueNames = Object.create(null);\n return {\n EnumTypeDefinition: checkValueUniqueness,\n EnumTypeExtension: checkValueUniqueness\n };\n\n function checkValueUniqueness(node) {\n const typeName = node.name.value;\n\n if (!knownValueNames[typeName]) {\n knownValueNames[typeName] = Object.create(null);\n } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n\n const valueNodes = node.values ?? [];\n const valueNames = knownValueNames[typeName];\n\n for (const valueDef of valueNodes) {\n const valueName = valueDef.name.value;\n const existingType = existingTypeMap[typeName];\n\n if (isEnumType(existingType) && existingType.getValue(valueName)) {\n context.reportError(new GraphQLError(`Enum value \"${typeName}.${valueName}\" already exists in the schema. It cannot also be defined in this type extension.`, valueDef.name));\n } else if (valueNames[valueName]) {\n context.reportError(new GraphQLError(`Enum value \"${typeName}.${valueName}\" can only be defined once.`, [valueNames[valueName], valueDef.name]));\n } else {\n valueNames[valueName] = valueDef.name;\n }\n }\n\n return false;\n }\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique directive names\n *\n * A GraphQL document is only valid if all defined directives have unique names.\n */\nexport function UniqueDirectiveNamesRule(context) {\n const knownDirectiveNames = Object.create(null);\n const schema = context.getSchema();\n return {\n DirectiveDefinition(node) {\n const directiveName = node.name.value;\n\n if (schema?.getDirective(directiveName)) {\n context.reportError(new GraphQLError(`Directive \"@${directiveName}\" already exists in the schema. It cannot be redefined.`, node.name));\n return;\n }\n\n if (knownDirectiveNames[directiveName]) {\n context.reportError(new GraphQLError(`There can be only one directive named \"@${directiveName}\".`, [knownDirectiveNames[directiveName], node.name]));\n } else {\n knownDirectiveNames[directiveName] = node.name;\n }\n\n return false;\n }\n\n };\n}\n","import { Kind } from \"../language/kinds.mjs\";\nimport { visit } from \"../language/visitor.mjs\";\nimport { TypeInfo, visitWithTypeInfo } from \"../utilities/TypeInfo.mjs\";\n\n/**\n * An instance of this class is passed as the \"this\" context to all validators,\n * allowing access to commonly useful contextual information from within a\n * validation rule.\n */\nexport class ASTValidationContext {\n constructor(ast, onError) {\n this._ast = ast;\n this._fragments = undefined;\n this._fragmentSpreads = new Map();\n this._recursivelyReferencedFragments = new Map();\n this._onError = onError;\n }\n\n reportError(error) {\n this._onError(error);\n }\n\n getDocument() {\n return this._ast;\n }\n\n getFragment(name) {\n let fragments = this._fragments;\n\n if (!fragments) {\n this._fragments = fragments = this.getDocument().definitions.reduce((frags, statement) => {\n if (statement.kind === Kind.FRAGMENT_DEFINITION) {\n frags[statement.name.value] = statement;\n }\n\n return frags;\n }, Object.create(null));\n }\n\n return fragments[name];\n }\n\n getFragmentSpreads(node) {\n let spreads = this._fragmentSpreads.get(node);\n\n if (!spreads) {\n spreads = [];\n const setsToVisit = [node];\n\n while (setsToVisit.length !== 0) {\n const set = setsToVisit.pop();\n\n for (const selection of set.selections) {\n if (selection.kind === Kind.FRAGMENT_SPREAD) {\n spreads.push(selection);\n } else if (selection.selectionSet) {\n setsToVisit.push(selection.selectionSet);\n }\n }\n }\n\n this._fragmentSpreads.set(node, spreads);\n }\n\n return spreads;\n }\n\n getRecursivelyReferencedFragments(operation) {\n let fragments = this._recursivelyReferencedFragments.get(operation);\n\n if (!fragments) {\n fragments = [];\n const collectedNames = Object.create(null);\n const nodesToVisit = [operation.selectionSet];\n\n while (nodesToVisit.length !== 0) {\n const node = nodesToVisit.pop();\n\n for (const spread of this.getFragmentSpreads(node)) {\n const fragName = spread.name.value;\n\n if (collectedNames[fragName] !== true) {\n collectedNames[fragName] = true;\n const fragment = this.getFragment(fragName);\n\n if (fragment) {\n fragments.push(fragment);\n nodesToVisit.push(fragment.selectionSet);\n }\n }\n }\n }\n\n this._recursivelyReferencedFragments.set(operation, fragments);\n }\n\n return fragments;\n }\n\n}\nexport class SDLValidationContext extends ASTValidationContext {\n constructor(ast, schema, onError) {\n super(ast, onError);\n this._schema = schema;\n }\n\n getSchema() {\n return this._schema;\n }\n\n}\nexport class ValidationContext extends ASTValidationContext {\n constructor(schema, ast, typeInfo, onError) {\n super(ast, onError);\n this._schema = schema;\n this._typeInfo = typeInfo;\n this._variableUsages = new Map();\n this._recursiveVariableUsages = new Map();\n }\n\n getSchema() {\n return this._schema;\n }\n\n getVariableUsages(node) {\n let usages = this._variableUsages.get(node);\n\n if (!usages) {\n const newUsages = [];\n const typeInfo = new TypeInfo(this._schema);\n visit(node, visitWithTypeInfo(typeInfo, {\n VariableDefinition: () => false,\n\n Variable(variable) {\n newUsages.push({\n node: variable,\n type: typeInfo.getInputType(),\n defaultValue: typeInfo.getDefaultValue()\n });\n }\n\n }));\n usages = newUsages;\n\n this._variableUsages.set(node, usages);\n }\n\n return usages;\n }\n\n getRecursiveVariableUsages(operation) {\n let usages = this._recursiveVariableUsages.get(operation);\n\n if (!usages) {\n usages = this.getVariableUsages(operation);\n\n for (const frag of this.getRecursivelyReferencedFragments(operation)) {\n usages = usages.concat(this.getVariableUsages(frag));\n }\n\n this._recursiveVariableUsages.set(operation, usages);\n }\n\n return usages;\n }\n\n getType() {\n return this._typeInfo.getType();\n }\n\n getParentType() {\n return this._typeInfo.getParentType();\n }\n\n getInputType() {\n return this._typeInfo.getInputType();\n }\n\n getParentInputType() {\n return this._typeInfo.getParentInputType();\n }\n\n getFieldDef() {\n return this._typeInfo.getFieldDef();\n }\n\n getDirective() {\n return this._typeInfo.getDirective();\n }\n\n getArgument() {\n return this._typeInfo.getArgument();\n }\n\n getEnumValue() {\n return this._typeInfo.getEnumValue();\n }\n\n}\n","import devAssert from \"../jsutils/devAssert.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nimport { visit, visitInParallel } from \"../language/visitor.mjs\";\nimport { assertValidSchema } from \"../type/validate.mjs\";\nimport { TypeInfo, visitWithTypeInfo } from \"../utilities/TypeInfo.mjs\";\nimport { specifiedRules, specifiedSDLRules } from \"./specifiedRules.mjs\";\nimport { SDLValidationContext, ValidationContext } from \"./ValidationContext.mjs\";\n/**\n * Implements the \"Validation\" section of the spec.\n *\n * Validation runs synchronously, returning an array of encountered errors, or\n * an empty array if no errors were encountered and the document is valid.\n *\n * A list of specific validation rules may be provided. If not provided, the\n * default list of rules defined by the GraphQL specification will be used.\n *\n * Each validation rules is a function which returns a visitor\n * (see the language/visitor API). Visitor methods are expected to return\n * GraphQLErrors, or Arrays of GraphQLErrors when invalid.\n *\n * Optionally a custom TypeInfo instance may be provided. If not provided, one\n * will be created from the provided schema.\n */\n\nexport function validate(schema, documentAST, rules = specifiedRules, typeInfo = new TypeInfo(schema), options = {\n maxErrors: undefined\n}) {\n documentAST || devAssert(0, 'Must provide document.'); // If the schema used for validation is invalid, throw an error.\n\n assertValidSchema(schema);\n const abortObj = Object.freeze({});\n const errors = [];\n const context = new ValidationContext(schema, documentAST, typeInfo, error => {\n if (options.maxErrors != null && errors.length >= options.maxErrors) {\n errors.push(new GraphQLError('Too many validation errors, error limit reached. Validation aborted.'));\n throw abortObj;\n }\n\n errors.push(error);\n }); // This uses a specialized visitor which runs multiple visitors in parallel,\n // while maintaining the visitor skip and break API.\n\n const visitor = visitInParallel(rules.map(rule => rule(context))); // Visit the whole document with each instance of all provided rules.\n\n try {\n visit(documentAST, visitWithTypeInfo(typeInfo, visitor));\n } catch (e) {\n if (e !== abortObj) {\n throw e;\n }\n }\n\n return errors;\n}\n/**\n * @internal\n */\n\nexport function validateSDL(documentAST, schemaToExtend, rules = specifiedSDLRules) {\n const errors = [];\n const context = new SDLValidationContext(documentAST, schemaToExtend, error => {\n errors.push(error);\n });\n const visitors = rules.map(rule => rule(context));\n visit(documentAST, visitInParallel(visitors));\n return errors;\n}\n/**\n * Utility function which asserts a SDL document is valid by throwing an error\n * if it is invalid.\n *\n * @internal\n */\n\nexport function assertValidSDL(documentAST) {\n const errors = validateSDL(documentAST);\n\n if (errors.length !== 0) {\n throw new Error(errors.map(error => error.message).join('\\n\\n'));\n }\n}\n/**\n * Utility function which asserts a SDL document is valid by throwing an error\n * if it is invalid.\n *\n * @internal\n */\n\nexport function assertValidSDLExtension(documentAST, schema) {\n const errors = validateSDL(documentAST, schema);\n\n if (errors.length !== 0) {\n throw new Error(errors.map(error => error.message).join('\\n\\n'));\n }\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport keyMap from \"../jsutils/keyMap.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { isLeafType, isInputObjectType, isListType, isNonNullType } from \"../type/definition.mjs\";\n/**\n * Produces a JavaScript value given a GraphQL Value AST.\n *\n * A GraphQL type must be provided, which will be used to interpret different\n * GraphQL Value literals.\n *\n * Returns `undefined` when the value could not be validly coerced according to\n * the provided type.\n *\n * | GraphQL Value | JSON Value |\n * | -------------------- | ------------- |\n * | Input Object | Object |\n * | List | Array |\n * | Boolean | Boolean |\n * | String | String |\n * | Int / Float | Number |\n * | Enum Value | Mixed |\n * | NullValue | null |\n *\n */\n\nexport function valueFromAST(valueNode, type, variables) {\n if (!valueNode) {\n // When there is no node, then there is also no value.\n // Importantly, this is different from returning the value null.\n return;\n }\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n\n if (variables == null || variables[variableName] === undefined) {\n // No valid return value.\n return;\n }\n\n const variableValue = variables[variableName];\n\n if (variableValue === null && isNonNullType(type)) {\n return; // Invalid: intentionally return no value.\n } // Note: This does no further checking that this variable is correct.\n // This assumes that this query has been validated and the variable\n // usage here is of the correct type.\n\n\n return variableValue;\n }\n\n if (isNonNullType(type)) {\n if (valueNode.kind === Kind.NULL) {\n return; // Invalid: intentionally return no value.\n }\n\n return valueFromAST(valueNode, type.ofType, variables);\n }\n\n if (valueNode.kind === Kind.NULL) {\n // This is explicitly returning the value null.\n return null;\n }\n\n if (isListType(type)) {\n const itemType = type.ofType;\n\n if (valueNode.kind === Kind.LIST) {\n const coercedValues = [];\n\n for (const itemNode of valueNode.values) {\n if (isMissingVariable(itemNode, variables)) {\n // If an array contains a missing variable, it is either coerced to\n // null or if the item type is non-null, it considered invalid.\n if (isNonNullType(itemType)) {\n return; // Invalid: intentionally return no value.\n }\n\n coercedValues.push(null);\n } else {\n const itemValue = valueFromAST(itemNode, itemType, variables);\n\n if (itemValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n\n coercedValues.push(itemValue);\n }\n }\n\n return coercedValues;\n }\n\n const coercedValue = valueFromAST(valueNode, itemType, variables);\n\n if (coercedValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n\n return [coercedValue];\n }\n\n if (isInputObjectType(type)) {\n if (valueNode.kind !== Kind.OBJECT) {\n return; // Invalid: intentionally return no value.\n }\n\n const coercedObj = Object.create(null);\n const fieldNodes = keyMap(valueNode.fields, field => field.name.value);\n\n for (const field of objectValues(type.getFields())) {\n const fieldNode = fieldNodes[field.name];\n\n if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {\n if (field.defaultValue !== undefined) {\n coercedObj[field.name] = field.defaultValue;\n } else if (isNonNullType(field.type)) {\n return; // Invalid: intentionally return no value.\n }\n\n continue;\n }\n\n const fieldValue = valueFromAST(fieldNode.value, field.type, variables);\n\n if (fieldValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n\n coercedObj[field.name] = fieldValue;\n }\n\n return coercedObj;\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isLeafType(type)) {\n // Scalars and Enums fulfill parsing a literal value via parseLiteral().\n // Invalid values represent a failure to parse correctly, in which case\n // no value is returned.\n let result;\n\n try {\n result = type.parseLiteral(valueNode, variables);\n } catch (_error) {\n return; // Invalid: intentionally return no value.\n }\n\n if (result === undefined) {\n return; // Invalid: intentionally return no value.\n }\n\n return result;\n } // istanbul ignore next (Not reachable. All possible input types have been considered)\n\n\n false || invariant(0, 'Unexpected input type: ' + inspect(type));\n} // Returns true if the provided valueNode is a variable which is not defined\n// in the set of variables.\n\nfunction isMissingVariable(valueNode, variables) {\n return valueNode.kind === Kind.VARIABLE && (variables == null || variables[valueNode.name.value] === undefined);\n}\n","import keyMap from \"../jsutils/keyMap.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport printPathArray from \"../jsutils/printPathArray.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { print } from \"../language/printer.mjs\";\nimport { isInputType, isNonNullType } from \"../type/definition.mjs\";\nimport { typeFromAST } from \"../utilities/typeFromAST.mjs\";\nimport { valueFromAST } from \"../utilities/valueFromAST.mjs\";\nimport { coerceInputValue } from \"../utilities/coerceInputValue.mjs\";\n\n/**\n * Prepares an object map of variableValues of the correct type based on the\n * provided variable definitions and arbitrary input. If the input cannot be\n * parsed to match the variable definitions, a GraphQLError will be thrown.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getVariableValues(schema, varDefNodes, inputs, options) {\n const errors = [];\n const maxErrors = options?.maxErrors;\n\n try {\n const coerced = coerceVariableValues(schema, varDefNodes, inputs, error => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError('Too many errors processing variables, error limit reached. Execution aborted.');\n }\n\n errors.push(error);\n });\n\n if (errors.length === 0) {\n return {\n coerced\n };\n }\n } catch (error) {\n errors.push(error);\n }\n\n return {\n errors\n };\n}\n\nfunction coerceVariableValues(schema, varDefNodes, inputs, onError) {\n const coercedValues = {};\n\n for (const varDefNode of varDefNodes) {\n const varName = varDefNode.variable.name.value;\n const varType = typeFromAST(schema, varDefNode.type);\n\n if (!isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = print(varDefNode.type);\n onError(new GraphQLError(`Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`, varDefNode.type));\n continue;\n }\n\n if (!hasOwnProperty(inputs, varName)) {\n if (varDefNode.defaultValue) {\n coercedValues[varName] = valueFromAST(varDefNode.defaultValue, varType);\n } else if (isNonNullType(varType)) {\n const varTypeStr = inspect(varType);\n onError(new GraphQLError(`Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`, varDefNode));\n }\n\n continue;\n }\n\n const value = inputs[varName];\n\n if (value === null && isNonNullType(varType)) {\n const varTypeStr = inspect(varType);\n onError(new GraphQLError(`Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`, varDefNode));\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(value, varType, (path, invalidValue, error) => {\n let prefix = `Variable \"$${varName}\" got invalid value ` + inspect(invalidValue);\n\n if (path.length > 0) {\n prefix += ` at \"${varName}${printPathArray(path)}\"`;\n }\n\n onError(new GraphQLError(prefix + '; ' + error.message, varDefNode, undefined, undefined, undefined, error.originalError));\n });\n }\n\n return coercedValues;\n}\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\n\n\nexport function getArgumentValues(def, node, variableValues) {\n const coercedValues = {}; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n const argumentNodes = node.arguments ?? [];\n const argNodeMap = keyMap(argumentNodes, arg => arg.name.value);\n\n for (const argDef of def.args) {\n const name = argDef.name;\n const argType = argDef.type;\n const argumentNode = argNodeMap[name];\n\n if (!argumentNode) {\n if (argDef.defaultValue !== undefined) {\n coercedValues[name] = argDef.defaultValue;\n } else if (isNonNullType(argType)) {\n throw new GraphQLError(`Argument \"${name}\" of required type \"${inspect(argType)}\" ` + 'was not provided.', node);\n }\n\n continue;\n }\n\n const valueNode = argumentNode.value;\n let isNull = valueNode.kind === Kind.NULL;\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n\n if (variableValues == null || !hasOwnProperty(variableValues, variableName)) {\n if (argDef.defaultValue !== undefined) {\n coercedValues[name] = argDef.defaultValue;\n } else if (isNonNullType(argType)) {\n throw new GraphQLError(`Argument \"${name}\" of required type \"${inspect(argType)}\" ` + `was provided the variable \"$${variableName}\" which was not provided a runtime value.`, valueNode);\n }\n\n continue;\n }\n\n isNull = variableValues[variableName] == null;\n }\n\n if (isNull && isNonNullType(argType)) {\n throw new GraphQLError(`Argument \"${name}\" of non-null type \"${inspect(argType)}\" ` + 'must not be null.', valueNode);\n }\n\n const coercedValue = valueFromAST(valueNode, argType, variableValues);\n\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectTypeRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw new GraphQLError(`Argument \"${name}\" has invalid value ${print(valueNode)}.`, valueNode);\n }\n\n coercedValues[name] = coercedValue;\n }\n\n return coercedValues;\n}\n/**\n * Prepares an object map of argument values given a directive definition\n * and a AST node which may contain directives. Optionally also accepts a map\n * of variable values.\n *\n * If the directive does not exist on the node, returns undefined.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\n\nexport function getDirectiveValues(directiveDef, node, variableValues) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const directiveNode = node.directives?.find(directive => directive.name.value === directiveDef.name);\n\n if (directiveNode) {\n return getArgumentValues(directiveDef, directiveNode, variableValues);\n }\n}\n\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport keyValMap from \"../jsutils/keyValMap.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport { parseValue } from \"../language/parser.mjs\";\nimport { GraphQLSchema } from \"../type/schema.mjs\";\nimport { GraphQLDirective } from \"../type/directives.mjs\";\nimport { specifiedScalarTypes } from \"../type/scalars.mjs\";\nimport { introspectionTypes, TypeKind } from \"../type/introspection.mjs\";\nimport { isInputType, isOutputType, GraphQLList, GraphQLNonNull, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType, assertNullableType, assertObjectType, assertInterfaceType } from \"../type/definition.mjs\";\nimport { valueFromAST } from \"./valueFromAST.mjs\";\n/**\n * Build a GraphQLSchema for use by client tools.\n *\n * Given the result of a client running the introspection query, creates and\n * returns a GraphQLSchema instance which can be then used with all graphql-js\n * tools, but cannot be used to execute a query, as introspection does not\n * represent the \"resolver\", \"parse\" or \"serialize\" functions or any other\n * server-internal mechanisms.\n *\n * This function expects a complete introspection result. Don't forget to check\n * the \"errors\" field of a server response before calling this function.\n */\n\nexport function buildClientSchema(introspection, options) {\n isObjectLike(introspection) && isObjectLike(introspection.__schema) || devAssert(0, `Invalid or incomplete introspection result. Ensure that you are passing \"data\" property of introspection response and no \"errors\" was returned alongside: ${inspect(introspection)}.`); // Get the schema from the introspection result.\n\n const schemaIntrospection = introspection.__schema; // Iterate through all types, getting the type definition for each.\n\n const typeMap = keyValMap(schemaIntrospection.types, typeIntrospection => typeIntrospection.name, typeIntrospection => buildType(typeIntrospection)); // Include standard types only if they are used.\n\n for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) {\n if (typeMap[stdType.name]) {\n typeMap[stdType.name] = stdType;\n }\n } // Get the root Query, Mutation, and Subscription types.\n\n\n const queryType = schemaIntrospection.queryType ? getObjectType(schemaIntrospection.queryType) : null;\n const mutationType = schemaIntrospection.mutationType ? getObjectType(schemaIntrospection.mutationType) : null;\n const subscriptionType = schemaIntrospection.subscriptionType ? getObjectType(schemaIntrospection.subscriptionType) : null; // Get the directives supported by Introspection, assuming empty-set if\n // directives were not queried for.\n\n const directives = schemaIntrospection.directives ? schemaIntrospection.directives.map(buildDirective) : []; // Then produce and return a Schema with these types.\n\n return new GraphQLSchema({\n description: schemaIntrospection.description,\n query: queryType,\n mutation: mutationType,\n subscription: subscriptionType,\n types: objectValues(typeMap),\n directives,\n assumeValid: options?.assumeValid\n }); // Given a type reference in introspection, return the GraphQLType instance.\n // preferring cached instances before building new instances.\n\n function getType(typeRef) {\n if (typeRef.kind === TypeKind.LIST) {\n const itemRef = typeRef.ofType;\n\n if (!itemRef) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n\n return new GraphQLList(getType(itemRef));\n }\n\n if (typeRef.kind === TypeKind.NON_NULL) {\n const nullableRef = typeRef.ofType;\n\n if (!nullableRef) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n\n const nullableType = getType(nullableRef);\n return new GraphQLNonNull(assertNullableType(nullableType));\n }\n\n return getNamedType(typeRef);\n }\n\n function getNamedType(typeRef) {\n const typeName = typeRef.name;\n\n if (!typeName) {\n throw new Error(`Unknown type reference: ${inspect(typeRef)}.`);\n }\n\n const type = typeMap[typeName];\n\n if (!type) {\n throw new Error(`Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`);\n }\n\n return type;\n }\n\n function getObjectType(typeRef) {\n return assertObjectType(getNamedType(typeRef));\n }\n\n function getInterfaceType(typeRef) {\n return assertInterfaceType(getNamedType(typeRef));\n } // Given a type's introspection result, construct the correct\n // GraphQLType instance.\n\n\n function buildType(type) {\n if (type != null && type.name != null && type.kind != null) {\n switch (type.kind) {\n case TypeKind.SCALAR:\n return buildScalarDef(type);\n\n case TypeKind.OBJECT:\n return buildObjectDef(type);\n\n case TypeKind.INTERFACE:\n return buildInterfaceDef(type);\n\n case TypeKind.UNION:\n return buildUnionDef(type);\n\n case TypeKind.ENUM:\n return buildEnumDef(type);\n\n case TypeKind.INPUT_OBJECT:\n return buildInputObjectDef(type);\n }\n }\n\n const typeStr = inspect(type);\n throw new Error(`Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${typeStr}.`);\n }\n\n function buildScalarDef(scalarIntrospection) {\n return new GraphQLScalarType({\n name: scalarIntrospection.name,\n description: scalarIntrospection.description,\n specifiedByUrl: scalarIntrospection.specifiedByUrl\n });\n }\n\n function buildImplementationsList(implementingIntrospection) {\n // TODO: Temporary workaround until GraphQL ecosystem will fully support\n // 'interfaces' on interface types.\n if (implementingIntrospection.interfaces === null && implementingIntrospection.kind === TypeKind.INTERFACE) {\n return [];\n }\n\n if (!implementingIntrospection.interfaces) {\n const implementingIntrospectionStr = inspect(implementingIntrospection);\n throw new Error(`Introspection result missing interfaces: ${implementingIntrospectionStr}.`);\n }\n\n return implementingIntrospection.interfaces.map(getInterfaceType);\n }\n\n function buildObjectDef(objectIntrospection) {\n return new GraphQLObjectType({\n name: objectIntrospection.name,\n description: objectIntrospection.description,\n interfaces: () => buildImplementationsList(objectIntrospection),\n fields: () => buildFieldDefMap(objectIntrospection)\n });\n }\n\n function buildInterfaceDef(interfaceIntrospection) {\n return new GraphQLInterfaceType({\n name: interfaceIntrospection.name,\n description: interfaceIntrospection.description,\n interfaces: () => buildImplementationsList(interfaceIntrospection),\n fields: () => buildFieldDefMap(interfaceIntrospection)\n });\n }\n\n function buildUnionDef(unionIntrospection) {\n if (!unionIntrospection.possibleTypes) {\n const unionIntrospectionStr = inspect(unionIntrospection);\n throw new Error(`Introspection result missing possibleTypes: ${unionIntrospectionStr}.`);\n }\n\n return new GraphQLUnionType({\n name: unionIntrospection.name,\n description: unionIntrospection.description,\n types: () => unionIntrospection.possibleTypes.map(getObjectType)\n });\n }\n\n function buildEnumDef(enumIntrospection) {\n if (!enumIntrospection.enumValues) {\n const enumIntrospectionStr = inspect(enumIntrospection);\n throw new Error(`Introspection result missing enumValues: ${enumIntrospectionStr}.`);\n }\n\n return new GraphQLEnumType({\n name: enumIntrospection.name,\n description: enumIntrospection.description,\n values: keyValMap(enumIntrospection.enumValues, valueIntrospection => valueIntrospection.name, valueIntrospection => ({\n description: valueIntrospection.description,\n deprecationReason: valueIntrospection.deprecationReason\n }))\n });\n }\n\n function buildInputObjectDef(inputObjectIntrospection) {\n if (!inputObjectIntrospection.inputFields) {\n const inputObjectIntrospectionStr = inspect(inputObjectIntrospection);\n throw new Error(`Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`);\n }\n\n return new GraphQLInputObjectType({\n name: inputObjectIntrospection.name,\n description: inputObjectIntrospection.description,\n fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields)\n });\n }\n\n function buildFieldDefMap(typeIntrospection) {\n if (!typeIntrospection.fields) {\n throw new Error(`Introspection result missing fields: ${inspect(typeIntrospection)}.`);\n }\n\n return keyValMap(typeIntrospection.fields, fieldIntrospection => fieldIntrospection.name, buildField);\n }\n\n function buildField(fieldIntrospection) {\n const type = getType(fieldIntrospection.type);\n\n if (!isOutputType(type)) {\n const typeStr = inspect(type);\n throw new Error(`Introspection must provide output type for fields, but received: ${typeStr}.`);\n }\n\n if (!fieldIntrospection.args) {\n const fieldIntrospectionStr = inspect(fieldIntrospection);\n throw new Error(`Introspection result missing field args: ${fieldIntrospectionStr}.`);\n }\n\n return {\n description: fieldIntrospection.description,\n deprecationReason: fieldIntrospection.deprecationReason,\n type,\n args: buildInputValueDefMap(fieldIntrospection.args)\n };\n }\n\n function buildInputValueDefMap(inputValueIntrospections) {\n return keyValMap(inputValueIntrospections, inputValue => inputValue.name, buildInputValue);\n }\n\n function buildInputValue(inputValueIntrospection) {\n const type = getType(inputValueIntrospection.type);\n\n if (!isInputType(type)) {\n const typeStr = inspect(type);\n throw new Error(`Introspection must provide input type for arguments, but received: ${typeStr}.`);\n }\n\n const defaultValue = inputValueIntrospection.defaultValue != null ? valueFromAST(parseValue(inputValueIntrospection.defaultValue), type) : undefined;\n return {\n description: inputValueIntrospection.description,\n type,\n defaultValue,\n deprecationReason: inputValueIntrospection.deprecationReason\n };\n }\n\n function buildDirective(directiveIntrospection) {\n if (!directiveIntrospection.args) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(`Introspection result missing directive args: ${directiveIntrospectionStr}.`);\n }\n\n if (!directiveIntrospection.locations) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(`Introspection result missing directive locations: ${directiveIntrospectionStr}.`);\n }\n\n return new GraphQLDirective({\n name: directiveIntrospection.name,\n description: directiveIntrospection.description,\n isRepeatable: directiveIntrospection.isRepeatable,\n locations: directiveIntrospection.locations.slice(),\n args: buildInputValueDefMap(directiveIntrospection.args)\n });\n }\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport keyMap from \"../jsutils/keyMap.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport mapValue from \"../jsutils/mapValue.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { isTypeDefinitionNode, isTypeExtensionNode } from \"../language/predicates.mjs\";\nimport { assertValidSDLExtension } from \"../validation/validate.mjs\";\nimport { getDirectiveValues } from \"../execution/values.mjs\";\nimport { assertSchema, GraphQLSchema } from \"../type/schema.mjs\";\nimport { specifiedScalarTypes, isSpecifiedScalarType } from \"../type/scalars.mjs\";\nimport { introspectionTypes, isIntrospectionType } from \"../type/introspection.mjs\";\nimport { GraphQLDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective } from \"../type/directives.mjs\";\nimport { isScalarType, isObjectType, isInterfaceType, isUnionType, isListType, isNonNullType, isEnumType, isInputObjectType, GraphQLList, GraphQLNonNull, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType } from \"../type/definition.mjs\";\nimport { valueFromAST } from \"./valueFromAST.mjs\";\n\n/**\n * Produces a new schema given an existing schema and a document which may\n * contain GraphQL type extensions and definitions. The original schema will\n * remain unaltered.\n *\n * Because a schema represents a graph of references, a schema cannot be\n * extended without effectively making an entire copy. We do not know until it's\n * too late if subgraphs remain unchanged.\n *\n * This algorithm copies the provided schema, applying extensions while\n * producing the copy. The original schema remains unaltered.\n */\nexport function extendSchema(schema, documentAST, options) {\n assertSchema(schema);\n documentAST != null && documentAST.kind === Kind.DOCUMENT || devAssert(0, 'Must provide valid Document AST.');\n\n if (options?.assumeValid !== true && options?.assumeValidSDL !== true) {\n assertValidSDLExtension(documentAST, schema);\n }\n\n const schemaConfig = schema.toConfig();\n const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options);\n return schemaConfig === extendedConfig ? schema : new GraphQLSchema(extendedConfig);\n}\n/**\n * @internal\n */\n\nexport function extendSchemaImpl(schemaConfig, documentAST, options) {\n // Collect the type definitions and extensions found in the document.\n const typeDefs = [];\n const typeExtensionsMap = Object.create(null); // New directives and types are separate because a directives and types can\n // have the same name. For example, a type named \"skip\".\n\n const directiveDefs = [];\n let schemaDef; // Schema extensions are collected which may add additional operation types.\n\n const schemaExtensions = [];\n\n for (const def of documentAST.definitions) {\n if (def.kind === Kind.SCHEMA_DEFINITION) {\n schemaDef = def;\n } else if (def.kind === Kind.SCHEMA_EXTENSION) {\n schemaExtensions.push(def);\n } else if (isTypeDefinitionNode(def)) {\n typeDefs.push(def);\n } else if (isTypeExtensionNode(def)) {\n const extendedTypeName = def.name.value;\n const existingTypeExtensions = typeExtensionsMap[extendedTypeName];\n typeExtensionsMap[extendedTypeName] = existingTypeExtensions ? existingTypeExtensions.concat([def]) : [def];\n } else if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n directiveDefs.push(def);\n }\n } // If this document contains no new types, extensions, or directives then\n // return the same unmodified GraphQLSchema instance.\n\n\n if (Object.keys(typeExtensionsMap).length === 0 && typeDefs.length === 0 && directiveDefs.length === 0 && schemaExtensions.length === 0 && schemaDef == null) {\n return schemaConfig;\n }\n\n const typeMap = Object.create(null);\n\n for (const existingType of schemaConfig.types) {\n typeMap[existingType.name] = extendNamedType(existingType);\n }\n\n for (const typeNode of typeDefs) {\n const name = typeNode.name.value;\n typeMap[name] = stdTypeMap[name] ?? buildType(typeNode);\n }\n\n const operationTypes = {\n // Get the extended root operation types.\n query: schemaConfig.query && replaceNamedType(schemaConfig.query),\n mutation: schemaConfig.mutation && replaceNamedType(schemaConfig.mutation),\n subscription: schemaConfig.subscription && replaceNamedType(schemaConfig.subscription),\n // Then, incorporate schema definition and all schema extensions.\n ...(schemaDef && getOperationTypes([schemaDef])),\n ...getOperationTypes(schemaExtensions)\n }; // Then produce and return a Schema config with these types.\n\n return {\n description: schemaDef?.description?.value,\n ...operationTypes,\n types: objectValues(typeMap),\n directives: [...schemaConfig.directives.map(replaceDirective), ...directiveDefs.map(buildDirective)],\n extensions: undefined,\n astNode: schemaDef ?? schemaConfig.astNode,\n extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExtensions),\n assumeValid: options?.assumeValid ?? false\n }; // Below are functions used for producing this schema that have closed over\n // this scope and have access to the schema, cache, and newly defined types.\n\n function replaceType(type) {\n if (isListType(type)) {\n // $FlowFixMe[incompatible-return]\n return new GraphQLList(replaceType(type.ofType));\n }\n\n if (isNonNullType(type)) {\n // $FlowFixMe[incompatible-return]\n return new GraphQLNonNull(replaceType(type.ofType));\n }\n\n return replaceNamedType(type);\n }\n\n function replaceNamedType(type) {\n // Note: While this could make early assertions to get the correctly\n // typed values, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n return typeMap[type.name];\n }\n\n function replaceDirective(directive) {\n const config = directive.toConfig();\n return new GraphQLDirective({ ...config,\n args: mapValue(config.args, extendArg)\n });\n }\n\n function extendNamedType(type) {\n if (isIntrospectionType(type) || isSpecifiedScalarType(type)) {\n // Builtin types are not extended.\n return type;\n }\n\n if (isScalarType(type)) {\n return extendScalarType(type);\n }\n\n if (isObjectType(type)) {\n return extendObjectType(type);\n }\n\n if (isInterfaceType(type)) {\n return extendInterfaceType(type);\n }\n\n if (isUnionType(type)) {\n return extendUnionType(type);\n }\n\n if (isEnumType(type)) {\n return extendEnumType(type);\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isInputObjectType(type)) {\n return extendInputObjectType(type);\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, 'Unexpected type: ' + inspect(type));\n }\n\n function extendInputObjectType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[config.name] ?? [];\n return new GraphQLInputObjectType({ ...config,\n fields: () => ({ ...mapValue(config.fields, field => ({ ...field,\n type: replaceType(field.type)\n })),\n ...buildInputFieldMap(extensions)\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendEnumType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[type.name] ?? [];\n return new GraphQLEnumType({ ...config,\n values: { ...config.values,\n ...buildEnumValueMap(extensions)\n },\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendScalarType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[config.name] ?? [];\n let specifiedByUrl = config.specifiedByUrl;\n\n for (const extensionNode of extensions) {\n specifiedByUrl = getSpecifiedByUrl(extensionNode) ?? specifiedByUrl;\n }\n\n return new GraphQLScalarType({ ...config,\n specifiedByUrl,\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendObjectType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[config.name] ?? [];\n return new GraphQLObjectType({ ...config,\n interfaces: () => [...type.getInterfaces().map(replaceNamedType), ...buildInterfaces(extensions)],\n fields: () => ({ ...mapValue(config.fields, extendField),\n ...buildFieldMap(extensions)\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendInterfaceType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[config.name] ?? [];\n return new GraphQLInterfaceType({ ...config,\n interfaces: () => [...type.getInterfaces().map(replaceNamedType), ...buildInterfaces(extensions)],\n fields: () => ({ ...mapValue(config.fields, extendField),\n ...buildFieldMap(extensions)\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendUnionType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[config.name] ?? [];\n return new GraphQLUnionType({ ...config,\n types: () => [...type.getTypes().map(replaceNamedType), ...buildUnionTypes(extensions)],\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendField(field) {\n return { ...field,\n type: replaceType(field.type),\n // $FlowFixMe[incompatible-call]\n args: mapValue(field.args, extendArg)\n };\n }\n\n function extendArg(arg) {\n return { ...arg,\n type: replaceType(arg.type)\n };\n }\n\n function getOperationTypes(nodes) {\n const opTypes = {};\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const operationTypesNodes = node.operationTypes ?? [];\n\n for (const operationType of operationTypesNodes) {\n opTypes[operationType.operation] = getNamedType(operationType.type);\n }\n } // Note: While this could make early assertions to get the correctly\n // typed values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n\n\n return opTypes;\n }\n\n function getNamedType(node) {\n const name = node.name.value;\n const type = stdTypeMap[name] ?? typeMap[name];\n\n if (type === undefined) {\n throw new Error(`Unknown type: \"${name}\".`);\n }\n\n return type;\n }\n\n function getWrappedType(node) {\n if (node.kind === Kind.LIST_TYPE) {\n return new GraphQLList(getWrappedType(node.type));\n }\n\n if (node.kind === Kind.NON_NULL_TYPE) {\n // $FlowFixMe[incompatible-call]\n return new GraphQLNonNull(getWrappedType(node.type));\n }\n\n return getNamedType(node);\n }\n\n function buildDirective(node) {\n const locations = node.locations.map(({\n value\n }) => value);\n return new GraphQLDirective({\n name: node.name.value,\n description: node.description?.value,\n locations,\n isRepeatable: node.repeatable,\n args: buildArgumentMap(node.arguments),\n astNode: node\n });\n }\n\n function buildFieldMap(nodes) {\n const fieldConfigMap = Object.create(null);\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const nodeFields = node.fields ?? [];\n\n for (const field of nodeFields) {\n fieldConfigMap[field.name.value] = {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n type: getWrappedType(field.type),\n description: field.description?.value,\n args: buildArgumentMap(field.arguments),\n deprecationReason: getDeprecationReason(field),\n astNode: field\n };\n }\n }\n\n return fieldConfigMap;\n }\n\n function buildArgumentMap(args) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argsNodes = args ?? [];\n const argConfigMap = Object.create(null);\n\n for (const arg of argsNodes) {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n const type = getWrappedType(arg.type);\n argConfigMap[arg.name.value] = {\n type,\n description: arg.description?.value,\n defaultValue: valueFromAST(arg.defaultValue, type),\n deprecationReason: getDeprecationReason(arg),\n astNode: arg\n };\n }\n\n return argConfigMap;\n }\n\n function buildInputFieldMap(nodes) {\n const inputFieldMap = Object.create(null);\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const fieldsNodes = node.fields ?? [];\n\n for (const field of fieldsNodes) {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n const type = getWrappedType(field.type);\n inputFieldMap[field.name.value] = {\n type,\n description: field.description?.value,\n defaultValue: valueFromAST(field.defaultValue, type),\n deprecationReason: getDeprecationReason(field),\n astNode: field\n };\n }\n }\n\n return inputFieldMap;\n }\n\n function buildEnumValueMap(nodes) {\n const enumValueMap = Object.create(null);\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const valuesNodes = node.values ?? [];\n\n for (const value of valuesNodes) {\n enumValueMap[value.name.value] = {\n description: value.description?.value,\n deprecationReason: getDeprecationReason(value),\n astNode: value\n };\n }\n }\n\n return enumValueMap;\n }\n\n function buildInterfaces(nodes) {\n const interfaces = [];\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const interfacesNodes = node.interfaces ?? [];\n\n for (const type of interfacesNodes) {\n // Note: While this could make assertions to get the correctly typed\n // values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable\n // results.\n interfaces.push(getNamedType(type));\n }\n }\n\n return interfaces;\n }\n\n function buildUnionTypes(nodes) {\n const types = [];\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const typeNodes = node.types ?? [];\n\n for (const type of typeNodes) {\n // Note: While this could make assertions to get the correctly typed\n // values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable\n // results.\n types.push(getNamedType(type));\n }\n }\n\n return types;\n }\n\n function buildType(astNode) {\n const name = astNode.name.value;\n const extensionNodes = typeExtensionsMap[name] ?? [];\n\n switch (astNode.kind) {\n case Kind.OBJECT_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n const allNodes = [astNode, ...extensionASTNodes];\n return new GraphQLObjectType({\n name,\n description: astNode.description?.value,\n interfaces: () => buildInterfaces(allNodes),\n fields: () => buildFieldMap(allNodes),\n astNode,\n extensionASTNodes\n });\n }\n\n case Kind.INTERFACE_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n const allNodes = [astNode, ...extensionASTNodes];\n return new GraphQLInterfaceType({\n name,\n description: astNode.description?.value,\n interfaces: () => buildInterfaces(allNodes),\n fields: () => buildFieldMap(allNodes),\n astNode,\n extensionASTNodes\n });\n }\n\n case Kind.ENUM_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n const allNodes = [astNode, ...extensionASTNodes];\n return new GraphQLEnumType({\n name,\n description: astNode.description?.value,\n values: buildEnumValueMap(allNodes),\n astNode,\n extensionASTNodes\n });\n }\n\n case Kind.UNION_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n const allNodes = [astNode, ...extensionASTNodes];\n return new GraphQLUnionType({\n name,\n description: astNode.description?.value,\n types: () => buildUnionTypes(allNodes),\n astNode,\n extensionASTNodes\n });\n }\n\n case Kind.SCALAR_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n return new GraphQLScalarType({\n name,\n description: astNode.description?.value,\n specifiedByUrl: getSpecifiedByUrl(astNode),\n astNode,\n extensionASTNodes\n });\n }\n\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n const allNodes = [astNode, ...extensionASTNodes];\n return new GraphQLInputObjectType({\n name,\n description: astNode.description?.value,\n fields: () => buildInputFieldMap(allNodes),\n astNode,\n extensionASTNodes\n });\n }\n } // istanbul ignore next (Not reachable. All possible type definition nodes have been considered)\n\n\n false || invariant(0, 'Unexpected type definition node: ' + inspect(astNode));\n }\n}\nconst stdTypeMap = keyMap(specifiedScalarTypes.concat(introspectionTypes), type => type.name);\n/**\n * Given a field or enum value node, returns the string value for the\n * deprecation reason.\n */\n\nfunction getDeprecationReason(node) {\n const deprecated = getDirectiveValues(GraphQLDeprecatedDirective, node);\n return deprecated?.reason;\n}\n/**\n * Given a scalar node, returns the string value for the specifiedByUrl.\n */\n\n\nfunction getSpecifiedByUrl(node) {\n const specifiedBy = getDirectiveValues(GraphQLSpecifiedByDirective, node);\n return specifiedBy?.url;\n}\n","import devAssert from \"../jsutils/devAssert.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { parse } from \"../language/parser.mjs\";\nimport { assertValidSDL } from \"../validation/validate.mjs\";\nimport { GraphQLSchema } from \"../type/schema.mjs\";\nimport { specifiedDirectives } from \"../type/directives.mjs\";\nimport { extendSchemaImpl } from \"./extendSchema.mjs\";\n\n/**\n * This takes the ast of a schema document produced by the parse function in\n * src/language/parser.js.\n *\n * If no schema definition is provided, then it will look for types named Query\n * and Mutation.\n *\n * Given that AST it constructs a GraphQLSchema. The resulting schema\n * has no resolve methods, so execution will use default resolvers.\n */\nexport function buildASTSchema(documentAST, options) {\n documentAST != null && documentAST.kind === Kind.DOCUMENT || devAssert(0, 'Must provide valid Document AST.');\n\n if (options?.assumeValid !== true && options?.assumeValidSDL !== true) {\n assertValidSDL(documentAST);\n }\n\n const emptySchemaConfig = {\n description: undefined,\n types: [],\n directives: [],\n extensions: undefined,\n extensionASTNodes: [],\n assumeValid: false\n };\n const config = extendSchemaImpl(emptySchemaConfig, documentAST, options);\n\n if (config.astNode == null) {\n for (const type of config.types) {\n switch (type.name) {\n // Note: While this could make early assertions to get the correctly\n // typed values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n case 'Query':\n config.query = type;\n break;\n\n case 'Mutation':\n config.mutation = type;\n break;\n\n case 'Subscription':\n config.subscription = type;\n break;\n }\n }\n }\n\n const {\n directives\n } = config; // If specified directives were not explicitly declared, add them.\n\n for (const stdDirective of specifiedDirectives) {\n if (directives.every(directive => directive.name !== stdDirective.name)) {\n directives.push(stdDirective);\n }\n }\n\n return new GraphQLSchema(config);\n}\n/**\n * A helper function to build a GraphQLSchema directly from a source\n * document.\n */\n\nexport function buildSchema(source, options) {\n const document = parse(source, {\n noLocation: options?.noLocation,\n experimentalFragmentVariables: options?.experimentalFragmentVariables\n });\n return buildASTSchema(document, {\n assumeValidSDL: options?.assumeValidSDL,\n assumeValid: options?.assumeValid\n });\n}\n",null,null,null,null,null,"import { GraphQLError } from \"../error/GraphQLError.mjs\";\n\n/**\n * Extracts the root type of the operation from the schema.\n */\nexport function getOperationRootType(schema, operation) {\n if (operation.operation === 'query') {\n const queryType = schema.getQueryType();\n\n if (!queryType) {\n throw new GraphQLError('Schema does not define the required query root type.', operation);\n }\n\n return queryType;\n }\n\n if (operation.operation === 'mutation') {\n const mutationType = schema.getMutationType();\n\n if (!mutationType) {\n throw new GraphQLError('Schema is not configured for mutations.', operation);\n }\n\n return mutationType;\n }\n\n if (operation.operation === 'subscription') {\n const subscriptionType = schema.getSubscriptionType();\n\n if (!subscriptionType) {\n throw new GraphQLError('Schema is not configured for subscriptions.', operation);\n }\n\n return subscriptionType;\n }\n\n throw new GraphQLError('Can only have query, mutation and subscription operations.', operation);\n}\n",null,"/**\n * Provided a collection of ASTs, presumably each from different files,\n * concatenate the ASTs together into batched AST, useful for validating many\n * GraphQL source files which together represent one conceptual application.\n */\nexport function concatAST(documents) {\n let definitions = [];\n\n for (const doc of documents) {\n definitions = definitions.concat(doc.definitions);\n }\n\n return {\n kind: 'Document',\n definitions\n };\n}\n"],"names":["isObjectLike","value","getLocation","source","position","lineRegexp","match","line","column","exec","body","index","length","printLocation","location","printSourceLocation","start","sourceLocation","firstLineColumnOffset","locationOffset","whitespace","lineIndex","lineOffset","lineNum","columnOffset","columnNum","locationStr","name","lines","split","locationLine","subLineIndex","Math","floor","subLineColumnNum","subLines","i","push","slice","printPrefixedLines","map","subLine","existingLines","filter","_","undefined","padLen","max","prefix","leftPad","str","join","len","Array","GraphQLError","Error","[object Object]","message","nodes","positions","path","originalError","extensions","super","_nodes","isArray","_source","loc","_locations","_positions","reduce","list","node","pos","_extensions","originalExtensions","Object","defineProperties","this","enumerable","writable","locations","stack","defineProperty","configurable","captureStackTrace","error","output","printError","get","Symbol","toStringTag","syntaxError","description","Kind","freeze","NAME","DOCUMENT","OPERATION_DEFINITION","VARIABLE_DEFINITION","SELECTION_SET","FIELD","ARGUMENT","FRAGMENT_SPREAD","INLINE_FRAGMENT","FRAGMENT_DEFINITION","VARIABLE","INT","FLOAT","STRING","BOOLEAN","NULL","ENUM","LIST","OBJECT","OBJECT_FIELD","DIRECTIVE","NAMED_TYPE","LIST_TYPE","NON_NULL_TYPE","SCHEMA_DEFINITION","OPERATION_TYPE_DEFINITION","SCALAR_TYPE_DEFINITION","OBJECT_TYPE_DEFINITION","FIELD_DEFINITION","INPUT_VALUE_DEFINITION","INTERFACE_TYPE_DEFINITION","UNION_TYPE_DEFINITION","ENUM_TYPE_DEFINITION","ENUM_VALUE_DEFINITION","INPUT_OBJECT_TYPE_DEFINITION","DIRECTIVE_DEFINITION","SCHEMA_EXTENSION","SCALAR_TYPE_EXTENSION","OBJECT_TYPE_EXTENSION","INTERFACE_TYPE_EXTENSION","UNION_TYPE_EXTENSION","ENUM_TYPE_EXTENSION","INPUT_OBJECT_TYPE_EXTENSION","Location","startToken","endToken","end","for","toJSON","Token","kind","prev","next","isNode","maybeNode","TokenKind","SOF","EOF","BANG","DOLLAR","AMP","PAREN_L","PAREN_R","SPREAD","COLON","EQUALS","AT","BRACKET_L","BRACKET_R","BRACE_L","PIPE","BRACE_R","BLOCK_STRING","COMMENT","inspect","formatValue","seenValues","JSON","stringify","previouslySeenValues","indexOf","jsonValue","array","min","remaining","items","formatArray","object","keys","tag","prototype","toString","call","replace","constructor","getObjectTag","key","formatObject","formatObjectValue","String","devAssert","condition","Boolean","Source","DirectiveLocation","QUERY","MUTATION","SUBSCRIPTION","SCHEMA","SCALAR","ARGUMENT_DEFINITION","INTERFACE","UNION","ENUM_VALUE","INPUT_OBJECT","INPUT_FIELD_DEFINITION","dedentBlockStringValue","rawString","commonIndent","isFirstLine","isEmptyLine","indent","charCodeAt","getBlockStringIndentation","startLine","isBlank","endLine","Lexer","startOfFileToken","lastToken","token","lineStart","lookahead","readToken","printCharCode","code","isNaN","fromCharCode","toUpperCase","lexer","bodyLength","col","readComment","readBlockString","readString","readNumber","readName","unexpectedCharacterMessage","firstCode","isFloat","readDigits","isNameStart","chunkStart","charCode","a","b","c","d","char2hex","rawValue","parse","options","Parser","parseDocument","sourceObj","instanceOf","isSource","_lexer","_options","expectToken","definitions","many","parseDefinition","peek","parseOperationDefinition","parseFragmentDefinition","parseTypeSystemDefinition","parseTypeSystemExtension","peekDescription","unexpected","operation","variableDefinitions","directives","selectionSet","parseSelectionSet","parseOperationType","parseName","parseVariableDefinitions","parseDirectives","operationToken","optionalMany","parseVariableDefinition","variable","parseVariable","type","parseTypeReference","defaultValue","expectOptionalToken","parseValueLiteral","selections","parseSelection","parseFragment","parseField","nameOrAlias","alias","arguments","parseArguments","isConst","item","parseConstArgument","parseArgument","hasTypeCondition","expectOptionalKeyword","parseFragmentName","typeCondition","parseNamedType","expectKeyword","experimentalFragmentVariables","parseList","parseObject","advance","parseStringLiteral","block","values","any","fields","parseObjectField","parseDirective","keywordToken","parseSchemaDefinition","parseScalarTypeDefinition","parseObjectTypeDefinition","parseInterfaceTypeDefinition","parseUnionTypeDefinition","parseEnumTypeDefinition","parseInputObjectTypeDefinition","parseDirectiveDefinition","parseDescription","operationTypes","parseOperationTypeDefinition","interfaces","parseImplementsInterfaces","parseFieldsDefinition","delimitedMany","parseFieldDefinition","args","parseArgumentDefs","parseInputValueDef","types","parseUnionMemberTypes","parseEnumValuesDefinition","parseEnumValueDefinition","parseInputFieldsDefinition","parseSchemaExtension","parseScalarTypeExtension","parseObjectTypeExtension","parseInterfaceTypeExtension","parseUnionTypeExtension","parseEnumTypeExtension","parseInputObjectTypeExtension","repeatable","parseDirectiveLocations","parseDirectiveLocation","noLocation","getTokenKindDesc","getTokenDesc","atToken","openKind","parseFn","closeKind","delimiterKind","isPunctuatorTokenKind","QueryDocumentKeys","Name","Document","OperationDefinition","VariableDefinition","Variable","SelectionSet","Field","Argument","FragmentSpread","InlineFragment","FragmentDefinition","IntValue","FloatValue","StringValue","BooleanValue","NullValue","EnumValue","ListValue","ObjectValue","ObjectField","Directive","NamedType","ListType","NonNullType","SchemaDefinition","OperationTypeDefinition","ScalarTypeDefinition","ObjectTypeDefinition","FieldDefinition","InputValueDefinition","InterfaceTypeDefinition","UnionTypeDefinition","EnumTypeDefinition","EnumValueDefinition","InputObjectTypeDefinition","DirectiveDefinition","SchemaExtension","ScalarTypeExtension","ObjectTypeExtension","InterfaceTypeExtension","UnionTypeExtension","EnumTypeExtension","InputObjectTypeExtension","BREAK","visit","root","visitor","visitorKeys","parent","inArray","edits","ancestors","newRoot","isLeaving","isEdited","pop","clone","k","editOffset","ii","editKey","editValue","splice","result","visitFn","getVisitFn","visitInParallel","visitors","skipping","fn","apply","kindVisitor","kindSpecificVisitor","leave","enter","specificVisitor","specificKindVisitor","objectValues","obj","NAME_RX","objectEntries","entries","keyMap","keyFn","create","mapValue","toObjMap","getPrototypeOf","keyValMap","valFn","didYouMean","firstArg","secondArg","subMessage","suggestionsArg","suggestions","x","selected","lastItem","identityFunc","suggestionList","input","optionsByDistance","lexicalDistance","LexicalDistance","threshold","option","distance","measure","sort","distanceDiff","localeCompare","_input","_inputLowerCase","toLowerCase","_inputArray","stringToArray","_rows","fill","optionLowerCase","tmp","aLength","bLength","rows","j","upRow","currentRow","smallestCell","cost","currentCell","doubleDiagonalCell","strLength","print","ast","printDocASTReducer","op","varDefs","wrap","argsLine","isBlockString","indentation","preferMultipleLines","isSingleLine","hasLeadingSpace","hasTrailingQuote","hasTrailingSlash","printAsMultipleLines","printBlockString","addDescription","hasMultilineItems","cb","maybeArray","separator","maybeString","isMultiline","some","invariant","valueFromASTUntyped","valueNode","variables","parseInt","parseFloat","field","isType","isScalarType","isObjectType","isInterfaceType","isUnionType","isEnumType","isInputObjectType","isListType","isNonNullType","GraphQLScalarType","GraphQLObjectType","GraphQLInterfaceType","GraphQLUnionType","GraphQLEnumType","GraphQLInputObjectType","GraphQLList","GraphQLNonNull","isInputType","isWrappingType","ofType","isOutputType","isLeafType","isCompositeType","isAbstractType","isNullableType","getNullableType","isNamedType","getNamedType","unwrappedType","resolveThunk","thunk","undefineIfEmpty","arr","config","parseValue","specifiedByUrl","serialize","parseLiteral","astNode","extensionASTNodes","isTypeOf","_fields","defineFieldMap","bind","_interfaces","defineInterfaces","getInterfaces","fieldsToFieldsConfig","getFields","fieldMap","isPlainObj","fieldConfig","fieldName","resolve","argsConfig","argName","argConfig","deprecationReason","subscribe","argsToArgsConfig","arg","isRequiredArgument","resolveType","_types","defineTypes","getTypes","typeName","valueMap","_values","valueName","valueConfig","_valueLookup","Map","enumValue","_nameLookup","outputValue","inputValue","valueStr","didYouMeanEnumValue","getValue","_variables","getValues","enumType","unknownValueStr","defineInputFieldMap","isRequiredInputField","isEqualType","typeA","typeB","isTypeSubTypeOf","schema","maybeSubType","superType","isSubType","doTypesOverlap","getPossibleTypes","MAX_INT","MIN_INT","GraphQLInt","coercedValue","serializeObject","num","Number","isInteger","GraphQLFloat","isFinite","valueOf","valueOfResult","GraphQLString","GraphQLBoolean","GraphQLID","specifiedScalarTypes","astFromValue","astValue","itemType","iterator","isCollection","valuesNodes","from","itemNode","fieldNodes","fieldValue","serialized","stringNum","integerStringRegExp","test","TypeError","__Schema","__Type","getTypeMap","queryType","getQueryType","mutationType","getMutationType","subscriptionType","getSubscriptionType","__Directive","getDirectives","directive","isRepeatable","__DirectiveLocation","__InputValue","__TypeKind","TypeKind","NON_NULL","__Field","includeDeprecated","possibleTypes","_args","_context","enumValues","__EnumValue","inputFields","isDeprecated","valueAST","SchemaMetaFieldDef","TypeMetaFieldDef","getType","TypeNameMetaFieldDef","parentType","introspectionTypes","isIntrospectionType","isDirective","GraphQLDirective","GraphQLIncludeDirective","if","GraphQLSkipDirective","GraphQLDeprecatedDirective","reason","GraphQLSpecifiedByDirective","url","specifiedDirectives","assertSchema","GraphQLSchema","isSchema","__validationErrors","assumeValid","_queryType","query","_mutationType","mutation","_subscriptionType","subscription","_directives","allReferencedTypes","Set","delete","collectReferencedTypes","_typeMap","_subTypeMap","_implementationsMap","namedType","iface","implementations","objects","abstractType","getImplementations","interfaceType","find","typeSet","has","add","memberType","validateSchema","context","SchemaValidationContext","reportError","getOperationTypeNode","validateRootTypes","validateName","getDeprecatedDirectiveNode","validateDirectives","validateInputObjectCircularRefs","visitedTypes","fieldPath","fieldPathIndexByTypeName","detectCycleRecursive","inputObj","fieldType","cycleIndex","cyclePath","pathStr","fieldObj","createInputObjectCircularRefsValidator","typeMap","validateFields","validateInterfaces","validateUnionMembers","validateEnumValues","validateInputFields","validateTypes","errors","getErrors","_errors","addError","operationNodes","getAllSubNodes","rawOriginalError","locatedError","getAllNodes","ifaceTypeNames","getAllImplementsInterfaceNodes","validateTypeImplementsAncestors","validateTypeImplementsInterface","typeFieldMap","ifaceField","typeField","ifaceArg","typeArg","ifaceInterfaces","transitive","union","memberTypes","includedTypeNames","getUnionMemberTypeNodes","concat","getter","subNodes","typeNode","ifaceNode","unionNode","definitionNode","typeFromAST","innerType","TypeInfo","getFieldDefFn","initialType","_schema","_typeStack","_parentTypeStack","_inputTypeStack","_fieldDefStack","_defaultValueStack","_directive","_argument","_enumValue","_getFieldDef","getFieldDef","getParentType","fieldDef","getDirective","typeConditionAST","outputType","inputType","argDef","argType","fieldOrDirective","listType","getInputType","objectType","inputFieldType","inputField","fieldNode","visitWithTypeInfo","typeInfo","isExecutableDefinitionNode","isTypeDefinitionNode","isTypeExtensionNode","KnownTypeNamesRule","getSchema","existingTypesMap","definedTypes","def","getDocument","typeNames","_1","_2","isSDL","isTypeSystemDefinitionNode","isTypeSystemExtensionNode","standardTypeNames","isStandardTypeName","suggestedTypes","NoUnusedFragmentsRule","operationDefs","fragmentDefs","fragmentNameUsed","fragment","getRecursivelyReferencedFragments","fragmentDef","fragName","KnownDirectivesRule","locationsMap","definedDirectives","astDefinitions","_key","_parent","_path","candidateLocation","appliedTo","getDirectiveLocationForOperation","getDirectiveLocationForASTPath","UniqueDirectivesPerLocationRule","uniqueDirectiveMap","schemaDirectives","typeDirectivesMap","seenDirectives","directiveName","KnownArgumentNamesOnDirectivesRule","directiveArgs","argsNodes","directiveNode","knownArgs","argNode","UniqueArgumentNamesRule","knownArgNames","isValidValueNode","locationType","typeStr","ProvidedRequiredArgumentsOnDirectivesRule","requiredArgsMap","argNodes","isRequiredArgumentNode","requiredArgs","argNodeMap","argTypeStr","allowedVariableUsage","varType","varDefaultValue","locationDefaultValue","hasLocationDefaultValue","reasonMessage","responseName","subReason","collectConflictsBetweenFieldsAndFragment","conflicts","cachedFieldsAndFragmentNames","comparedFragmentPairs","areMutuallyExclusive","fragmentName","getFragment","fieldMap2","fragmentNames2","getReferencedFieldsAndFragmentNames","collectConflictsBetween","collectConflictsBetweenFragments","fragmentName1","fragmentName2","fragment1","fragment2","fieldMap1","fragmentNames1","parentFieldsAreMutuallyExclusive","fields2","fields1","conflict","findConflict","field1","field2","parentType1","node1","def1","parentType2","node2","def2","name1","name2","arguments1","arguments2","every","argument1","argument2","argument","value1","value2","sameArguments","type1","type2","doTypesConflict","selectionSet1","selectionSet2","allFields","subfieldConflicts","getFieldsAndFragmentNames","findConflictsBetweenSubSelectionSets","cached","nodeAndDefs","fragmentNames","_collectFieldsAndFragmentNames","set","fragmentType","selection","inlineFragmentType","PairSet","_data","first","_pairSetAdd","UniqueInputFieldNamesRule","knownNameStack","knownNames","hasField","defKindToExtKind","specifiedRules","definition","defName","knownOperationNames","operationName","operationCount","variableName","suggestion","usageCount","possibleType","possibleInterface","usageCountDiff","getSuggestedTypeNames","getSuggestedFieldNames","knownFragmentNames","fragType","parentTypeStr","fragTypeStr","frag","getFragmentType","visitedFrags","spreadPath","spreadPathIndexByName","spreadNodes","getFragmentSpreads","spreadNode","spreadName","spreadFragment","viaPath","s","knownVariableNames","variableNameDefined","usages","getRecursiveVariableUsages","varName","variableDefs","variableNameUsed","variableDef","getArgument","getParentInputType","fieldNodeMap","varDefMap","varDef","varTypeStr","collectConflictsWithin","findConflictsWithinSelectionSet","reasonMsg","specifiedSDLRules","oldSchema","alreadyDefined","schemaDefinitionsCount","definedOperationTypes","existingOperationTypes","checkOperationTypes","operationTypesNodes","operationType","alreadyDefinedOperationType","knownTypeNames","checkTypeName","existingTypeMap","knownValueNames","checkValueUniqueness","valueNodes","valueNames","valueDef","existingType","knownFieldNames","checkFieldUniqueness","fieldNames","knownDirectiveNames","checkExtension","defNode","expectedKind","typeToExtKind","kindStr","extensionKindToTypeName","allTypeNames","ASTValidationContext","onError","_ast","_fragments","_fragmentSpreads","_recursivelyReferencedFragments","_onError","fragments","frags","statement","spreads","setsToVisit","collectedNames","nodesToVisit","spread","SDLValidationContext","ValidationContext","_typeInfo","_variableUsages","_recursiveVariableUsages","newUsages","getDefaultValue","getVariableUsages","getEnumValue","validate","documentAST","rules","maxErrors","assertValidSchema","abortObj","rule","e","validateSDL","schemaToExtend","valueFromAST","variableValue","coercedValues","isMissingVariable","itemValue","coercedObj","_error","getDirectiveValues","directiveDef","variableValues","argumentNode","isNull","prop","hasOwnProperty","getArgumentValues","buildClientSchema","introspection","__schema","schemaIntrospection","typeIntrospection","scalarIntrospection","objectIntrospection","buildImplementationsList","buildFieldDefMap","interfaceIntrospection","unionIntrospection","unionIntrospectionStr","getObjectType","buildUnionDef","enumIntrospection","enumIntrospectionStr","valueIntrospection","buildEnumDef","inputObjectIntrospection","inputObjectIntrospectionStr","buildInputValueDefMap","buildInputObjectDef","buildType","stdType","directiveIntrospection","directiveIntrospectionStr","typeRef","itemRef","nullableRef","nullableType","assertNullableType","assertObjectType","getInterfaceType","assertInterfaceType","implementingIntrospection","implementingIntrospectionStr","fieldIntrospection","buildField","fieldIntrospectionStr","inputValueIntrospections","buildInputValue","inputValueIntrospection","parser","extendSchemaImpl","schemaConfig","typeDefs","typeExtensionsMap","directiveDefs","schemaDef","schemaExtensions","extendedTypeName","existingTypeExtensions","extendNamedType","stdTypeMap","replaceNamedType","getOperationTypes","toConfig","extendArg","buildArgumentMap","replaceType","isSpecifiedScalarType","extensionNode","getSpecifiedByUrl","extendScalarType","buildInterfaces","extendField","buildFieldMap","extendObjectType","extendInterfaceType","buildUnionTypes","extendUnionType","buildEnumValueMap","extendEnumType","buildInputFieldMap","extendInputObjectType","opTypes","getWrappedType","fieldConfigMap","nodeFields","getDeprecationReason","argConfigMap","inputFieldMap","fieldsNodes","enumValueMap","interfacesNodes","typeNodes","extensionNodes","allNodes","buildASTSchema","assumeValidSDL","assertValidSDL","stdDirective","specifiedRulesToBeRemoved","defaultValidationRules","includes","GraphQLSchemaValidationError","validationErrors","isMetaFieldName","startsWith","isNotNullOrUndefined","valueFromValueNode","filePathForNode","compileToIR","document","fragmentNodeMap","operations","fragmentMap","referencedTypes","compileOperation","fragmentNode","compileFragment","operationDefinition","filePath","rootType","getOperationRootType","compileSelectionSet","fragmentDefinition","selectionSetNode","visitedFragments","selectionNode","unwrappedFieldType","argDefType","compileSelection","introspectionResult","payload","data","documents","doc","concatAST"],"mappings":"mDAIe,SAASA,EAAaC,GACnC,MAAuB,iBAATA,GAA+B,OAAVA,ECG9B,SAASC,EAAYC,EAAQC,GAClC,MAAMC,EAAa,eACnB,IAEIC,EAFAC,EAAO,EACPC,EAASJ,EAAW,EAGxB,MAAQE,EAAQD,EAAWI,KAAKN,EAAOO,QAAUJ,EAAMK,MAAQP,GAC7DG,GAAQ,EACRC,EAASJ,EAAW,GAAKE,EAAMK,MAAQL,EAAM,GAAGM,QAGlD,MAAO,CACLL,KAAAA,EACAC,OAAAA,GChBG,SAASK,EAAcC,GAC5B,OAAOC,EAAoBD,EAASX,OAAQD,EAAYY,EAASX,OAAQW,EAASE,QAM7E,SAASD,EAAoBZ,EAAQc,GAC1C,MAAMC,EAAwBf,EAAOgB,eAAeX,OAAS,EACvDE,EAAOU,EAAWF,GAAyBf,EAAOO,KA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,GAC5B,OAAO6P,EAAM7P,gCAQb2mB,EACA2jB,GAEA,OAAOhI,GAAS3b,EAAQ2jB,EAAUV"} \ No newline at end of file +{"version":3,"file":"ApolloCodegenFrontend.bundle.js","sources":["../JavaScript/node_modules/graphql/jsutils/isObjectLike.mjs","../JavaScript/node_modules/graphql/language/location.mjs","../JavaScript/node_modules/graphql/language/printLocation.mjs","../JavaScript/node_modules/graphql/error/GraphQLError.mjs","../JavaScript/node_modules/graphql/error/syntaxError.mjs","../JavaScript/node_modules/graphql/language/kinds.mjs","../JavaScript/node_modules/graphql/language/ast.mjs","../JavaScript/node_modules/graphql/language/tokenKind.mjs","../JavaScript/node_modules/graphql/jsutils/inspect.mjs","../JavaScript/node_modules/graphql/jsutils/devAssert.mjs","../JavaScript/node_modules/graphql/jsutils/instanceOf.mjs","../JavaScript/node_modules/graphql/language/source.mjs","../JavaScript/node_modules/graphql/language/directiveLocation.mjs","../JavaScript/node_modules/graphql/language/blockString.mjs","../JavaScript/node_modules/graphql/language/lexer.mjs","../JavaScript/node_modules/graphql/language/parser.mjs","../JavaScript/node_modules/graphql/language/visitor.mjs","../JavaScript/node_modules/graphql/polyfills/objectValues.mjs","../JavaScript/node_modules/graphql/utilities/assertValidName.mjs","../JavaScript/node_modules/graphql/polyfills/objectEntries.mjs","../JavaScript/node_modules/graphql/jsutils/keyMap.mjs","../JavaScript/node_modules/graphql/jsutils/mapValue.mjs","../JavaScript/node_modules/graphql/jsutils/toObjMap.mjs","../JavaScript/node_modules/graphql/jsutils/keyValMap.mjs","../JavaScript/node_modules/graphql/jsutils/didYouMean.mjs","../JavaScript/node_modules/graphql/jsutils/identityFunc.mjs","../JavaScript/node_modules/graphql/jsutils/suggestionList.mjs","../JavaScript/node_modules/graphql/language/printer.mjs","../JavaScript/node_modules/graphql/jsutils/invariant.mjs","../JavaScript/node_modules/graphql/utilities/valueFromASTUntyped.mjs","../JavaScript/node_modules/graphql/type/definition.mjs","../JavaScript/node_modules/graphql/utilities/typeComparators.mjs","../JavaScript/node_modules/graphql/type/scalars.mjs","../JavaScript/node_modules/graphql/utilities/astFromValue.mjs","../JavaScript/node_modules/graphql/jsutils/isCollection.mjs","../JavaScript/node_modules/graphql/type/introspection.mjs","../JavaScript/node_modules/graphql/type/directives.mjs","../JavaScript/node_modules/graphql/type/schema.mjs","../JavaScript/node_modules/graphql/type/validate.mjs","../JavaScript/node_modules/graphql/error/locatedError.mjs","../JavaScript/node_modules/graphql/utilities/typeFromAST.mjs","../JavaScript/node_modules/graphql/utilities/TypeInfo.mjs","../JavaScript/node_modules/graphql/language/predicates.mjs","../JavaScript/node_modules/graphql/validation/rules/KnownTypeNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/NoUnusedFragmentsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/KnownDirectivesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueDirectivesPerLocationRule.mjs","../JavaScript/node_modules/graphql/validation/rules/KnownArgumentNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueArgumentNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/ValuesOfCorrectTypeRule.mjs","../JavaScript/node_modules/graphql/validation/rules/ProvidedRequiredArgumentsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.mjs","../JavaScript/node_modules/graphql/validation/rules/OverlappingFieldsCanBeMergedRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueInputFieldNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueFieldDefinitionNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/PossibleTypeExtensionsRule.mjs","../JavaScript/node_modules/graphql/validation/specifiedRules.mjs","../JavaScript/node_modules/graphql/validation/rules/ExecutableDefinitionsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueOperationNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/LoneAnonymousOperationRule.mjs","../JavaScript/node_modules/graphql/validation/rules/SingleFieldSubscriptionsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/FragmentsOnCompositeTypesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/VariablesAreInputTypesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/ScalarLeafsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueFragmentNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/KnownFragmentNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/PossibleFragmentSpreadsRule.mjs","../JavaScript/node_modules/graphql/validation/rules/NoFragmentCyclesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueVariableNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/NoUndefinedVariablesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/NoUnusedVariablesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/LoneSchemaDefinitionRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueOperationTypesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueTypeNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueEnumValueNamesRule.mjs","../JavaScript/node_modules/graphql/validation/rules/UniqueDirectiveNamesRule.mjs","../JavaScript/node_modules/graphql/validation/ValidationContext.mjs","../JavaScript/node_modules/graphql/validation/validate.mjs","../JavaScript/node_modules/graphql/utilities/valueFromAST.mjs","../JavaScript/node_modules/graphql/execution/values.mjs","../JavaScript/node_modules/graphql/utilities/buildClientSchema.mjs","../JavaScript/node_modules/graphql/utilities/extendSchema.mjs","../JavaScript/node_modules/graphql/utilities/buildASTSchema.mjs","../JavaScript/node_modules/graphql/utilities/printSchema.mjs","../JavaScript/src/validationRules.ts","../JavaScript/src/utilities/graphql.ts","../JavaScript/src/utilities/predicates.ts","../JavaScript/src/compiler/values.ts","../JavaScript/src/compiler/index.ts","../JavaScript/node_modules/graphql/utilities/getOperationRootType.mjs","../JavaScript/src/index.ts","../JavaScript/node_modules/graphql/utilities/concatAST.mjs"],"sourcesContent":["/**\n * Return true if `value` is object-like. A value is object-like if it's not\n * `null` and has a `typeof` result of \"object\".\n */\nexport default function isObjectLike(value) {\n return typeof value == 'object' && value !== null;\n}\n","/**\n * Represents a location in a Source.\n */\n\n/**\n * Takes a Source and a UTF-8 character offset, and returns the corresponding\n * line and column as a SourceLocation.\n */\nexport function getLocation(source, position) {\n const lineRegexp = /\\r\\n|[\\n\\r]/g;\n let line = 1;\n let column = position + 1;\n let match;\n\n while ((match = lineRegexp.exec(source.body)) && match.index < position) {\n line += 1;\n column = position + 1 - (match.index + match[0].length);\n }\n\n return {\n line,\n column\n };\n}\n","import { getLocation } from \"./location.mjs\";\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\n\nexport function printLocation(location) {\n return printSourceLocation(location.source, getLocation(location.source, location.start));\n}\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\n\nexport function printSourceLocation(source, sourceLocation) {\n const firstLineColumnOffset = source.locationOffset.column - 1;\n const body = whitespace(firstLineColumnOffset) + source.body;\n const lineIndex = sourceLocation.line - 1;\n const lineOffset = source.locationOffset.line - 1;\n const lineNum = sourceLocation.line + lineOffset;\n const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;\n const columnNum = sourceLocation.column + columnOffset;\n const locationStr = `${source.name}:${lineNum}:${columnNum}\\n`;\n const lines = body.split(/\\r\\n|[\\n\\r]/g);\n const locationLine = lines[lineIndex]; // Special case for minified documents\n\n if (locationLine.length > 120) {\n const subLineIndex = Math.floor(columnNum / 80);\n const subLineColumnNum = columnNum % 80;\n const subLines = [];\n\n for (let i = 0; i < locationLine.length; i += 80) {\n subLines.push(locationLine.slice(i, i + 80));\n }\n\n return locationStr + printPrefixedLines([[`${lineNum}`, subLines[0]], ...subLines.slice(1, subLineIndex + 1).map(subLine => ['', subLine]), [' ', whitespace(subLineColumnNum - 1) + '^'], ['', subLines[subLineIndex + 1]]]);\n }\n\n return locationStr + printPrefixedLines([// Lines specified like this: [\"prefix\", \"string\"],\n [`${lineNum - 1}`, lines[lineIndex - 1]], [`${lineNum}`, locationLine], ['', whitespace(columnNum - 1) + '^'], [`${lineNum + 1}`, lines[lineIndex + 1]]]);\n}\n\nfunction printPrefixedLines(lines) {\n const existingLines = lines.filter(([_, line]) => line !== undefined);\n const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));\n return existingLines.map(([prefix, line]) => leftPad(padLen, prefix) + (line ? ' | ' + line : ' |')).join('\\n');\n}\n\nfunction whitespace(len) {\n return Array(len + 1).join(' ');\n}\n\nfunction leftPad(len, str) {\n return whitespace(len - str.length) + str;\n}\n","// FIXME:\n// flowlint uninitialized-instance-property:off\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport { getLocation } from \"../language/location.mjs\";\nimport { printLocation, printSourceLocation } from \"../language/printLocation.mjs\";\n/**\n * A GraphQLError describes an Error found during the parse, validate, or\n * execute phases of performing a GraphQL operation. In addition to a message\n * and stack trace, it also includes information about the locations in a\n * GraphQL document and/or execution result that correspond to the Error.\n */\n\nexport class GraphQLError extends Error {\n /**\n * A message describing the Error for debugging purposes.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n *\n * Note: should be treated as readonly, despite invariant usage.\n */\n\n /**\n * An array of { line, column } locations within the source GraphQL document\n * which correspond to this error.\n *\n * Errors during validation often contain multiple locations, for example to\n * point out two things with the same name. Errors during execution include a\n * single location, the field which produced the error.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n\n /**\n * An array describing the JSON-path into the execution response which\n * corresponds to this error. Only included for errors during execution.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n\n /**\n * An array of GraphQL AST Nodes corresponding to this error.\n */\n\n /**\n * The source GraphQL document for the first location of this error.\n *\n * Note that if this Error represents more than one node, the source may not\n * represent nodes after the first node.\n */\n\n /**\n * An array of character offsets within the source GraphQL document\n * which correspond to this error.\n */\n\n /**\n * The original error thrown from a field resolver during execution.\n */\n\n /**\n * Extension fields to add to the formatted error.\n */\n constructor(message, nodes, source, positions, path, originalError, extensions) {\n super(message); // Compute list of blame nodes.\n\n const _nodes = Array.isArray(nodes) ? nodes.length !== 0 ? nodes : undefined : nodes ? [nodes] : undefined; // Compute locations in the source for the given nodes/positions.\n\n\n let _source = source;\n\n if (!_source && _nodes) {\n _source = _nodes[0].loc?.source;\n }\n\n let _positions = positions;\n\n if (!_positions && _nodes) {\n _positions = _nodes.reduce((list, node) => {\n if (node.loc) {\n list.push(node.loc.start);\n }\n\n return list;\n }, []);\n }\n\n if (_positions && _positions.length === 0) {\n _positions = undefined;\n }\n\n let _locations;\n\n if (positions && source) {\n _locations = positions.map(pos => getLocation(source, pos));\n } else if (_nodes) {\n _locations = _nodes.reduce((list, node) => {\n if (node.loc) {\n list.push(getLocation(node.loc.source, node.loc.start));\n }\n\n return list;\n }, []);\n }\n\n let _extensions = extensions;\n\n if (_extensions == null && originalError != null) {\n const originalExtensions = originalError.extensions;\n\n if (isObjectLike(originalExtensions)) {\n _extensions = originalExtensions;\n }\n }\n\n Object.defineProperties(this, {\n name: {\n value: 'GraphQLError'\n },\n message: {\n value: message,\n // By being enumerable, JSON.stringify will include `message` in the\n // resulting output. This ensures that the simplest possible GraphQL\n // service adheres to the spec.\n enumerable: true,\n writable: true\n },\n locations: {\n // Coercing falsy values to undefined ensures they will not be included\n // in JSON.stringify() when not provided.\n value: _locations ?? undefined,\n // By being enumerable, JSON.stringify will include `locations` in the\n // resulting output. This ensures that the simplest possible GraphQL\n // service adheres to the spec.\n enumerable: _locations != null\n },\n path: {\n // Coercing falsy values to undefined ensures they will not be included\n // in JSON.stringify() when not provided.\n value: path ?? undefined,\n // By being enumerable, JSON.stringify will include `path` in the\n // resulting output. This ensures that the simplest possible GraphQL\n // service adheres to the spec.\n enumerable: path != null\n },\n nodes: {\n value: _nodes ?? undefined\n },\n source: {\n value: _source ?? undefined\n },\n positions: {\n value: _positions ?? undefined\n },\n originalError: {\n value: originalError\n },\n extensions: {\n // Coercing falsy values to undefined ensures they will not be included\n // in JSON.stringify() when not provided.\n value: _extensions ?? undefined,\n // By being enumerable, JSON.stringify will include `path` in the\n // resulting output. This ensures that the simplest possible GraphQL\n // service adheres to the spec.\n enumerable: _extensions != null\n }\n }); // Include (non-enumerable) stack trace.\n\n if (originalError?.stack) {\n Object.defineProperty(this, 'stack', {\n value: originalError.stack,\n writable: true,\n configurable: true\n });\n return;\n } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')\n\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, GraphQLError);\n } else {\n Object.defineProperty(this, 'stack', {\n value: Error().stack,\n writable: true,\n configurable: true\n });\n }\n }\n\n toString() {\n return printError(this);\n } // FIXME: workaround to not break chai comparisons, should be remove in v16\n // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'Object';\n }\n\n}\n/**\n * Prints a GraphQLError to a string, representing useful location information\n * about the error's position in the source.\n */\n\nexport function printError(error) {\n let output = error.message;\n\n if (error.nodes) {\n for (const node of error.nodes) {\n if (node.loc) {\n output += '\\n\\n' + printLocation(node.loc);\n }\n }\n } else if (error.source && error.locations) {\n for (const location of error.locations) {\n output += '\\n\\n' + printSourceLocation(error.source, location);\n }\n }\n\n return output;\n}\n","import { GraphQLError } from \"./GraphQLError.mjs\";\n/**\n * Produces a GraphQLError representing a syntax error, containing useful\n * descriptive information about the syntax error's position in the source.\n */\n\nexport function syntaxError(source, position, description) {\n return new GraphQLError(`Syntax Error: ${description}`, undefined, source, [position]);\n}\n","/**\n * The set of allowed kind values for AST nodes.\n */\nexport const Kind = Object.freeze({\n // Name\n NAME: 'Name',\n // Document\n DOCUMENT: 'Document',\n OPERATION_DEFINITION: 'OperationDefinition',\n VARIABLE_DEFINITION: 'VariableDefinition',\n SELECTION_SET: 'SelectionSet',\n FIELD: 'Field',\n ARGUMENT: 'Argument',\n // Fragments\n FRAGMENT_SPREAD: 'FragmentSpread',\n INLINE_FRAGMENT: 'InlineFragment',\n FRAGMENT_DEFINITION: 'FragmentDefinition',\n // Values\n VARIABLE: 'Variable',\n INT: 'IntValue',\n FLOAT: 'FloatValue',\n STRING: 'StringValue',\n BOOLEAN: 'BooleanValue',\n NULL: 'NullValue',\n ENUM: 'EnumValue',\n LIST: 'ListValue',\n OBJECT: 'ObjectValue',\n OBJECT_FIELD: 'ObjectField',\n // Directives\n DIRECTIVE: 'Directive',\n // Types\n NAMED_TYPE: 'NamedType',\n LIST_TYPE: 'ListType',\n NON_NULL_TYPE: 'NonNullType',\n // Type System Definitions\n SCHEMA_DEFINITION: 'SchemaDefinition',\n OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition',\n // Type Definitions\n SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition',\n OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition',\n FIELD_DEFINITION: 'FieldDefinition',\n INPUT_VALUE_DEFINITION: 'InputValueDefinition',\n INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition',\n UNION_TYPE_DEFINITION: 'UnionTypeDefinition',\n ENUM_TYPE_DEFINITION: 'EnumTypeDefinition',\n ENUM_VALUE_DEFINITION: 'EnumValueDefinition',\n INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition',\n // Directive Definitions\n DIRECTIVE_DEFINITION: 'DirectiveDefinition',\n // Type System Extensions\n SCHEMA_EXTENSION: 'SchemaExtension',\n // Type Extensions\n SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension',\n OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension',\n INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension',\n UNION_TYPE_EXTENSION: 'UnionTypeExtension',\n ENUM_TYPE_EXTENSION: 'EnumTypeExtension',\n INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension'\n});\n/**\n * The enum type representing the possible kind values of AST nodes.\n */\n","/**\n * Contains a range of UTF-8 character offsets and token references that\n * identify the region of the source from which the AST derived.\n */\nexport class Location {\n /**\n * The character offset at which this Node begins.\n */\n\n /**\n * The character offset at which this Node ends.\n */\n\n /**\n * The Token at which this Node begins.\n */\n\n /**\n * The Token at which this Node ends.\n */\n\n /**\n * The Source document the AST represents.\n */\n constructor(startToken, endToken, source) {\n this.start = startToken.start;\n this.end = endToken.end;\n this.startToken = startToken;\n this.endToken = endToken;\n this.source = source;\n }\n\n toJSON() {\n return {\n start: this.start,\n end: this.end\n };\n } // @deprecated: Will be removed in v17\n // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return this.toJSON();\n }\n\n}\n/**\n * Represents a range of characters represented by a lexical token\n * within a Source.\n */\n\nexport class Token {\n /**\n * The kind of Token.\n */\n\n /**\n * The character offset at which this Node begins.\n */\n\n /**\n * The character offset at which this Node ends.\n */\n\n /**\n * The 1-indexed line number on which this Token appears.\n */\n\n /**\n * The 1-indexed column number at which this Token begins.\n */\n\n /**\n * For non-punctuation tokens, represents the interpreted value of the token.\n */\n\n /**\n * Tokens exist as nodes in a double-linked-list amongst all tokens\n * including ignored tokens. is always the first node and \n * the last.\n */\n constructor(kind, start, end, line, column, prev, value) {\n this.kind = kind;\n this.start = start;\n this.end = end;\n this.line = line;\n this.column = column;\n this.value = value;\n this.prev = prev;\n this.next = null;\n }\n\n toJSON() {\n return {\n kind: this.kind,\n value: this.value,\n line: this.line,\n column: this.column\n };\n } // @deprecated: Will be removed in v17\n // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return this.toJSON();\n }\n\n}\n/**\n * @internal\n */\n\nexport function isNode(maybeNode) {\n return maybeNode != null && typeof maybeNode.kind === 'string';\n}\n/**\n * The list of all possible AST node types.\n */\n","/**\n * An exported enum describing the different kinds of tokens that the\n * lexer emits.\n */\nexport const TokenKind = Object.freeze({\n SOF: '',\n EOF: '',\n BANG: '!',\n DOLLAR: '$',\n AMP: '&',\n PAREN_L: '(',\n PAREN_R: ')',\n SPREAD: '...',\n COLON: ':',\n EQUALS: '=',\n AT: '@',\n BRACKET_L: '[',\n BRACKET_R: ']',\n BRACE_L: '{',\n PIPE: '|',\n BRACE_R: '}',\n NAME: 'Name',\n INT: 'Int',\n FLOAT: 'Float',\n STRING: 'String',\n BLOCK_STRING: 'BlockString',\n COMMENT: 'Comment'\n});\n/**\n * The enum type representing the token kinds values.\n */\n","/* eslint-disable flowtype/no-weak-types */\nconst MAX_ARRAY_LENGTH = 10;\nconst MAX_RECURSIVE_DEPTH = 2;\n/**\n * Used to print values in error messages.\n */\n\nexport default function inspect(value) {\n return formatValue(value, []);\n}\n\nfunction formatValue(value, seenValues) {\n switch (typeof value) {\n case 'string':\n return JSON.stringify(value);\n\n case 'function':\n return value.name ? `[function ${value.name}]` : '[function]';\n\n case 'object':\n if (value === null) {\n return 'null';\n }\n\n return formatObjectValue(value, seenValues);\n\n default:\n return String(value);\n }\n}\n\nfunction formatObjectValue(value, previouslySeenValues) {\n if (previouslySeenValues.indexOf(value) !== -1) {\n return '[Circular]';\n }\n\n const seenValues = [...previouslySeenValues, value];\n\n if (typeof value.toJSON === 'function') {\n const jsonValue = value.toJSON(value); // check for infinite recursion\n\n if (jsonValue !== value) {\n return typeof jsonValue === 'string' ? jsonValue : formatValue(jsonValue, seenValues);\n }\n } else if (Array.isArray(value)) {\n return formatArray(value, seenValues);\n }\n\n return formatObject(value, seenValues);\n}\n\nfunction formatObject(object, seenValues) {\n const keys = Object.keys(object);\n\n if (keys.length === 0) {\n return '{}';\n }\n\n if (seenValues.length > MAX_RECURSIVE_DEPTH) {\n return '[' + getObjectTag(object) + ']';\n }\n\n const properties = keys.map(key => {\n const value = formatValue(object[key], seenValues);\n return key + ': ' + value;\n });\n return '{ ' + properties.join(', ') + ' }';\n}\n\nfunction formatArray(array, seenValues) {\n if (array.length === 0) {\n return '[]';\n }\n\n if (seenValues.length > MAX_RECURSIVE_DEPTH) {\n return '[Array]';\n }\n\n const len = Math.min(MAX_ARRAY_LENGTH, array.length);\n const remaining = array.length - len;\n const items = [];\n\n for (let i = 0; i < len; ++i) {\n items.push(formatValue(array[i], seenValues));\n }\n\n if (remaining === 1) {\n items.push('... 1 more item');\n } else if (remaining > 1) {\n items.push(`... ${remaining} more items`);\n }\n\n return '[' + items.join(', ') + ']';\n}\n\nfunction getObjectTag(object) {\n const tag = Object.prototype.toString.call(object).replace(/^\\[object /, '').replace(/]$/, '');\n\n if (tag === 'Object' && typeof object.constructor === 'function') {\n const name = object.constructor.name;\n\n if (typeof name === 'string' && name !== '') {\n return name;\n }\n }\n\n return tag;\n}\n","export default function devAssert(condition, message) {\n const booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')\n\n if (!booleanCondition) {\n throw new Error(message);\n }\n}\n","/**\n * A replacement for instanceof which includes an error warning when multi-realm\n * constructors are detected.\n */\n// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production\n// See: https://webpack.js.org/guides/production/\nexport default process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')\n// eslint-disable-next-line no-shadow\nfunction instanceOf(value, constructor) {\n return value instanceof constructor;\n} : // eslint-disable-next-line no-shadow\nfunction instanceOf(value, constructor) {\n if (value instanceof constructor) {\n return true;\n }\n\n if (value) {\n const valueClass = value.constructor;\n const className = constructor.name;\n\n if (className && valueClass && valueClass.name === className) {\n throw new Error(`Cannot use ${className} \"${value}\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.`);\n }\n }\n\n return false;\n};\n","import inspect from \"../jsutils/inspect.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport instanceOf from \"../jsutils/instanceOf.mjs\";\n\n/**\n * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are\n * optional, but they are useful for clients who store GraphQL documents in source files.\n * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might\n * be useful for `name` to be `\"Foo.graphql\"` and location to be `{ line: 40, column: 1 }`.\n * The `line` and `column` properties in `locationOffset` are 1-indexed.\n */\nexport class Source {\n constructor(body, name = 'GraphQL request', locationOffset = {\n line: 1,\n column: 1\n }) {\n typeof body === 'string' || devAssert(0, `Body must be a string. Received: ${inspect(body)}.`);\n this.body = body;\n this.name = name;\n this.locationOffset = locationOffset;\n this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.');\n this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.');\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'Source';\n }\n\n}\n/**\n * Test if the given value is a Source object.\n *\n * @internal\n */\n\n// eslint-disable-next-line no-redeclare\nexport function isSource(source) {\n return instanceOf(source, Source);\n}\n","/**\n * The set of allowed directive location values.\n */\nexport const DirectiveLocation = Object.freeze({\n // Request Definitions\n QUERY: 'QUERY',\n MUTATION: 'MUTATION',\n SUBSCRIPTION: 'SUBSCRIPTION',\n FIELD: 'FIELD',\n FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',\n FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',\n INLINE_FRAGMENT: 'INLINE_FRAGMENT',\n VARIABLE_DEFINITION: 'VARIABLE_DEFINITION',\n // Type System Definitions\n SCHEMA: 'SCHEMA',\n SCALAR: 'SCALAR',\n OBJECT: 'OBJECT',\n FIELD_DEFINITION: 'FIELD_DEFINITION',\n ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',\n INTERFACE: 'INTERFACE',\n UNION: 'UNION',\n ENUM: 'ENUM',\n ENUM_VALUE: 'ENUM_VALUE',\n INPUT_OBJECT: 'INPUT_OBJECT',\n INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'\n});\n/**\n * The enum type representing the directive location values.\n */\n","/**\n * Produces the value of a block string from its parsed raw value, similar to\n * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.\n *\n * This implements the GraphQL spec's BlockStringValue() static algorithm.\n *\n * @internal\n */\nexport function dedentBlockStringValue(rawString) {\n // Expand a block string's raw value into independent lines.\n const lines = rawString.split(/\\r\\n|[\\n\\r]/g); // Remove common indentation from all lines but first.\n\n const commonIndent = getBlockStringIndentation(rawString);\n\n if (commonIndent !== 0) {\n for (let i = 1; i < lines.length; i++) {\n lines[i] = lines[i].slice(commonIndent);\n }\n } // Remove leading and trailing blank lines.\n\n\n let startLine = 0;\n\n while (startLine < lines.length && isBlank(lines[startLine])) {\n ++startLine;\n }\n\n let endLine = lines.length;\n\n while (endLine > startLine && isBlank(lines[endLine - 1])) {\n --endLine;\n } // Return a string of the lines joined with U+000A.\n\n\n return lines.slice(startLine, endLine).join('\\n');\n}\n\nfunction isBlank(str) {\n for (let i = 0; i < str.length; ++i) {\n if (str[i] !== ' ' && str[i] !== '\\t') {\n return false;\n }\n }\n\n return true;\n}\n/**\n * @internal\n */\n\n\nexport function getBlockStringIndentation(value) {\n let isFirstLine = true;\n let isEmptyLine = true;\n let indent = 0;\n let commonIndent = null;\n\n for (let i = 0; i < value.length; ++i) {\n switch (value.charCodeAt(i)) {\n case 13:\n // \\r\n if (value.charCodeAt(i + 1) === 10) {\n ++i; // skip \\r\\n as one symbol\n }\n\n // falls through\n\n case 10:\n // \\n\n isFirstLine = false;\n isEmptyLine = true;\n indent = 0;\n break;\n\n case 9: // \\t\n\n case 32:\n // \n ++indent;\n break;\n\n default:\n if (isEmptyLine && !isFirstLine && (commonIndent === null || indent < commonIndent)) {\n commonIndent = indent;\n }\n\n isEmptyLine = false;\n }\n }\n\n return commonIndent ?? 0;\n}\n/**\n * Print a block string in the indented block form by adding a leading and\n * trailing blank line. However, if a block string starts with whitespace and is\n * a single-line, adding a leading blank line would strip that whitespace.\n *\n * @internal\n */\n\nexport function printBlockString(value, indentation = '', preferMultipleLines = false) {\n const isSingleLine = value.indexOf('\\n') === -1;\n const hasLeadingSpace = value[0] === ' ' || value[0] === '\\t';\n const hasTrailingQuote = value[value.length - 1] === '\"';\n const hasTrailingSlash = value[value.length - 1] === '\\\\';\n const printAsMultipleLines = !isSingleLine || hasTrailingQuote || hasTrailingSlash || preferMultipleLines;\n let result = ''; // Format a multi-line block quote to account for leading space.\n\n if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) {\n result += '\\n' + indentation;\n }\n\n result += indentation ? value.replace(/\\n/g, '\\n' + indentation) : value;\n\n if (printAsMultipleLines) {\n result += '\\n';\n }\n\n return '\"\"\"' + result.replace(/\"\"\"/g, '\\\\\"\"\"') + '\"\"\"';\n}\n","import { syntaxError } from \"../error/syntaxError.mjs\";\nimport { Token } from \"./ast.mjs\";\nimport { TokenKind } from \"./tokenKind.mjs\";\nimport { dedentBlockStringValue } from \"./blockString.mjs\";\n/**\n * Given a Source object, creates a Lexer for that source.\n * A Lexer is a stateful stream generator in that every time\n * it is advanced, it returns the next token in the Source. Assuming the\n * source lexes, the final Token emitted by the lexer will be of kind\n * EOF, after which the lexer will repeatedly return the same EOF token\n * whenever called.\n */\n\nexport class Lexer {\n /**\n * The previously focused non-ignored token.\n */\n\n /**\n * The currently focused non-ignored token.\n */\n\n /**\n * The (1-indexed) line containing the current token.\n */\n\n /**\n * The character offset at which the current line begins.\n */\n constructor(source) {\n const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0, null);\n this.source = source;\n this.lastToken = startOfFileToken;\n this.token = startOfFileToken;\n this.line = 1;\n this.lineStart = 0;\n }\n /**\n * Advances the token stream to the next non-ignored token.\n */\n\n\n advance() {\n this.lastToken = this.token;\n const token = this.token = this.lookahead();\n return token;\n }\n /**\n * Looks ahead and returns the next non-ignored token, but does not change\n * the state of Lexer.\n */\n\n\n lookahead() {\n let token = this.token;\n\n if (token.kind !== TokenKind.EOF) {\n do {\n // Note: next is only mutable during parsing, so we cast to allow this.\n token = token.next ?? (token.next = readToken(this, token));\n } while (token.kind === TokenKind.COMMENT);\n }\n\n return token;\n }\n\n}\n/**\n * @internal\n */\n\nexport function isPunctuatorTokenKind(kind) {\n return kind === TokenKind.BANG || kind === TokenKind.DOLLAR || kind === TokenKind.AMP || kind === TokenKind.PAREN_L || kind === TokenKind.PAREN_R || kind === TokenKind.SPREAD || kind === TokenKind.COLON || kind === TokenKind.EQUALS || kind === TokenKind.AT || kind === TokenKind.BRACKET_L || kind === TokenKind.BRACKET_R || kind === TokenKind.BRACE_L || kind === TokenKind.PIPE || kind === TokenKind.BRACE_R;\n}\n\nfunction printCharCode(code) {\n return (// NaN/undefined represents access beyond the end of the file.\n isNaN(code) ? TokenKind.EOF : // Trust JSON for ASCII.\n code < 0x007f ? JSON.stringify(String.fromCharCode(code)) : // Otherwise print the escaped form.\n `\"\\\\u${('00' + code.toString(16).toUpperCase()).slice(-4)}\"`\n );\n}\n/**\n * Gets the next token from the source starting at the given position.\n *\n * This skips over whitespace until it finds the next lexable token, then lexes\n * punctuators immediately or calls the appropriate helper function for more\n * complicated tokens.\n */\n\n\nfunction readToken(lexer, prev) {\n const source = lexer.source;\n const body = source.body;\n const bodyLength = body.length;\n let pos = prev.end;\n\n while (pos < bodyLength) {\n const code = body.charCodeAt(pos);\n const line = lexer.line;\n const col = 1 + pos - lexer.lineStart; // SourceCharacter\n\n switch (code) {\n case 0xfeff: // \n\n case 9: // \\t\n\n case 32: // \n\n case 44:\n // ,\n ++pos;\n continue;\n\n case 10:\n // \\n\n ++pos;\n ++lexer.line;\n lexer.lineStart = pos;\n continue;\n\n case 13:\n // \\r\n if (body.charCodeAt(pos + 1) === 10) {\n pos += 2;\n } else {\n ++pos;\n }\n\n ++lexer.line;\n lexer.lineStart = pos;\n continue;\n\n case 33:\n // !\n return new Token(TokenKind.BANG, pos, pos + 1, line, col, prev);\n\n case 35:\n // #\n return readComment(source, pos, line, col, prev);\n\n case 36:\n // $\n return new Token(TokenKind.DOLLAR, pos, pos + 1, line, col, prev);\n\n case 38:\n // &\n return new Token(TokenKind.AMP, pos, pos + 1, line, col, prev);\n\n case 40:\n // (\n return new Token(TokenKind.PAREN_L, pos, pos + 1, line, col, prev);\n\n case 41:\n // )\n return new Token(TokenKind.PAREN_R, pos, pos + 1, line, col, prev);\n\n case 46:\n // .\n if (body.charCodeAt(pos + 1) === 46 && body.charCodeAt(pos + 2) === 46) {\n return new Token(TokenKind.SPREAD, pos, pos + 3, line, col, prev);\n }\n\n break;\n\n case 58:\n // :\n return new Token(TokenKind.COLON, pos, pos + 1, line, col, prev);\n\n case 61:\n // =\n return new Token(TokenKind.EQUALS, pos, pos + 1, line, col, prev);\n\n case 64:\n // @\n return new Token(TokenKind.AT, pos, pos + 1, line, col, prev);\n\n case 91:\n // [\n return new Token(TokenKind.BRACKET_L, pos, pos + 1, line, col, prev);\n\n case 93:\n // ]\n return new Token(TokenKind.BRACKET_R, pos, pos + 1, line, col, prev);\n\n case 123:\n // {\n return new Token(TokenKind.BRACE_L, pos, pos + 1, line, col, prev);\n\n case 124:\n // |\n return new Token(TokenKind.PIPE, pos, pos + 1, line, col, prev);\n\n case 125:\n // }\n return new Token(TokenKind.BRACE_R, pos, pos + 1, line, col, prev);\n\n case 34:\n // \"\n if (body.charCodeAt(pos + 1) === 34 && body.charCodeAt(pos + 2) === 34) {\n return readBlockString(source, pos, line, col, prev, lexer);\n }\n\n return readString(source, pos, line, col, prev);\n\n case 45: // -\n\n case 48: // 0\n\n case 49: // 1\n\n case 50: // 2\n\n case 51: // 3\n\n case 52: // 4\n\n case 53: // 5\n\n case 54: // 6\n\n case 55: // 7\n\n case 56: // 8\n\n case 57:\n // 9\n return readNumber(source, pos, code, line, col, prev);\n\n case 65: // A\n\n case 66: // B\n\n case 67: // C\n\n case 68: // D\n\n case 69: // E\n\n case 70: // F\n\n case 71: // G\n\n case 72: // H\n\n case 73: // I\n\n case 74: // J\n\n case 75: // K\n\n case 76: // L\n\n case 77: // M\n\n case 78: // N\n\n case 79: // O\n\n case 80: // P\n\n case 81: // Q\n\n case 82: // R\n\n case 83: // S\n\n case 84: // T\n\n case 85: // U\n\n case 86: // V\n\n case 87: // W\n\n case 88: // X\n\n case 89: // Y\n\n case 90: // Z\n\n case 95: // _\n\n case 97: // a\n\n case 98: // b\n\n case 99: // c\n\n case 100: // d\n\n case 101: // e\n\n case 102: // f\n\n case 103: // g\n\n case 104: // h\n\n case 105: // i\n\n case 106: // j\n\n case 107: // k\n\n case 108: // l\n\n case 109: // m\n\n case 110: // n\n\n case 111: // o\n\n case 112: // p\n\n case 113: // q\n\n case 114: // r\n\n case 115: // s\n\n case 116: // t\n\n case 117: // u\n\n case 118: // v\n\n case 119: // w\n\n case 120: // x\n\n case 121: // y\n\n case 122:\n // z\n return readName(source, pos, line, col, prev);\n }\n\n throw syntaxError(source, pos, unexpectedCharacterMessage(code));\n }\n\n const line = lexer.line;\n const col = 1 + pos - lexer.lineStart;\n return new Token(TokenKind.EOF, bodyLength, bodyLength, line, col, prev);\n}\n/**\n * Report a message that an unexpected character was encountered.\n */\n\n\nfunction unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return `Cannot contain the invalid character ${printCharCode(code)}.`;\n }\n\n if (code === 39) {\n // '\n return 'Unexpected single quote character (\\'), did you mean to use a double quote (\")?';\n }\n\n return `Cannot parse the unexpected character ${printCharCode(code)}.`;\n}\n/**\n * Reads a comment token from the source file.\n *\n * #[\\u0009\\u0020-\\uFFFF]*\n */\n\n\nfunction readComment(source, start, line, col, prev) {\n const body = source.body;\n let code;\n let position = start;\n\n do {\n code = body.charCodeAt(++position);\n } while (!isNaN(code) && ( // SourceCharacter but not LineTerminator\n code > 0x001f || code === 0x0009));\n\n return new Token(TokenKind.COMMENT, start, position, line, col, prev, body.slice(start + 1, position));\n}\n/**\n * Reads a number token from the source file, either a float\n * or an int depending on whether a decimal point appears.\n *\n * Int: -?(0|[1-9][0-9]*)\n * Float: -?(0|[1-9][0-9]*)(\\.[0-9]+)?((E|e)(+|-)?[0-9]+)?\n */\n\n\nfunction readNumber(source, start, firstCode, line, col, prev) {\n const body = source.body;\n let code = firstCode;\n let position = start;\n let isFloat = false;\n\n if (code === 45) {\n // -\n code = body.charCodeAt(++position);\n }\n\n if (code === 48) {\n // 0\n code = body.charCodeAt(++position);\n\n if (code >= 48 && code <= 57) {\n throw syntaxError(source, position, `Invalid number, unexpected digit after 0: ${printCharCode(code)}.`);\n }\n } else {\n position = readDigits(source, position, code);\n code = body.charCodeAt(position);\n }\n\n if (code === 46) {\n // .\n isFloat = true;\n code = body.charCodeAt(++position);\n position = readDigits(source, position, code);\n code = body.charCodeAt(position);\n }\n\n if (code === 69 || code === 101) {\n // E e\n isFloat = true;\n code = body.charCodeAt(++position);\n\n if (code === 43 || code === 45) {\n // + -\n code = body.charCodeAt(++position);\n }\n\n position = readDigits(source, position, code);\n code = body.charCodeAt(position);\n } // Numbers cannot be followed by . or NameStart\n\n\n if (code === 46 || isNameStart(code)) {\n throw syntaxError(source, position, `Invalid number, expected digit but got: ${printCharCode(code)}.`);\n }\n\n return new Token(isFloat ? TokenKind.FLOAT : TokenKind.INT, start, position, line, col, prev, body.slice(start, position));\n}\n/**\n * Returns the new position in the source after reading digits.\n */\n\n\nfunction readDigits(source, start, firstCode) {\n const body = source.body;\n let position = start;\n let code = firstCode;\n\n if (code >= 48 && code <= 57) {\n // 0 - 9\n do {\n code = body.charCodeAt(++position);\n } while (code >= 48 && code <= 57); // 0 - 9\n\n\n return position;\n }\n\n throw syntaxError(source, position, `Invalid number, expected digit but got: ${printCharCode(code)}.`);\n}\n/**\n * Reads a string token from the source file.\n *\n * \"([^\"\\\\\\u000A\\u000D]|(\\\\(u[0-9a-fA-F]{4}|[\"\\\\/bfnrt])))*\"\n */\n\n\nfunction readString(source, start, line, col, prev) {\n const body = source.body;\n let position = start + 1;\n let chunkStart = position;\n let code = 0;\n let value = '';\n\n while (position < body.length && !isNaN(code = body.charCodeAt(position)) && // not LineTerminator\n code !== 0x000a && code !== 0x000d) {\n // Closing Quote (\")\n if (code === 34) {\n value += body.slice(chunkStart, position);\n return new Token(TokenKind.STRING, start, position + 1, line, col, prev, value);\n } // SourceCharacter\n\n\n if (code < 0x0020 && code !== 0x0009) {\n throw syntaxError(source, position, `Invalid character within String: ${printCharCode(code)}.`);\n }\n\n ++position;\n\n if (code === 92) {\n // \\\n value += body.slice(chunkStart, position - 1);\n code = body.charCodeAt(position);\n\n switch (code) {\n case 34:\n value += '\"';\n break;\n\n case 47:\n value += '/';\n break;\n\n case 92:\n value += '\\\\';\n break;\n\n case 98:\n value += '\\b';\n break;\n\n case 102:\n value += '\\f';\n break;\n\n case 110:\n value += '\\n';\n break;\n\n case 114:\n value += '\\r';\n break;\n\n case 116:\n value += '\\t';\n break;\n\n case 117:\n {\n // uXXXX\n const charCode = uniCharCode(body.charCodeAt(position + 1), body.charCodeAt(position + 2), body.charCodeAt(position + 3), body.charCodeAt(position + 4));\n\n if (charCode < 0) {\n const invalidSequence = body.slice(position + 1, position + 5);\n throw syntaxError(source, position, `Invalid character escape sequence: \\\\u${invalidSequence}.`);\n }\n\n value += String.fromCharCode(charCode);\n position += 4;\n break;\n }\n\n default:\n throw syntaxError(source, position, `Invalid character escape sequence: \\\\${String.fromCharCode(code)}.`);\n }\n\n ++position;\n chunkStart = position;\n }\n }\n\n throw syntaxError(source, position, 'Unterminated string.');\n}\n/**\n * Reads a block string token from the source file.\n *\n * \"\"\"(\"?\"?(\\\\\"\"\"|\\\\(?!=\"\"\")|[^\"\\\\]))*\"\"\"\n */\n\n\nfunction readBlockString(source, start, line, col, prev, lexer) {\n const body = source.body;\n let position = start + 3;\n let chunkStart = position;\n let code = 0;\n let rawValue = '';\n\n while (position < body.length && !isNaN(code = body.charCodeAt(position))) {\n // Closing Triple-Quote (\"\"\")\n if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {\n rawValue += body.slice(chunkStart, position);\n return new Token(TokenKind.BLOCK_STRING, start, position + 3, line, col, prev, dedentBlockStringValue(rawValue));\n } // SourceCharacter\n\n\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n throw syntaxError(source, position, `Invalid character within String: ${printCharCode(code)}.`);\n }\n\n if (code === 10) {\n // new line\n ++position;\n ++lexer.line;\n lexer.lineStart = position;\n } else if (code === 13) {\n // carriage return\n if (body.charCodeAt(position + 1) === 10) {\n position += 2;\n } else {\n ++position;\n }\n\n ++lexer.line;\n lexer.lineStart = position;\n } else if ( // Escape Triple-Quote (\\\"\"\")\n code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {\n rawValue += body.slice(chunkStart, position) + '\"\"\"';\n position += 4;\n chunkStart = position;\n } else {\n ++position;\n }\n }\n\n throw syntaxError(source, position, 'Unterminated string.');\n}\n/**\n * Converts four hexadecimal chars to the integer that the\n * string represents. For example, uniCharCode('0','0','0','f')\n * will return 15, and uniCharCode('0','0','f','f') returns 255.\n *\n * Returns a negative number on error, if a char was invalid.\n *\n * This is implemented by noting that char2hex() returns -1 on error,\n * which means the result of ORing the char2hex() will also be negative.\n */\n\n\nfunction uniCharCode(a, b, c, d) {\n return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d);\n}\n/**\n * Converts a hex character to its integer value.\n * '0' becomes 0, '9' becomes 9\n * 'A' becomes 10, 'F' becomes 15\n * 'a' becomes 10, 'f' becomes 15\n *\n * Returns -1 on error.\n */\n\n\nfunction char2hex(a) {\n return a >= 48 && a <= 57 ? a - 48 // 0-9\n : a >= 65 && a <= 70 ? a - 55 // A-F\n : a >= 97 && a <= 102 ? a - 87 // a-f\n : -1;\n}\n/**\n * Reads an alphanumeric + underscore name from the source.\n *\n * [_A-Za-z][_0-9A-Za-z]*\n */\n\n\nfunction readName(source, start, line, col, prev) {\n const body = source.body;\n const bodyLength = body.length;\n let position = start + 1;\n let code = 0;\n\n while (position !== bodyLength && !isNaN(code = body.charCodeAt(position)) && (code === 95 || // _\n code >= 48 && code <= 57 || // 0-9\n code >= 65 && code <= 90 || // A-Z\n code >= 97 && code <= 122) // a-z\n ) {\n ++position;\n }\n\n return new Token(TokenKind.NAME, start, position, line, col, prev, body.slice(start, position));\n} // _ A-Z a-z\n\n\nfunction isNameStart(code) {\n return code === 95 || code >= 65 && code <= 90 || code >= 97 && code <= 122;\n}\n","import { syntaxError } from \"../error/syntaxError.mjs\";\nimport { Kind } from \"./kinds.mjs\";\nimport { Location } from \"./ast.mjs\";\nimport { TokenKind } from \"./tokenKind.mjs\";\nimport { Source, isSource } from \"./source.mjs\";\nimport { DirectiveLocation } from \"./directiveLocation.mjs\";\nimport { Lexer, isPunctuatorTokenKind } from \"./lexer.mjs\";\n/**\n * Configuration options to control parser behavior\n */\n\n/**\n * Given a GraphQL source, parses it into a Document.\n * Throws GraphQLError if a syntax error is encountered.\n */\nexport function parse(source, options) {\n const parser = new Parser(source, options);\n return parser.parseDocument();\n}\n/**\n * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for\n * that value.\n * Throws GraphQLError if a syntax error is encountered.\n *\n * This is useful within tools that operate upon GraphQL Values directly and\n * in isolation of complete GraphQL documents.\n *\n * Consider providing the results to the utility function: valueFromAST().\n */\n\nexport function parseValue(source, options) {\n const parser = new Parser(source, options);\n parser.expectToken(TokenKind.SOF);\n const value = parser.parseValueLiteral(false);\n parser.expectToken(TokenKind.EOF);\n return value;\n}\n/**\n * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for\n * that type.\n * Throws GraphQLError if a syntax error is encountered.\n *\n * This is useful within tools that operate upon GraphQL Types directly and\n * in isolation of complete GraphQL documents.\n *\n * Consider providing the results to the utility function: typeFromAST().\n */\n\nexport function parseType(source, options) {\n const parser = new Parser(source, options);\n parser.expectToken(TokenKind.SOF);\n const type = parser.parseTypeReference();\n parser.expectToken(TokenKind.EOF);\n return type;\n}\n/**\n * This class is exported only to assist people in implementing their own parsers\n * without duplicating too much code and should be used only as last resort for cases\n * such as experimental syntax or if certain features could not be contributed upstream.\n *\n * It is still part of the internal API and is versioned, so any changes to it are never\n * considered breaking changes. If you still need to support multiple versions of the\n * library, please use the `versionInfo` variable for version detection.\n *\n * @internal\n */\n\nexport class Parser {\n constructor(source, options) {\n const sourceObj = isSource(source) ? source : new Source(source);\n this._lexer = new Lexer(sourceObj);\n this._options = options;\n }\n /**\n * Converts a name lex token into a name parse node.\n */\n\n\n parseName() {\n const token = this.expectToken(TokenKind.NAME);\n return {\n kind: Kind.NAME,\n value: token.value,\n loc: this.loc(token)\n };\n } // Implements the parsing rules in the Document section.\n\n /**\n * Document : Definition+\n */\n\n\n parseDocument() {\n const start = this._lexer.token;\n return {\n kind: Kind.DOCUMENT,\n definitions: this.many(TokenKind.SOF, this.parseDefinition, TokenKind.EOF),\n loc: this.loc(start)\n };\n }\n /**\n * Definition :\n * - ExecutableDefinition\n * - TypeSystemDefinition\n * - TypeSystemExtension\n *\n * ExecutableDefinition :\n * - OperationDefinition\n * - FragmentDefinition\n */\n\n\n parseDefinition() {\n if (this.peek(TokenKind.NAME)) {\n switch (this._lexer.token.value) {\n case 'query':\n case 'mutation':\n case 'subscription':\n return this.parseOperationDefinition();\n\n case 'fragment':\n return this.parseFragmentDefinition();\n\n case 'schema':\n case 'scalar':\n case 'type':\n case 'interface':\n case 'union':\n case 'enum':\n case 'input':\n case 'directive':\n return this.parseTypeSystemDefinition();\n\n case 'extend':\n return this.parseTypeSystemExtension();\n }\n } else if (this.peek(TokenKind.BRACE_L)) {\n return this.parseOperationDefinition();\n } else if (this.peekDescription()) {\n return this.parseTypeSystemDefinition();\n }\n\n throw this.unexpected();\n } // Implements the parsing rules in the Operations section.\n\n /**\n * OperationDefinition :\n * - SelectionSet\n * - OperationType Name? VariableDefinitions? Directives? SelectionSet\n */\n\n\n parseOperationDefinition() {\n const start = this._lexer.token;\n\n if (this.peek(TokenKind.BRACE_L)) {\n return {\n kind: Kind.OPERATION_DEFINITION,\n operation: 'query',\n name: undefined,\n variableDefinitions: [],\n directives: [],\n selectionSet: this.parseSelectionSet(),\n loc: this.loc(start)\n };\n }\n\n const operation = this.parseOperationType();\n let name;\n\n if (this.peek(TokenKind.NAME)) {\n name = this.parseName();\n }\n\n return {\n kind: Kind.OPERATION_DEFINITION,\n operation,\n name,\n variableDefinitions: this.parseVariableDefinitions(),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n loc: this.loc(start)\n };\n }\n /**\n * OperationType : one of query mutation subscription\n */\n\n\n parseOperationType() {\n const operationToken = this.expectToken(TokenKind.NAME);\n\n switch (operationToken.value) {\n case 'query':\n return 'query';\n\n case 'mutation':\n return 'mutation';\n\n case 'subscription':\n return 'subscription';\n }\n\n throw this.unexpected(operationToken);\n }\n /**\n * VariableDefinitions : ( VariableDefinition+ )\n */\n\n\n parseVariableDefinitions() {\n return this.optionalMany(TokenKind.PAREN_L, this.parseVariableDefinition, TokenKind.PAREN_R);\n }\n /**\n * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?\n */\n\n\n parseVariableDefinition() {\n const start = this._lexer.token;\n return {\n kind: Kind.VARIABLE_DEFINITION,\n variable: this.parseVariable(),\n type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),\n defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseValueLiteral(true) : undefined,\n directives: this.parseDirectives(true),\n loc: this.loc(start)\n };\n }\n /**\n * Variable : $ Name\n */\n\n\n parseVariable() {\n const start = this._lexer.token;\n this.expectToken(TokenKind.DOLLAR);\n return {\n kind: Kind.VARIABLE,\n name: this.parseName(),\n loc: this.loc(start)\n };\n }\n /**\n * SelectionSet : { Selection+ }\n */\n\n\n parseSelectionSet() {\n const start = this._lexer.token;\n return {\n kind: Kind.SELECTION_SET,\n selections: this.many(TokenKind.BRACE_L, this.parseSelection, TokenKind.BRACE_R),\n loc: this.loc(start)\n };\n }\n /**\n * Selection :\n * - Field\n * - FragmentSpread\n * - InlineFragment\n */\n\n\n parseSelection() {\n return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();\n }\n /**\n * Field : Alias? Name Arguments? Directives? SelectionSet?\n *\n * Alias : Name :\n */\n\n\n parseField() {\n const start = this._lexer.token;\n const nameOrAlias = this.parseName();\n let alias;\n let name;\n\n if (this.expectOptionalToken(TokenKind.COLON)) {\n alias = nameOrAlias;\n name = this.parseName();\n } else {\n name = nameOrAlias;\n }\n\n return {\n kind: Kind.FIELD,\n alias,\n name,\n arguments: this.parseArguments(false),\n directives: this.parseDirectives(false),\n selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : undefined,\n loc: this.loc(start)\n };\n }\n /**\n * Arguments[Const] : ( Argument[?Const]+ )\n */\n\n\n parseArguments(isConst) {\n const item = isConst ? this.parseConstArgument : this.parseArgument;\n return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);\n }\n /**\n * Argument[Const] : Name : Value[?Const]\n */\n\n\n parseArgument() {\n const start = this._lexer.token;\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n return {\n kind: Kind.ARGUMENT,\n name,\n value: this.parseValueLiteral(false),\n loc: this.loc(start)\n };\n }\n\n parseConstArgument() {\n const start = this._lexer.token;\n return {\n kind: Kind.ARGUMENT,\n name: this.parseName(),\n value: (this.expectToken(TokenKind.COLON), this.parseValueLiteral(true)),\n loc: this.loc(start)\n };\n } // Implements the parsing rules in the Fragments section.\n\n /**\n * Corresponds to both FragmentSpread and InlineFragment in the spec.\n *\n * FragmentSpread : ... FragmentName Directives?\n *\n * InlineFragment : ... TypeCondition? Directives? SelectionSet\n */\n\n\n parseFragment() {\n const start = this._lexer.token;\n this.expectToken(TokenKind.SPREAD);\n const hasTypeCondition = this.expectOptionalKeyword('on');\n\n if (!hasTypeCondition && this.peek(TokenKind.NAME)) {\n return {\n kind: Kind.FRAGMENT_SPREAD,\n name: this.parseFragmentName(),\n directives: this.parseDirectives(false),\n loc: this.loc(start)\n };\n }\n\n return {\n kind: Kind.INLINE_FRAGMENT,\n typeCondition: hasTypeCondition ? this.parseNamedType() : undefined,\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n loc: this.loc(start)\n };\n }\n /**\n * FragmentDefinition :\n * - fragment FragmentName on TypeCondition Directives? SelectionSet\n *\n * TypeCondition : NamedType\n */\n\n\n parseFragmentDefinition() {\n const start = this._lexer.token;\n this.expectKeyword('fragment'); // Experimental support for defining variables within fragments changes\n // the grammar of FragmentDefinition:\n // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet\n\n if (this._options?.experimentalFragmentVariables === true) {\n return {\n kind: Kind.FRAGMENT_DEFINITION,\n name: this.parseFragmentName(),\n variableDefinitions: this.parseVariableDefinitions(),\n typeCondition: (this.expectKeyword('on'), this.parseNamedType()),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n loc: this.loc(start)\n };\n }\n\n return {\n kind: Kind.FRAGMENT_DEFINITION,\n name: this.parseFragmentName(),\n typeCondition: (this.expectKeyword('on'), this.parseNamedType()),\n directives: this.parseDirectives(false),\n selectionSet: this.parseSelectionSet(),\n loc: this.loc(start)\n };\n }\n /**\n * FragmentName : Name but not `on`\n */\n\n\n parseFragmentName() {\n if (this._lexer.token.value === 'on') {\n throw this.unexpected();\n }\n\n return this.parseName();\n } // Implements the parsing rules in the Values section.\n\n /**\n * Value[Const] :\n * - [~Const] Variable\n * - IntValue\n * - FloatValue\n * - StringValue\n * - BooleanValue\n * - NullValue\n * - EnumValue\n * - ListValue[?Const]\n * - ObjectValue[?Const]\n *\n * BooleanValue : one of `true` `false`\n *\n * NullValue : `null`\n *\n * EnumValue : Name but not `true`, `false` or `null`\n */\n\n\n parseValueLiteral(isConst) {\n const token = this._lexer.token;\n\n switch (token.kind) {\n case TokenKind.BRACKET_L:\n return this.parseList(isConst);\n\n case TokenKind.BRACE_L:\n return this.parseObject(isConst);\n\n case TokenKind.INT:\n this._lexer.advance();\n\n return {\n kind: Kind.INT,\n value: token.value,\n loc: this.loc(token)\n };\n\n case TokenKind.FLOAT:\n this._lexer.advance();\n\n return {\n kind: Kind.FLOAT,\n value: token.value,\n loc: this.loc(token)\n };\n\n case TokenKind.STRING:\n case TokenKind.BLOCK_STRING:\n return this.parseStringLiteral();\n\n case TokenKind.NAME:\n this._lexer.advance();\n\n switch (token.value) {\n case 'true':\n return {\n kind: Kind.BOOLEAN,\n value: true,\n loc: this.loc(token)\n };\n\n case 'false':\n return {\n kind: Kind.BOOLEAN,\n value: false,\n loc: this.loc(token)\n };\n\n case 'null':\n return {\n kind: Kind.NULL,\n loc: this.loc(token)\n };\n\n default:\n return {\n kind: Kind.ENUM,\n value: token.value,\n loc: this.loc(token)\n };\n }\n\n case TokenKind.DOLLAR:\n if (!isConst) {\n return this.parseVariable();\n }\n\n break;\n }\n\n throw this.unexpected();\n }\n\n parseStringLiteral() {\n const token = this._lexer.token;\n\n this._lexer.advance();\n\n return {\n kind: Kind.STRING,\n value: token.value,\n block: token.kind === TokenKind.BLOCK_STRING,\n loc: this.loc(token)\n };\n }\n /**\n * ListValue[Const] :\n * - [ ]\n * - [ Value[?Const]+ ]\n */\n\n\n parseList(isConst) {\n const start = this._lexer.token;\n\n const item = () => this.parseValueLiteral(isConst);\n\n return {\n kind: Kind.LIST,\n values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R),\n loc: this.loc(start)\n };\n }\n /**\n * ObjectValue[Const] :\n * - { }\n * - { ObjectField[?Const]+ }\n */\n\n\n parseObject(isConst) {\n const start = this._lexer.token;\n\n const item = () => this.parseObjectField(isConst);\n\n return {\n kind: Kind.OBJECT,\n fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R),\n loc: this.loc(start)\n };\n }\n /**\n * ObjectField[Const] : Name : Value[?Const]\n */\n\n\n parseObjectField(isConst) {\n const start = this._lexer.token;\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n return {\n kind: Kind.OBJECT_FIELD,\n name,\n value: this.parseValueLiteral(isConst),\n loc: this.loc(start)\n };\n } // Implements the parsing rules in the Directives section.\n\n /**\n * Directives[Const] : Directive[?Const]+\n */\n\n\n parseDirectives(isConst) {\n const directives = [];\n\n while (this.peek(TokenKind.AT)) {\n directives.push(this.parseDirective(isConst));\n }\n\n return directives;\n }\n /**\n * Directive[Const] : @ Name Arguments[?Const]?\n */\n\n\n parseDirective(isConst) {\n const start = this._lexer.token;\n this.expectToken(TokenKind.AT);\n return {\n kind: Kind.DIRECTIVE,\n name: this.parseName(),\n arguments: this.parseArguments(isConst),\n loc: this.loc(start)\n };\n } // Implements the parsing rules in the Types section.\n\n /**\n * Type :\n * - NamedType\n * - ListType\n * - NonNullType\n */\n\n\n parseTypeReference() {\n const start = this._lexer.token;\n let type;\n\n if (this.expectOptionalToken(TokenKind.BRACKET_L)) {\n type = this.parseTypeReference();\n this.expectToken(TokenKind.BRACKET_R);\n type = {\n kind: Kind.LIST_TYPE,\n type,\n loc: this.loc(start)\n };\n } else {\n type = this.parseNamedType();\n }\n\n if (this.expectOptionalToken(TokenKind.BANG)) {\n return {\n kind: Kind.NON_NULL_TYPE,\n type,\n loc: this.loc(start)\n };\n }\n\n return type;\n }\n /**\n * NamedType : Name\n */\n\n\n parseNamedType() {\n const start = this._lexer.token;\n return {\n kind: Kind.NAMED_TYPE,\n name: this.parseName(),\n loc: this.loc(start)\n };\n } // Implements the parsing rules in the Type Definition section.\n\n /**\n * TypeSystemDefinition :\n * - SchemaDefinition\n * - TypeDefinition\n * - DirectiveDefinition\n *\n * TypeDefinition :\n * - ScalarTypeDefinition\n * - ObjectTypeDefinition\n * - InterfaceTypeDefinition\n * - UnionTypeDefinition\n * - EnumTypeDefinition\n * - InputObjectTypeDefinition\n */\n\n\n parseTypeSystemDefinition() {\n // Many definitions begin with a description and require a lookahead.\n const keywordToken = this.peekDescription() ? this._lexer.lookahead() : this._lexer.token;\n\n if (keywordToken.kind === TokenKind.NAME) {\n switch (keywordToken.value) {\n case 'schema':\n return this.parseSchemaDefinition();\n\n case 'scalar':\n return this.parseScalarTypeDefinition();\n\n case 'type':\n return this.parseObjectTypeDefinition();\n\n case 'interface':\n return this.parseInterfaceTypeDefinition();\n\n case 'union':\n return this.parseUnionTypeDefinition();\n\n case 'enum':\n return this.parseEnumTypeDefinition();\n\n case 'input':\n return this.parseInputObjectTypeDefinition();\n\n case 'directive':\n return this.parseDirectiveDefinition();\n }\n }\n\n throw this.unexpected(keywordToken);\n }\n\n peekDescription() {\n return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);\n }\n /**\n * Description : StringValue\n */\n\n\n parseDescription() {\n if (this.peekDescription()) {\n return this.parseStringLiteral();\n }\n }\n /**\n * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }\n */\n\n\n parseSchemaDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('schema');\n const directives = this.parseDirectives(true);\n const operationTypes = this.many(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);\n return {\n kind: Kind.SCHEMA_DEFINITION,\n description,\n directives,\n operationTypes,\n loc: this.loc(start)\n };\n }\n /**\n * OperationTypeDefinition : OperationType : NamedType\n */\n\n\n parseOperationTypeDefinition() {\n const start = this._lexer.token;\n const operation = this.parseOperationType();\n this.expectToken(TokenKind.COLON);\n const type = this.parseNamedType();\n return {\n kind: Kind.OPERATION_TYPE_DEFINITION,\n operation,\n type,\n loc: this.loc(start)\n };\n }\n /**\n * ScalarTypeDefinition : Description? scalar Name Directives[Const]?\n */\n\n\n parseScalarTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('scalar');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n return {\n kind: Kind.SCALAR_TYPE_DEFINITION,\n description,\n name,\n directives,\n loc: this.loc(start)\n };\n }\n /**\n * ObjectTypeDefinition :\n * Description?\n * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?\n */\n\n\n parseObjectTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('type');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseDirectives(true);\n const fields = this.parseFieldsDefinition();\n return {\n kind: Kind.OBJECT_TYPE_DEFINITION,\n description,\n name,\n interfaces,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * ImplementsInterfaces :\n * - implements `&`? NamedType\n * - ImplementsInterfaces & NamedType\n */\n\n\n parseImplementsInterfaces() {\n return this.expectOptionalKeyword('implements') ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];\n }\n /**\n * FieldsDefinition : { FieldDefinition+ }\n */\n\n\n parseFieldsDefinition() {\n return this.optionalMany(TokenKind.BRACE_L, this.parseFieldDefinition, TokenKind.BRACE_R);\n }\n /**\n * FieldDefinition :\n * - Description? Name ArgumentsDefinition? : Type Directives[Const]?\n */\n\n\n parseFieldDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n const args = this.parseArgumentDefs();\n this.expectToken(TokenKind.COLON);\n const type = this.parseTypeReference();\n const directives = this.parseDirectives(true);\n return {\n kind: Kind.FIELD_DEFINITION,\n description,\n name,\n arguments: args,\n type,\n directives,\n loc: this.loc(start)\n };\n }\n /**\n * ArgumentsDefinition : ( InputValueDefinition+ )\n */\n\n\n parseArgumentDefs() {\n return this.optionalMany(TokenKind.PAREN_L, this.parseInputValueDef, TokenKind.PAREN_R);\n }\n /**\n * InputValueDefinition :\n * - Description? Name : Type DefaultValue? Directives[Const]?\n */\n\n\n parseInputValueDef() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n const type = this.parseTypeReference();\n let defaultValue;\n\n if (this.expectOptionalToken(TokenKind.EQUALS)) {\n defaultValue = this.parseValueLiteral(true);\n }\n\n const directives = this.parseDirectives(true);\n return {\n kind: Kind.INPUT_VALUE_DEFINITION,\n description,\n name,\n type,\n defaultValue,\n directives,\n loc: this.loc(start)\n };\n }\n /**\n * InterfaceTypeDefinition :\n * - Description? interface Name Directives[Const]? FieldsDefinition?\n */\n\n\n parseInterfaceTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('interface');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseDirectives(true);\n const fields = this.parseFieldsDefinition();\n return {\n kind: Kind.INTERFACE_TYPE_DEFINITION,\n description,\n name,\n interfaces,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * UnionTypeDefinition :\n * - Description? union Name Directives[Const]? UnionMemberTypes?\n */\n\n\n parseUnionTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('union');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const types = this.parseUnionMemberTypes();\n return {\n kind: Kind.UNION_TYPE_DEFINITION,\n description,\n name,\n directives,\n types,\n loc: this.loc(start)\n };\n }\n /**\n * UnionMemberTypes :\n * - = `|`? NamedType\n * - UnionMemberTypes | NamedType\n */\n\n\n parseUnionMemberTypes() {\n return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];\n }\n /**\n * EnumTypeDefinition :\n * - Description? enum Name Directives[Const]? EnumValuesDefinition?\n */\n\n\n parseEnumTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('enum');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const values = this.parseEnumValuesDefinition();\n return {\n kind: Kind.ENUM_TYPE_DEFINITION,\n description,\n name,\n directives,\n values,\n loc: this.loc(start)\n };\n }\n /**\n * EnumValuesDefinition : { EnumValueDefinition+ }\n */\n\n\n parseEnumValuesDefinition() {\n return this.optionalMany(TokenKind.BRACE_L, this.parseEnumValueDefinition, TokenKind.BRACE_R);\n }\n /**\n * EnumValueDefinition : Description? EnumValue Directives[Const]?\n *\n * EnumValue : Name\n */\n\n\n parseEnumValueDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n return {\n kind: Kind.ENUM_VALUE_DEFINITION,\n description,\n name,\n directives,\n loc: this.loc(start)\n };\n }\n /**\n * InputObjectTypeDefinition :\n * - Description? input Name Directives[Const]? InputFieldsDefinition?\n */\n\n\n parseInputObjectTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('input');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const fields = this.parseInputFieldsDefinition();\n return {\n kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,\n description,\n name,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * InputFieldsDefinition : { InputValueDefinition+ }\n */\n\n\n parseInputFieldsDefinition() {\n return this.optionalMany(TokenKind.BRACE_L, this.parseInputValueDef, TokenKind.BRACE_R);\n }\n /**\n * TypeSystemExtension :\n * - SchemaExtension\n * - TypeExtension\n *\n * TypeExtension :\n * - ScalarTypeExtension\n * - ObjectTypeExtension\n * - InterfaceTypeExtension\n * - UnionTypeExtension\n * - EnumTypeExtension\n * - InputObjectTypeDefinition\n */\n\n\n parseTypeSystemExtension() {\n const keywordToken = this._lexer.lookahead();\n\n if (keywordToken.kind === TokenKind.NAME) {\n switch (keywordToken.value) {\n case 'schema':\n return this.parseSchemaExtension();\n\n case 'scalar':\n return this.parseScalarTypeExtension();\n\n case 'type':\n return this.parseObjectTypeExtension();\n\n case 'interface':\n return this.parseInterfaceTypeExtension();\n\n case 'union':\n return this.parseUnionTypeExtension();\n\n case 'enum':\n return this.parseEnumTypeExtension();\n\n case 'input':\n return this.parseInputObjectTypeExtension();\n }\n }\n\n throw this.unexpected(keywordToken);\n }\n /**\n * SchemaExtension :\n * - extend schema Directives[Const]? { OperationTypeDefinition+ }\n * - extend schema Directives[Const]\n */\n\n\n parseSchemaExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('schema');\n const directives = this.parseDirectives(true);\n const operationTypes = this.optionalMany(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);\n\n if (directives.length === 0 && operationTypes.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.SCHEMA_EXTENSION,\n directives,\n operationTypes,\n loc: this.loc(start)\n };\n }\n /**\n * ScalarTypeExtension :\n * - extend scalar Name Directives[Const]\n */\n\n\n parseScalarTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('scalar');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n\n if (directives.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.SCALAR_TYPE_EXTENSION,\n name,\n directives,\n loc: this.loc(start)\n };\n }\n /**\n * ObjectTypeExtension :\n * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition\n * - extend type Name ImplementsInterfaces? Directives[Const]\n * - extend type Name ImplementsInterfaces\n */\n\n\n parseObjectTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('type');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseDirectives(true);\n const fields = this.parseFieldsDefinition();\n\n if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.OBJECT_TYPE_EXTENSION,\n name,\n interfaces,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * InterfaceTypeExtension :\n * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition\n * - extend interface Name ImplementsInterfaces? Directives[Const]\n * - extend interface Name ImplementsInterfaces\n */\n\n\n parseInterfaceTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('interface');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseDirectives(true);\n const fields = this.parseFieldsDefinition();\n\n if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.INTERFACE_TYPE_EXTENSION,\n name,\n interfaces,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * UnionTypeExtension :\n * - extend union Name Directives[Const]? UnionMemberTypes\n * - extend union Name Directives[Const]\n */\n\n\n parseUnionTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('union');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const types = this.parseUnionMemberTypes();\n\n if (directives.length === 0 && types.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.UNION_TYPE_EXTENSION,\n name,\n directives,\n types,\n loc: this.loc(start)\n };\n }\n /**\n * EnumTypeExtension :\n * - extend enum Name Directives[Const]? EnumValuesDefinition\n * - extend enum Name Directives[Const]\n */\n\n\n parseEnumTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('enum');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const values = this.parseEnumValuesDefinition();\n\n if (directives.length === 0 && values.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.ENUM_TYPE_EXTENSION,\n name,\n directives,\n values,\n loc: this.loc(start)\n };\n }\n /**\n * InputObjectTypeExtension :\n * - extend input Name Directives[Const]? InputFieldsDefinition\n * - extend input Name Directives[Const]\n */\n\n\n parseInputObjectTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('input');\n const name = this.parseName();\n const directives = this.parseDirectives(true);\n const fields = this.parseInputFieldsDefinition();\n\n if (directives.length === 0 && fields.length === 0) {\n throw this.unexpected();\n }\n\n return {\n kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,\n name,\n directives,\n fields,\n loc: this.loc(start)\n };\n }\n /**\n * DirectiveDefinition :\n * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations\n */\n\n\n parseDirectiveDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('directive');\n this.expectToken(TokenKind.AT);\n const name = this.parseName();\n const args = this.parseArgumentDefs();\n const repeatable = this.expectOptionalKeyword('repeatable');\n this.expectKeyword('on');\n const locations = this.parseDirectiveLocations();\n return {\n kind: Kind.DIRECTIVE_DEFINITION,\n description,\n name,\n arguments: args,\n repeatable,\n locations,\n loc: this.loc(start)\n };\n }\n /**\n * DirectiveLocations :\n * - `|`? DirectiveLocation\n * - DirectiveLocations | DirectiveLocation\n */\n\n\n parseDirectiveLocations() {\n return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);\n }\n /*\n * DirectiveLocation :\n * - ExecutableDirectiveLocation\n * - TypeSystemDirectiveLocation\n *\n * ExecutableDirectiveLocation : one of\n * `QUERY`\n * `MUTATION`\n * `SUBSCRIPTION`\n * `FIELD`\n * `FRAGMENT_DEFINITION`\n * `FRAGMENT_SPREAD`\n * `INLINE_FRAGMENT`\n *\n * TypeSystemDirectiveLocation : one of\n * `SCHEMA`\n * `SCALAR`\n * `OBJECT`\n * `FIELD_DEFINITION`\n * `ARGUMENT_DEFINITION`\n * `INTERFACE`\n * `UNION`\n * `ENUM`\n * `ENUM_VALUE`\n * `INPUT_OBJECT`\n * `INPUT_FIELD_DEFINITION`\n */\n\n\n parseDirectiveLocation() {\n const start = this._lexer.token;\n const name = this.parseName();\n\n if (DirectiveLocation[name.value] !== undefined) {\n return name;\n }\n\n throw this.unexpected(start);\n } // Core parsing utility functions\n\n /**\n * Returns a location object, used to identify the place in the source that created a given parsed object.\n */\n\n\n loc(startToken) {\n if (this._options?.noLocation !== true) {\n return new Location(startToken, this._lexer.lastToken, this._lexer.source);\n }\n }\n /**\n * Determines if the next token is of a given kind\n */\n\n\n peek(kind) {\n return this._lexer.token.kind === kind;\n }\n /**\n * If the next token is of the given kind, return that token after advancing the lexer.\n * Otherwise, do not change the parser state and throw an error.\n */\n\n\n expectToken(kind) {\n const token = this._lexer.token;\n\n if (token.kind === kind) {\n this._lexer.advance();\n\n return token;\n }\n\n throw syntaxError(this._lexer.source, token.start, `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`);\n }\n /**\n * If the next token is of the given kind, return that token after advancing the lexer.\n * Otherwise, do not change the parser state and return undefined.\n */\n\n\n expectOptionalToken(kind) {\n const token = this._lexer.token;\n\n if (token.kind === kind) {\n this._lexer.advance();\n\n return token;\n }\n\n return undefined;\n }\n /**\n * If the next token is a given keyword, advance the lexer.\n * Otherwise, do not change the parser state and throw an error.\n */\n\n\n expectKeyword(value) {\n const token = this._lexer.token;\n\n if (token.kind === TokenKind.NAME && token.value === value) {\n this._lexer.advance();\n } else {\n throw syntaxError(this._lexer.source, token.start, `Expected \"${value}\", found ${getTokenDesc(token)}.`);\n }\n }\n /**\n * If the next token is a given keyword, return \"true\" after advancing the lexer.\n * Otherwise, do not change the parser state and return \"false\".\n */\n\n\n expectOptionalKeyword(value) {\n const token = this._lexer.token;\n\n if (token.kind === TokenKind.NAME && token.value === value) {\n this._lexer.advance();\n\n return true;\n }\n\n return false;\n }\n /**\n * Helper function for creating an error when an unexpected lexed token is encountered.\n */\n\n\n unexpected(atToken) {\n const token = atToken ?? this._lexer.token;\n return syntaxError(this._lexer.source, token.start, `Unexpected ${getTokenDesc(token)}.`);\n }\n /**\n * Returns a possibly empty list of parse nodes, determined by the parseFn.\n * This list begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n\n\n any(openKind, parseFn, closeKind) {\n this.expectToken(openKind);\n const nodes = [];\n\n while (!this.expectOptionalToken(closeKind)) {\n nodes.push(parseFn.call(this));\n }\n\n return nodes;\n }\n /**\n * Returns a list of parse nodes, determined by the parseFn.\n * It can be empty only if open token is missing otherwise it will always return non-empty list\n * that begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n\n\n optionalMany(openKind, parseFn, closeKind) {\n if (this.expectOptionalToken(openKind)) {\n const nodes = [];\n\n do {\n nodes.push(parseFn.call(this));\n } while (!this.expectOptionalToken(closeKind));\n\n return nodes;\n }\n\n return [];\n }\n /**\n * Returns a non-empty list of parse nodes, determined by the parseFn.\n * This list begins with a lex token of openKind and ends with a lex token of closeKind.\n * Advances the parser to the next lex token after the closing token.\n */\n\n\n many(openKind, parseFn, closeKind) {\n this.expectToken(openKind);\n const nodes = [];\n\n do {\n nodes.push(parseFn.call(this));\n } while (!this.expectOptionalToken(closeKind));\n\n return nodes;\n }\n /**\n * Returns a non-empty list of parse nodes, determined by the parseFn.\n * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.\n * Advances the parser to the next lex token after last item in the list.\n */\n\n\n delimitedMany(delimiterKind, parseFn) {\n this.expectOptionalToken(delimiterKind);\n const nodes = [];\n\n do {\n nodes.push(parseFn.call(this));\n } while (this.expectOptionalToken(delimiterKind));\n\n return nodes;\n }\n\n}\n/**\n * A helper function to describe a token as a string for debugging.\n */\n\nfunction getTokenDesc(token) {\n const value = token.value;\n return getTokenKindDesc(token.kind) + (value != null ? ` \"${value}\"` : '');\n}\n/**\n * A helper function to describe a token kind as a string for debugging.\n */\n\n\nfunction getTokenKindDesc(kind) {\n return isPunctuatorTokenKind(kind) ? `\"${kind}\"` : kind;\n}\n","import inspect from \"../jsutils/inspect.mjs\";\nimport { isNode } from \"./ast.mjs\";\n/**\n * A visitor is provided to visit, it contains the collection of\n * relevant functions to be called during the visitor's traversal.\n */\n\nexport const QueryDocumentKeys = {\n Name: [],\n Document: ['definitions'],\n OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'],\n VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],\n Variable: ['name'],\n SelectionSet: ['selections'],\n Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],\n Argument: ['name', 'value'],\n FragmentSpread: ['name', 'directives'],\n InlineFragment: ['typeCondition', 'directives', 'selectionSet'],\n FragmentDefinition: ['name', // Note: fragment variable definitions are experimental and may be changed\n // or removed in the future.\n 'variableDefinitions', 'typeCondition', 'directives', 'selectionSet'],\n IntValue: [],\n FloatValue: [],\n StringValue: [],\n BooleanValue: [],\n NullValue: [],\n EnumValue: [],\n ListValue: ['values'],\n ObjectValue: ['fields'],\n ObjectField: ['name', 'value'],\n Directive: ['name', 'arguments'],\n NamedType: ['name'],\n ListType: ['type'],\n NonNullType: ['type'],\n SchemaDefinition: ['description', 'directives', 'operationTypes'],\n OperationTypeDefinition: ['type'],\n ScalarTypeDefinition: ['description', 'name', 'directives'],\n ObjectTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],\n FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'],\n InputValueDefinition: ['description', 'name', 'type', 'defaultValue', 'directives'],\n InterfaceTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],\n UnionTypeDefinition: ['description', 'name', 'directives', 'types'],\n EnumTypeDefinition: ['description', 'name', 'directives', 'values'],\n EnumValueDefinition: ['description', 'name', 'directives'],\n InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],\n DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],\n SchemaExtension: ['directives', 'operationTypes'],\n ScalarTypeExtension: ['name', 'directives'],\n ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],\n InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],\n UnionTypeExtension: ['name', 'directives', 'types'],\n EnumTypeExtension: ['name', 'directives', 'values'],\n InputObjectTypeExtension: ['name', 'directives', 'fields']\n};\nexport const BREAK = Object.freeze({});\n/**\n * visit() will walk through an AST using a depth-first traversal, calling\n * the visitor's enter function at each node in the traversal, and calling the\n * leave function after visiting that node and all of its child nodes.\n *\n * By returning different values from the enter and leave functions, the\n * behavior of the visitor can be altered, including skipping over a sub-tree of\n * the AST (by returning false), editing the AST by returning a value or null\n * to remove the value, or to stop the whole traversal by returning BREAK.\n *\n * When using visit() to edit an AST, the original AST will not be modified, and\n * a new version of the AST with the changes applied will be returned from the\n * visit function.\n *\n * const editedAST = visit(ast, {\n * enter(node, key, parent, path, ancestors) {\n * // @return\n * // undefined: no action\n * // false: skip visiting this node\n * // visitor.BREAK: stop visiting altogether\n * // null: delete this node\n * // any value: replace this node with the returned value\n * },\n * leave(node, key, parent, path, ancestors) {\n * // @return\n * // undefined: no action\n * // false: no action\n * // visitor.BREAK: stop visiting altogether\n * // null: delete this node\n * // any value: replace this node with the returned value\n * }\n * });\n *\n * Alternatively to providing enter() and leave() functions, a visitor can\n * instead provide functions named the same as the kinds of AST nodes, or\n * enter/leave visitors at a named key, leading to four permutations of the\n * visitor API:\n *\n * 1) Named visitors triggered when entering a node of a specific kind.\n *\n * visit(ast, {\n * Kind(node) {\n * // enter the \"Kind\" node\n * }\n * })\n *\n * 2) Named visitors that trigger upon entering and leaving a node of\n * a specific kind.\n *\n * visit(ast, {\n * Kind: {\n * enter(node) {\n * // enter the \"Kind\" node\n * }\n * leave(node) {\n * // leave the \"Kind\" node\n * }\n * }\n * })\n *\n * 3) Generic visitors that trigger upon entering and leaving any node.\n *\n * visit(ast, {\n * enter(node) {\n * // enter any node\n * },\n * leave(node) {\n * // leave any node\n * }\n * })\n *\n * 4) Parallel visitors for entering and leaving nodes of a specific kind.\n *\n * visit(ast, {\n * enter: {\n * Kind(node) {\n * // enter the \"Kind\" node\n * }\n * },\n * leave: {\n * Kind(node) {\n * // leave the \"Kind\" node\n * }\n * }\n * })\n */\n\nexport function visit(root, visitor, visitorKeys = QueryDocumentKeys) {\n /* eslint-disable no-undef-init */\n let stack = undefined;\n let inArray = Array.isArray(root);\n let keys = [root];\n let index = -1;\n let edits = [];\n let node = undefined;\n let key = undefined;\n let parent = undefined;\n const path = [];\n const ancestors = [];\n let newRoot = root;\n /* eslint-enable no-undef-init */\n\n do {\n index++;\n const isLeaving = index === keys.length;\n const isEdited = isLeaving && edits.length !== 0;\n\n if (isLeaving) {\n key = ancestors.length === 0 ? undefined : path[path.length - 1];\n node = parent;\n parent = ancestors.pop();\n\n if (isEdited) {\n if (inArray) {\n node = node.slice();\n } else {\n const clone = {};\n\n for (const k of Object.keys(node)) {\n clone[k] = node[k];\n }\n\n node = clone;\n }\n\n let editOffset = 0;\n\n for (let ii = 0; ii < edits.length; ii++) {\n let editKey = edits[ii][0];\n const editValue = edits[ii][1];\n\n if (inArray) {\n editKey -= editOffset;\n }\n\n if (inArray && editValue === null) {\n node.splice(editKey, 1);\n editOffset++;\n } else {\n node[editKey] = editValue;\n }\n }\n }\n\n index = stack.index;\n keys = stack.keys;\n edits = stack.edits;\n inArray = stack.inArray;\n stack = stack.prev;\n } else {\n key = parent ? inArray ? index : keys[index] : undefined;\n node = parent ? parent[key] : newRoot;\n\n if (node === null || node === undefined) {\n continue;\n }\n\n if (parent) {\n path.push(key);\n }\n }\n\n let result;\n\n if (!Array.isArray(node)) {\n if (!isNode(node)) {\n throw new Error(`Invalid AST Node: ${inspect(node)}.`);\n }\n\n const visitFn = getVisitFn(visitor, node.kind, isLeaving);\n\n if (visitFn) {\n result = visitFn.call(visitor, node, key, parent, path, ancestors);\n\n if (result === BREAK) {\n break;\n }\n\n if (result === false) {\n if (!isLeaving) {\n path.pop();\n continue;\n }\n } else if (result !== undefined) {\n edits.push([key, result]);\n\n if (!isLeaving) {\n if (isNode(result)) {\n node = result;\n } else {\n path.pop();\n continue;\n }\n }\n }\n }\n }\n\n if (result === undefined && isEdited) {\n edits.push([key, node]);\n }\n\n if (isLeaving) {\n path.pop();\n } else {\n stack = {\n inArray,\n index,\n keys,\n edits,\n prev: stack\n };\n inArray = Array.isArray(node);\n keys = inArray ? node : visitorKeys[node.kind] ?? [];\n index = -1;\n edits = [];\n\n if (parent) {\n ancestors.push(parent);\n }\n\n parent = node;\n }\n } while (stack !== undefined);\n\n if (edits.length !== 0) {\n newRoot = edits[edits.length - 1][1];\n }\n\n return newRoot;\n}\n/**\n * Creates a new visitor instance which delegates to many visitors to run in\n * parallel. Each visitor will be visited for each node before moving on.\n *\n * If a prior visitor edits a node, no following visitors will see that node.\n */\n\nexport function visitInParallel(visitors) {\n const skipping = new Array(visitors.length);\n return {\n enter(node) {\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] == null) {\n const fn = getVisitFn(visitors[i], node.kind,\n /* isLeaving */\n false);\n\n if (fn) {\n const result = fn.apply(visitors[i], arguments);\n\n if (result === false) {\n skipping[i] = node;\n } else if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined) {\n return result;\n }\n }\n }\n }\n },\n\n leave(node) {\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] == null) {\n const fn = getVisitFn(visitors[i], node.kind,\n /* isLeaving */\n true);\n\n if (fn) {\n const result = fn.apply(visitors[i], arguments);\n\n if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined && result !== false) {\n return result;\n }\n }\n } else if (skipping[i] === node) {\n skipping[i] = null;\n }\n }\n }\n\n };\n}\n/**\n * Given a visitor instance, if it is leaving or not, and a node kind, return\n * the function the visitor runtime should call.\n */\n\nexport function getVisitFn(visitor, kind, isLeaving) {\n const kindVisitor = visitor[kind];\n\n if (kindVisitor) {\n if (!isLeaving && typeof kindVisitor === 'function') {\n // { Kind() {} }\n return kindVisitor;\n }\n\n const kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter;\n\n if (typeof kindSpecificVisitor === 'function') {\n // { Kind: { enter() {}, leave() {} } }\n return kindSpecificVisitor;\n }\n } else {\n const specificVisitor = isLeaving ? visitor.leave : visitor.enter;\n\n if (specificVisitor) {\n if (typeof specificVisitor === 'function') {\n // { enter() {}, leave() {} }\n return specificVisitor;\n }\n\n const specificKindVisitor = specificVisitor[kind];\n\n if (typeof specificKindVisitor === 'function') {\n // { enter: { Kind() {} }, leave: { Kind() {} } }\n return specificKindVisitor;\n }\n }\n }\n}\n","/* eslint-disable no-redeclare */\n// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441\nconst objectValues = Object.values || (obj => Object.keys(obj).map(key => obj[key]));\n\nexport default objectValues;\n","import devAssert from \"../jsutils/devAssert.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nconst NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;\n/**\n * Upholds the spec rules about naming.\n */\n\nexport function assertValidName(name) {\n const error = isValidNameError(name);\n\n if (error) {\n throw error;\n }\n\n return name;\n}\n/**\n * Returns an Error if a name is invalid.\n */\n\nexport function isValidNameError(name) {\n typeof name === 'string' || devAssert(0, 'Expected name to be a string.');\n\n if (name.length > 1 && name[0] === '_' && name[1] === '_') {\n return new GraphQLError(`Name \"${name}\" must not begin with \"__\", which is reserved by GraphQL introspection.`);\n }\n\n if (!NAME_RX.test(name)) {\n return new GraphQLError(`Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \"${name}\" does not.`);\n }\n}\n","/* eslint-disable no-redeclare */\n// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441\nconst objectEntries = Object.entries || (obj => Object.keys(obj).map(key => [key, obj[key]]));\n\nexport default objectEntries;\n","/**\n * Creates a keyed JS object from an array, given a function to produce the keys\n * for each value in the array.\n *\n * This provides a convenient lookup for the array items if the key function\n * produces unique results.\n *\n * const phoneBook = [\n * { name: 'Jon', num: '555-1234' },\n * { name: 'Jenny', num: '867-5309' }\n * ]\n *\n * // { Jon: { name: 'Jon', num: '555-1234' },\n * // Jenny: { name: 'Jenny', num: '867-5309' } }\n * const entriesByName = keyMap(\n * phoneBook,\n * entry => entry.name\n * )\n *\n * // { name: 'Jenny', num: '857-6309' }\n * const jennyEntry = entriesByName['Jenny']\n *\n */\nexport default function keyMap(list, keyFn) {\n return list.reduce((map, item) => {\n map[keyFn(item)] = item;\n return map;\n }, Object.create(null));\n}\n","import objectEntries from \"../polyfills/objectEntries.mjs\";\n\n/**\n * Creates an object map with the same keys as `map` and values generated by\n * running each value of `map` thru `fn`.\n */\nexport default function mapValue(map, fn) {\n const result = Object.create(null);\n\n for (const [key, value] of objectEntries(map)) {\n result[key] = fn(value, key);\n }\n\n return result;\n}\n","import objectEntries from \"../polyfills/objectEntries.mjs\";\nexport default function toObjMap(obj) {\n /* eslint-enable no-redeclare */\n if (Object.getPrototypeOf(obj) === null) {\n return obj;\n }\n\n const map = Object.create(null);\n\n for (const [key, value] of objectEntries(obj)) {\n map[key] = value;\n }\n\n return map;\n}\n","/**\n * Creates a keyed JS object from an array, given a function to produce the keys\n * and a function to produce the values from each item in the array.\n *\n * const phoneBook = [\n * { name: 'Jon', num: '555-1234' },\n * { name: 'Jenny', num: '867-5309' }\n * ]\n *\n * // { Jon: '555-1234', Jenny: '867-5309' }\n * const phonesByName = keyValMap(\n * phoneBook,\n * entry => entry.name,\n * entry => entry.num\n * )\n *\n */\nexport default function keyValMap(list, keyFn, valFn) {\n return list.reduce((map, item) => {\n map[keyFn(item)] = valFn(item);\n return map;\n }, Object.create(null));\n}\n","const MAX_SUGGESTIONS = 5;\n/**\n * Given [ A, B, C ] return ' Did you mean A, B, or C?'.\n */\n\n// eslint-disable-next-line no-redeclare\nexport default function didYouMean(firstArg, secondArg) {\n const [subMessage, suggestionsArg] = typeof firstArg === 'string' ? [firstArg, secondArg] : [undefined, firstArg];\n let message = ' Did you mean ';\n\n if (subMessage) {\n message += subMessage + ' ';\n }\n\n const suggestions = suggestionsArg.map(x => `\"${x}\"`);\n\n switch (suggestions.length) {\n case 0:\n return '';\n\n case 1:\n return message + suggestions[0] + '?';\n\n case 2:\n return message + suggestions[0] + ' or ' + suggestions[1] + '?';\n }\n\n const selected = suggestions.slice(0, MAX_SUGGESTIONS);\n const lastItem = selected.pop();\n return message + selected.join(', ') + ', or ' + lastItem + '?';\n}\n","/**\n * Returns the first argument it receives.\n */\nexport default function identityFunc(x) {\n return x;\n}\n","/**\n * Given an invalid input string and a list of valid options, returns a filtered\n * list of valid options sorted based on their similarity with the input.\n */\nexport default function suggestionList(input, options) {\n const optionsByDistance = Object.create(null);\n const lexicalDistance = new LexicalDistance(input);\n const threshold = Math.floor(input.length * 0.4) + 1;\n\n for (const option of options) {\n const distance = lexicalDistance.measure(option, threshold);\n\n if (distance !== undefined) {\n optionsByDistance[option] = distance;\n }\n }\n\n return Object.keys(optionsByDistance).sort((a, b) => {\n const distanceDiff = optionsByDistance[a] - optionsByDistance[b];\n return distanceDiff !== 0 ? distanceDiff : a.localeCompare(b);\n });\n}\n/**\n * Computes the lexical distance between strings A and B.\n *\n * The \"distance\" between two strings is given by counting the minimum number\n * of edits needed to transform string A into string B. An edit can be an\n * insertion, deletion, or substitution of a single character, or a swap of two\n * adjacent characters.\n *\n * Includes a custom alteration from Damerau-Levenshtein to treat case changes\n * as a single edit which helps identify mis-cased values with an edit distance\n * of 1.\n *\n * This distance can be useful for detecting typos in input or sorting\n */\n\nclass LexicalDistance {\n constructor(input) {\n this._input = input;\n this._inputLowerCase = input.toLowerCase();\n this._inputArray = stringToArray(this._inputLowerCase);\n this._rows = [new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0)];\n }\n\n measure(option, threshold) {\n if (this._input === option) {\n return 0;\n }\n\n const optionLowerCase = option.toLowerCase(); // Any case change counts as a single edit\n\n if (this._inputLowerCase === optionLowerCase) {\n return 1;\n }\n\n let a = stringToArray(optionLowerCase);\n let b = this._inputArray;\n\n if (a.length < b.length) {\n const tmp = a;\n a = b;\n b = tmp;\n }\n\n const aLength = a.length;\n const bLength = b.length;\n\n if (aLength - bLength > threshold) {\n return undefined;\n }\n\n const rows = this._rows;\n\n for (let j = 0; j <= bLength; j++) {\n rows[0][j] = j;\n }\n\n for (let i = 1; i <= aLength; i++) {\n const upRow = rows[(i - 1) % 3];\n const currentRow = rows[i % 3];\n let smallestCell = currentRow[0] = i;\n\n for (let j = 1; j <= bLength; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n let currentCell = Math.min(upRow[j] + 1, // delete\n currentRow[j - 1] + 1, // insert\n upRow[j - 1] + cost // substitute\n );\n\n if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {\n // transposition\n const doubleDiagonalCell = rows[(i - 2) % 3][j - 2];\n currentCell = Math.min(currentCell, doubleDiagonalCell + 1);\n }\n\n if (currentCell < smallestCell) {\n smallestCell = currentCell;\n }\n\n currentRow[j] = currentCell;\n } // Early exit, since distance can't go smaller than smallest element of the previous row.\n\n\n if (smallestCell > threshold) {\n return undefined;\n }\n }\n\n const distance = rows[aLength % 3][bLength];\n return distance <= threshold ? distance : undefined;\n }\n\n}\n\nfunction stringToArray(str) {\n const strLength = str.length;\n const array = new Array(strLength);\n\n for (let i = 0; i < strLength; ++i) {\n array[i] = str.charCodeAt(i);\n }\n\n return array;\n}\n","import { visit } from \"./visitor.mjs\";\nimport { printBlockString } from \"./blockString.mjs\";\n/**\n * Converts an AST into a string, using one set of reasonable\n * formatting rules.\n */\n\nexport function print(ast) {\n return visit(ast, {\n leave: printDocASTReducer\n });\n}\nconst MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future\n\nconst printDocASTReducer = {\n Name: node => node.value,\n Variable: node => '$' + node.name,\n // Document\n Document: node => join(node.definitions, '\\n\\n') + '\\n',\n\n OperationDefinition(node) {\n const op = node.operation;\n const name = node.name;\n const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');\n const directives = join(node.directives, ' ');\n const selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use\n // the query short form.\n\n return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');\n },\n\n VariableDefinition: ({\n variable,\n type,\n defaultValue,\n directives\n }) => variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' ')),\n SelectionSet: ({\n selections\n }) => block(selections),\n Field: ({\n alias,\n name,\n arguments: args,\n directives,\n selectionSet\n }) => {\n const prefix = wrap('', alias, ': ') + name;\n let argsLine = prefix + wrap('(', join(args, ', '), ')');\n\n if (argsLine.length > MAX_LINE_LENGTH) {\n argsLine = prefix + wrap('(\\n', indent(join(args, '\\n')), '\\n)');\n }\n\n return join([argsLine, join(directives, ' '), selectionSet], ' ');\n },\n Argument: ({\n name,\n value\n }) => name + ': ' + value,\n // Fragments\n FragmentSpread: ({\n name,\n directives\n }) => '...' + name + wrap(' ', join(directives, ' ')),\n InlineFragment: ({\n typeCondition,\n directives,\n selectionSet\n }) => join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' '),\n FragmentDefinition: ({\n name,\n typeCondition,\n variableDefinitions,\n directives,\n selectionSet\n }) => // Note: fragment variable definitions are experimental and may be changed\n // or removed in the future.\n `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` + `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` + selectionSet,\n // Value\n IntValue: ({\n value\n }) => value,\n FloatValue: ({\n value\n }) => value,\n StringValue: ({\n value,\n block: isBlockString\n }, key) => isBlockString ? printBlockString(value, key === 'description' ? '' : ' ') : JSON.stringify(value),\n BooleanValue: ({\n value\n }) => value ? 'true' : 'false',\n NullValue: () => 'null',\n EnumValue: ({\n value\n }) => value,\n ListValue: ({\n values\n }) => '[' + join(values, ', ') + ']',\n ObjectValue: ({\n fields\n }) => '{' + join(fields, ', ') + '}',\n ObjectField: ({\n name,\n value\n }) => name + ': ' + value,\n // Directive\n Directive: ({\n name,\n arguments: args\n }) => '@' + name + wrap('(', join(args, ', '), ')'),\n // Type\n NamedType: ({\n name\n }) => name,\n ListType: ({\n type\n }) => '[' + type + ']',\n NonNullType: ({\n type\n }) => type + '!',\n // Type System Definitions\n SchemaDefinition: addDescription(({\n directives,\n operationTypes\n }) => join(['schema', join(directives, ' '), block(operationTypes)], ' ')),\n OperationTypeDefinition: ({\n operation,\n type\n }) => operation + ': ' + type,\n ScalarTypeDefinition: addDescription(({\n name,\n directives\n }) => join(['scalar', name, join(directives, ' ')], ' ')),\n ObjectTypeDefinition: addDescription(({\n name,\n interfaces,\n directives,\n fields\n }) => join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ')),\n FieldDefinition: addDescription(({\n name,\n arguments: args,\n type,\n directives\n }) => name + (hasMultilineItems(args) ? wrap('(\\n', indent(join(args, '\\n')), '\\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '))),\n InputValueDefinition: addDescription(({\n name,\n type,\n defaultValue,\n directives\n }) => join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ')),\n InterfaceTypeDefinition: addDescription(({\n name,\n interfaces,\n directives,\n fields\n }) => join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ')),\n UnionTypeDefinition: addDescription(({\n name,\n directives,\n types\n }) => join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ')),\n EnumTypeDefinition: addDescription(({\n name,\n directives,\n values\n }) => join(['enum', name, join(directives, ' '), block(values)], ' ')),\n EnumValueDefinition: addDescription(({\n name,\n directives\n }) => join([name, join(directives, ' ')], ' ')),\n InputObjectTypeDefinition: addDescription(({\n name,\n directives,\n fields\n }) => join(['input', name, join(directives, ' '), block(fields)], ' ')),\n DirectiveDefinition: addDescription(({\n name,\n arguments: args,\n repeatable,\n locations\n }) => 'directive @' + name + (hasMultilineItems(args) ? wrap('(\\n', indent(join(args, '\\n')), '\\n)') : wrap('(', join(args, ', '), ')')) + (repeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | ')),\n SchemaExtension: ({\n directives,\n operationTypes\n }) => join(['extend schema', join(directives, ' '), block(operationTypes)], ' '),\n ScalarTypeExtension: ({\n name,\n directives\n }) => join(['extend scalar', name, join(directives, ' ')], ' '),\n ObjectTypeExtension: ({\n name,\n interfaces,\n directives,\n fields\n }) => join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),\n InterfaceTypeExtension: ({\n name,\n interfaces,\n directives,\n fields\n }) => join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),\n UnionTypeExtension: ({\n name,\n directives,\n types\n }) => join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' '),\n EnumTypeExtension: ({\n name,\n directives,\n values\n }) => join(['extend enum', name, join(directives, ' '), block(values)], ' '),\n InputObjectTypeExtension: ({\n name,\n directives,\n fields\n }) => join(['extend input', name, join(directives, ' '), block(fields)], ' ')\n};\n\nfunction addDescription(cb) {\n return node => join([node.description, cb(node)], '\\n');\n}\n/**\n * Given maybeArray, print an empty string if it is null or empty, otherwise\n * print all items together separated by separator if provided\n */\n\n\nfunction join(maybeArray, separator = '') {\n return maybeArray?.filter(x => x).join(separator) ?? '';\n}\n/**\n * Given array, print each item on its own line, wrapped in an\n * indented \"{ }\" block.\n */\n\n\nfunction block(array) {\n return wrap('{\\n', indent(join(array, '\\n')), '\\n}');\n}\n/**\n * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.\n */\n\n\nfunction wrap(start, maybeString, end = '') {\n return maybeString != null && maybeString !== '' ? start + maybeString + end : '';\n}\n\nfunction indent(str) {\n return wrap(' ', str.replace(/\\n/g, '\\n '));\n}\n\nfunction isMultiline(str) {\n return str.indexOf('\\n') !== -1;\n}\n\nfunction hasMultilineItems(maybeArray) {\n return maybeArray != null && maybeArray.some(isMultiline);\n}\n","export default function invariant(condition, message) {\n const booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')\n\n if (!booleanCondition) {\n throw new Error(message != null ? message : 'Unexpected invariant triggered.');\n }\n}\n","import inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport keyValMap from \"../jsutils/keyValMap.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\n\n/**\n * Produces a JavaScript value given a GraphQL Value AST.\n *\n * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value\n * will reflect the provided GraphQL value AST.\n *\n * | GraphQL Value | JavaScript Value |\n * | -------------------- | ---------------- |\n * | Input Object | Object |\n * | List | Array |\n * | Boolean | Boolean |\n * | String / Enum | String |\n * | Int / Float | Number |\n * | Null | null |\n *\n */\nexport function valueFromASTUntyped(valueNode, variables) {\n switch (valueNode.kind) {\n case Kind.NULL:\n return null;\n\n case Kind.INT:\n return parseInt(valueNode.value, 10);\n\n case Kind.FLOAT:\n return parseFloat(valueNode.value);\n\n case Kind.STRING:\n case Kind.ENUM:\n case Kind.BOOLEAN:\n return valueNode.value;\n\n case Kind.LIST:\n return valueNode.values.map(node => valueFromASTUntyped(node, variables));\n\n case Kind.OBJECT:\n return keyValMap(valueNode.fields, field => field.name.value, field => valueFromASTUntyped(field.value, variables));\n\n case Kind.VARIABLE:\n return variables?.[valueNode.name.value];\n } // istanbul ignore next (Not reachable. All possible value nodes have been considered)\n\n\n false || invariant(0, 'Unexpected value node: ' + inspect(valueNode));\n}\n","import objectEntries from \"../polyfills/objectEntries.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport keyMap from \"../jsutils/keyMap.mjs\";\nimport mapValue from \"../jsutils/mapValue.mjs\";\nimport toObjMap from \"../jsutils/toObjMap.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport keyValMap from \"../jsutils/keyValMap.mjs\";\nimport instanceOf from \"../jsutils/instanceOf.mjs\";\nimport didYouMean from \"../jsutils/didYouMean.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport identityFunc from \"../jsutils/identityFunc.mjs\";\nimport suggestionList from \"../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { print } from \"../language/printer.mjs\";\nimport { valueFromASTUntyped } from \"../utilities/valueFromASTUntyped.mjs\";\nexport function isType(type) {\n return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type) || isListType(type) || isNonNullType(type);\n}\nexport function assertType(type) {\n if (!isType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL type.`);\n }\n\n return type;\n}\n/**\n * There are predicates for each kind of GraphQL type.\n */\n\n// eslint-disable-next-line no-redeclare\nexport function isScalarType(type) {\n return instanceOf(type, GraphQLScalarType);\n}\nexport function assertScalarType(type) {\n if (!isScalarType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Scalar type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isObjectType(type) {\n return instanceOf(type, GraphQLObjectType);\n}\nexport function assertObjectType(type) {\n if (!isObjectType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Object type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isInterfaceType(type) {\n return instanceOf(type, GraphQLInterfaceType);\n}\nexport function assertInterfaceType(type) {\n if (!isInterfaceType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Interface type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isUnionType(type) {\n return instanceOf(type, GraphQLUnionType);\n}\nexport function assertUnionType(type) {\n if (!isUnionType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Union type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isEnumType(type) {\n return instanceOf(type, GraphQLEnumType);\n}\nexport function assertEnumType(type) {\n if (!isEnumType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Enum type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isInputObjectType(type) {\n return instanceOf(type, GraphQLInputObjectType);\n}\nexport function assertInputObjectType(type) {\n if (!isInputObjectType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Input Object type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isListType(type) {\n return instanceOf(type, GraphQLList);\n}\nexport function assertListType(type) {\n if (!isListType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL List type.`);\n }\n\n return type;\n}\n// eslint-disable-next-line no-redeclare\nexport function isNonNullType(type) {\n return instanceOf(type, GraphQLNonNull);\n}\nexport function assertNonNullType(type) {\n if (!isNonNullType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL Non-Null type.`);\n }\n\n return type;\n}\n/**\n * These types may be used as input types for arguments and directives.\n */\n\nexport function isInputType(type) {\n return isScalarType(type) || isEnumType(type) || isInputObjectType(type) || isWrappingType(type) && isInputType(type.ofType);\n}\nexport function assertInputType(type) {\n if (!isInputType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL input type.`);\n }\n\n return type;\n}\n/**\n * These types may be used as output types as the result of fields.\n */\n\nexport function isOutputType(type) {\n return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isWrappingType(type) && isOutputType(type.ofType);\n}\nexport function assertOutputType(type) {\n if (!isOutputType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL output type.`);\n }\n\n return type;\n}\n/**\n * These types may describe types which may be leaf values.\n */\n\nexport function isLeafType(type) {\n return isScalarType(type) || isEnumType(type);\n}\nexport function assertLeafType(type) {\n if (!isLeafType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL leaf type.`);\n }\n\n return type;\n}\n/**\n * These types may describe the parent context of a selection set.\n */\n\nexport function isCompositeType(type) {\n return isObjectType(type) || isInterfaceType(type) || isUnionType(type);\n}\nexport function assertCompositeType(type) {\n if (!isCompositeType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL composite type.`);\n }\n\n return type;\n}\n/**\n * These types may describe the parent context of a selection set.\n */\n\nexport function isAbstractType(type) {\n return isInterfaceType(type) || isUnionType(type);\n}\nexport function assertAbstractType(type) {\n if (!isAbstractType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL abstract type.`);\n }\n\n return type;\n}\n/**\n * List Type Wrapper\n *\n * A list is a wrapping type which points to another type.\n * Lists are often created within the context of defining the fields of\n * an object type.\n *\n * Example:\n *\n * const PersonType = new GraphQLObjectType({\n * name: 'Person',\n * fields: () => ({\n * parents: { type: new GraphQLList(PersonType) },\n * children: { type: new GraphQLList(PersonType) },\n * })\n * })\n *\n */\n\nexport class GraphQLList {\n constructor(ofType) {\n isType(ofType) || devAssert(0, `Expected ${inspect(ofType)} to be a GraphQL type.`);\n this.ofType = ofType;\n }\n\n toString() {\n return '[' + String(this.ofType) + ']';\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLList';\n }\n\n}\n/**\n * Non-Null Type Wrapper\n *\n * A non-null is a wrapping type which points to another type.\n * Non-null types enforce that their values are never null and can ensure\n * an error is raised if this ever occurs during a request. It is useful for\n * fields which you can make a strong guarantee on non-nullability, for example\n * usually the id field of a database row will never be null.\n *\n * Example:\n *\n * const RowType = new GraphQLObjectType({\n * name: 'Row',\n * fields: () => ({\n * id: { type: new GraphQLNonNull(GraphQLString) },\n * })\n * })\n *\n * Note: the enforcement of non-nullability occurs within the executor.\n */\n\nexport class GraphQLNonNull {\n constructor(ofType) {\n isNullableType(ofType) || devAssert(0, `Expected ${inspect(ofType)} to be a GraphQL nullable type.`);\n this.ofType = ofType;\n }\n\n toString() {\n return String(this.ofType) + '!';\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLNonNull';\n }\n\n}\n/**\n * These types wrap and modify other types\n */\n\nexport function isWrappingType(type) {\n return isListType(type) || isNonNullType(type);\n}\nexport function assertWrappingType(type) {\n if (!isWrappingType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL wrapping type.`);\n }\n\n return type;\n}\n/**\n * These types can all accept null as a value.\n */\n\nexport function isNullableType(type) {\n return isType(type) && !isNonNullType(type);\n}\nexport function assertNullableType(type) {\n if (!isNullableType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL nullable type.`);\n }\n\n return type;\n}\n/* eslint-disable no-redeclare */\n\nexport function getNullableType(type) {\n /* eslint-enable no-redeclare */\n if (type) {\n return isNonNullType(type) ? type.ofType : type;\n }\n}\n/**\n * These named types do not include modifiers like List or NonNull.\n */\n\nexport function isNamedType(type) {\n return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type);\n}\nexport function assertNamedType(type) {\n if (!isNamedType(type)) {\n throw new Error(`Expected ${inspect(type)} to be a GraphQL named type.`);\n }\n\n return type;\n}\n/* eslint-disable no-redeclare */\n\nexport function getNamedType(type) {\n /* eslint-enable no-redeclare */\n if (type) {\n let unwrappedType = type;\n\n while (isWrappingType(unwrappedType)) {\n unwrappedType = unwrappedType.ofType;\n }\n\n return unwrappedType;\n }\n}\n/**\n * Used while defining GraphQL types to allow for circular references in\n * otherwise immutable type definitions.\n */\n\nfunction resolveThunk(thunk) {\n // $FlowFixMe[incompatible-use]\n return typeof thunk === 'function' ? thunk() : thunk;\n}\n\nfunction undefineIfEmpty(arr) {\n return arr && arr.length > 0 ? arr : undefined;\n}\n/**\n * Scalar Type Definition\n *\n * The leaf values of any request and input values to arguments are\n * Scalars (or Enums) and are defined with a name and a series of functions\n * used to parse input from ast or variables and to ensure validity.\n *\n * If a type's serialize function does not return a value (i.e. it returns\n * `undefined`) then an error will be raised and a `null` value will be returned\n * in the response. If the serialize function returns `null`, then no error will\n * be included in the response.\n *\n * Example:\n *\n * const OddType = new GraphQLScalarType({\n * name: 'Odd',\n * serialize(value) {\n * if (value % 2 === 1) {\n * return value;\n * }\n * }\n * });\n *\n */\n\n\nexport class GraphQLScalarType {\n constructor(config) {\n const parseValue = config.parseValue ?? identityFunc;\n this.name = config.name;\n this.description = config.description;\n this.specifiedByUrl = config.specifiedByUrl;\n this.serialize = config.serialize ?? identityFunc;\n this.parseValue = parseValue;\n\n this.parseLiteral = config.parseLiteral ?? ((node, variables) => parseValue(valueFromASTUntyped(node, variables)));\n\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n config.specifiedByUrl == null || typeof config.specifiedByUrl === 'string' || devAssert(0, `${this.name} must provide \"specifiedByUrl\" as a string, ` + `but got: ${inspect(config.specifiedByUrl)}.`);\n config.serialize == null || typeof config.serialize === 'function' || devAssert(0, `${this.name} must provide \"serialize\" function. If this custom Scalar is also used as an input type, ensure \"parseValue\" and \"parseLiteral\" functions are also provided.`);\n\n if (config.parseLiteral) {\n typeof config.parseValue === 'function' && typeof config.parseLiteral === 'function' || devAssert(0, `${this.name} must provide both \"parseValue\" and \"parseLiteral\" functions.`);\n }\n }\n\n toConfig() {\n return {\n name: this.name,\n description: this.description,\n specifiedByUrl: this.specifiedByUrl,\n serialize: this.serialize,\n parseValue: this.parseValue,\n parseLiteral: this.parseLiteral,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLScalarType';\n }\n\n}\n\n/**\n * Object Type Definition\n *\n * Almost all of the GraphQL types you define will be object types. Object types\n * have a name, but most importantly describe their fields.\n *\n * Example:\n *\n * const AddressType = new GraphQLObjectType({\n * name: 'Address',\n * fields: {\n * street: { type: GraphQLString },\n * number: { type: GraphQLInt },\n * formatted: {\n * type: GraphQLString,\n * resolve(obj) {\n * return obj.number + ' ' + obj.street\n * }\n * }\n * }\n * });\n *\n * When two types need to refer to each other, or a type needs to refer to\n * itself in a field, you can use a function expression (aka a closure or a\n * thunk) to supply the fields lazily.\n *\n * Example:\n *\n * const PersonType = new GraphQLObjectType({\n * name: 'Person',\n * fields: () => ({\n * name: { type: GraphQLString },\n * bestFriend: { type: PersonType },\n * })\n * });\n *\n */\nexport class GraphQLObjectType {\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.isTypeOf = config.isTypeOf;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n this._fields = defineFieldMap.bind(undefined, config);\n this._interfaces = defineInterfaces.bind(undefined, config);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n config.isTypeOf == null || typeof config.isTypeOf === 'function' || devAssert(0, `${this.name} must provide \"isTypeOf\" as a function, ` + `but got: ${inspect(config.isTypeOf)}.`);\n }\n\n getFields() {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n\n return this._fields;\n }\n\n getInterfaces() {\n if (typeof this._interfaces === 'function') {\n this._interfaces = this._interfaces();\n }\n\n return this._interfaces;\n }\n\n toConfig() {\n return {\n name: this.name,\n description: this.description,\n interfaces: this.getInterfaces(),\n fields: fieldsToFieldsConfig(this.getFields()),\n isTypeOf: this.isTypeOf,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes || []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLObjectType';\n }\n\n}\n\nfunction defineInterfaces(config) {\n const interfaces = resolveThunk(config.interfaces) ?? [];\n Array.isArray(interfaces) || devAssert(0, `${config.name} interfaces must be an Array or a function which returns an Array.`);\n return interfaces;\n}\n\nfunction defineFieldMap(config) {\n const fieldMap = resolveThunk(config.fields);\n isPlainObj(fieldMap) || devAssert(0, `${config.name} fields must be an object with field names as keys or a function which returns such an object.`);\n return mapValue(fieldMap, (fieldConfig, fieldName) => {\n isPlainObj(fieldConfig) || devAssert(0, `${config.name}.${fieldName} field config must be an object.`);\n fieldConfig.resolve == null || typeof fieldConfig.resolve === 'function' || devAssert(0, `${config.name}.${fieldName} field resolver must be a function if ` + `provided, but got: ${inspect(fieldConfig.resolve)}.`);\n const argsConfig = fieldConfig.args ?? {};\n isPlainObj(argsConfig) || devAssert(0, `${config.name}.${fieldName} args must be an object with argument names as keys.`);\n const args = objectEntries(argsConfig).map(([argName, argConfig]) => ({\n name: argName,\n description: argConfig.description,\n type: argConfig.type,\n defaultValue: argConfig.defaultValue,\n deprecationReason: argConfig.deprecationReason,\n extensions: argConfig.extensions && toObjMap(argConfig.extensions),\n astNode: argConfig.astNode\n }));\n return {\n name: fieldName,\n description: fieldConfig.description,\n type: fieldConfig.type,\n args,\n resolve: fieldConfig.resolve,\n subscribe: fieldConfig.subscribe,\n deprecationReason: fieldConfig.deprecationReason,\n extensions: fieldConfig.extensions && toObjMap(fieldConfig.extensions),\n astNode: fieldConfig.astNode\n };\n });\n}\n\nfunction isPlainObj(obj) {\n return isObjectLike(obj) && !Array.isArray(obj);\n}\n\nfunction fieldsToFieldsConfig(fields) {\n return mapValue(fields, field => ({\n description: field.description,\n type: field.type,\n args: argsToArgsConfig(field.args),\n resolve: field.resolve,\n subscribe: field.subscribe,\n deprecationReason: field.deprecationReason,\n extensions: field.extensions,\n astNode: field.astNode\n }));\n}\n/**\n * @internal\n */\n\n\nexport function argsToArgsConfig(args) {\n return keyValMap(args, arg => arg.name, arg => ({\n description: arg.description,\n type: arg.type,\n defaultValue: arg.defaultValue,\n deprecationReason: arg.deprecationReason,\n extensions: arg.extensions,\n astNode: arg.astNode\n }));\n}\nexport function isRequiredArgument(arg) {\n return isNonNullType(arg.type) && arg.defaultValue === undefined;\n}\n\n/**\n * Interface Type Definition\n *\n * When a field can return one of a heterogeneous set of types, a Interface type\n * is used to describe what types are possible, what fields are in common across\n * all types, as well as a function to determine which type is actually used\n * when the field is resolved.\n *\n * Example:\n *\n * const EntityType = new GraphQLInterfaceType({\n * name: 'Entity',\n * fields: {\n * name: { type: GraphQLString }\n * }\n * });\n *\n */\nexport class GraphQLInterfaceType {\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.resolveType = config.resolveType;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n this._fields = defineFieldMap.bind(undefined, config);\n this._interfaces = defineInterfaces.bind(undefined, config);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n config.resolveType == null || typeof config.resolveType === 'function' || devAssert(0, `${this.name} must provide \"resolveType\" as a function, ` + `but got: ${inspect(config.resolveType)}.`);\n }\n\n getFields() {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n\n return this._fields;\n }\n\n getInterfaces() {\n if (typeof this._interfaces === 'function') {\n this._interfaces = this._interfaces();\n }\n\n return this._interfaces;\n }\n\n toConfig() {\n return {\n name: this.name,\n description: this.description,\n interfaces: this.getInterfaces(),\n fields: fieldsToFieldsConfig(this.getFields()),\n resolveType: this.resolveType,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLInterfaceType';\n }\n\n}\n\n/**\n * Union Type Definition\n *\n * When a field can return one of a heterogeneous set of types, a Union type\n * is used to describe what types are possible as well as providing a function\n * to determine which type is actually used when the field is resolved.\n *\n * Example:\n *\n * const PetType = new GraphQLUnionType({\n * name: 'Pet',\n * types: [ DogType, CatType ],\n * resolveType(value) {\n * if (value instanceof Dog) {\n * return DogType;\n * }\n * if (value instanceof Cat) {\n * return CatType;\n * }\n * }\n * });\n *\n */\nexport class GraphQLUnionType {\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.resolveType = config.resolveType;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n this._types = defineTypes.bind(undefined, config);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n config.resolveType == null || typeof config.resolveType === 'function' || devAssert(0, `${this.name} must provide \"resolveType\" as a function, ` + `but got: ${inspect(config.resolveType)}.`);\n }\n\n getTypes() {\n if (typeof this._types === 'function') {\n this._types = this._types();\n }\n\n return this._types;\n }\n\n toConfig() {\n return {\n name: this.name,\n description: this.description,\n types: this.getTypes(),\n resolveType: this.resolveType,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLUnionType';\n }\n\n}\n\nfunction defineTypes(config) {\n const types = resolveThunk(config.types);\n Array.isArray(types) || devAssert(0, `Must provide Array of types or a function which returns such an array for Union ${config.name}.`);\n return types;\n}\n\n/**\n * Enum Type Definition\n *\n * Some leaf values of requests and input values are Enums. GraphQL serializes\n * Enum values as strings, however internally Enums can be represented by any\n * kind of type, often integers.\n *\n * Example:\n *\n * const RGBType = new GraphQLEnumType({\n * name: 'RGB',\n * values: {\n * RED: { value: 0 },\n * GREEN: { value: 1 },\n * BLUE: { value: 2 }\n * }\n * });\n *\n * Note: If a value is not provided in a definition, the name of the enum value\n * will be used as its internal value.\n */\nexport class GraphQLEnumType\n/* */\n{\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n this._values = defineEnumValues(this.name, config.values);\n this._valueLookup = new Map(this._values.map(enumValue => [enumValue.value, enumValue]));\n this._nameLookup = keyMap(this._values, value => value.name);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n }\n\n getValues() {\n return this._values;\n }\n\n getValue(name) {\n return this._nameLookup[name];\n }\n\n serialize(outputValue) {\n const enumValue = this._valueLookup.get(outputValue);\n\n if (enumValue === undefined) {\n throw new GraphQLError(`Enum \"${this.name}\" cannot represent value: ${inspect(outputValue)}`);\n }\n\n return enumValue.name;\n }\n\n parseValue(inputValue)\n /* T */\n {\n if (typeof inputValue !== 'string') {\n const valueStr = inspect(inputValue);\n throw new GraphQLError(`Enum \"${this.name}\" cannot represent non-string value: ${valueStr}.` + didYouMeanEnumValue(this, valueStr));\n }\n\n const enumValue = this.getValue(inputValue);\n\n if (enumValue == null) {\n throw new GraphQLError(`Value \"${inputValue}\" does not exist in \"${this.name}\" enum.` + didYouMeanEnumValue(this, inputValue));\n }\n\n return enumValue.value;\n }\n\n parseLiteral(valueNode, _variables)\n /* T */\n {\n // Note: variables will be resolved to a value before calling this function.\n if (valueNode.kind !== Kind.ENUM) {\n const valueStr = print(valueNode);\n throw new GraphQLError(`Enum \"${this.name}\" cannot represent non-enum value: ${valueStr}.` + didYouMeanEnumValue(this, valueStr), valueNode);\n }\n\n const enumValue = this.getValue(valueNode.value);\n\n if (enumValue == null) {\n const valueStr = print(valueNode);\n throw new GraphQLError(`Value \"${valueStr}\" does not exist in \"${this.name}\" enum.` + didYouMeanEnumValue(this, valueStr), valueNode);\n }\n\n return enumValue.value;\n }\n\n toConfig() {\n const values = keyValMap(this.getValues(), value => value.name, value => ({\n description: value.description,\n value: value.value,\n deprecationReason: value.deprecationReason,\n extensions: value.extensions,\n astNode: value.astNode\n }));\n return {\n name: this.name,\n description: this.description,\n values,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLEnumType';\n }\n\n}\n\nfunction didYouMeanEnumValue(enumType, unknownValueStr) {\n const allNames = enumType.getValues().map(value => value.name);\n const suggestedValues = suggestionList(unknownValueStr, allNames);\n return didYouMean('the enum value', suggestedValues);\n}\n\nfunction defineEnumValues(typeName, valueMap) {\n isPlainObj(valueMap) || devAssert(0, `${typeName} values must be an object with value names as keys.`);\n return objectEntries(valueMap).map(([valueName, valueConfig]) => {\n isPlainObj(valueConfig) || devAssert(0, `${typeName}.${valueName} must refer to an object with a \"value\" key ` + `representing an internal value but got: ${inspect(valueConfig)}.`);\n return {\n name: valueName,\n description: valueConfig.description,\n value: valueConfig.value !== undefined ? valueConfig.value : valueName,\n deprecationReason: valueConfig.deprecationReason,\n extensions: valueConfig.extensions && toObjMap(valueConfig.extensions),\n astNode: valueConfig.astNode\n };\n });\n}\n\n/**\n * Input Object Type Definition\n *\n * An input object defines a structured collection of fields which may be\n * supplied to a field argument.\n *\n * Using `NonNull` will ensure that a value must be provided by the query\n *\n * Example:\n *\n * const GeoPoint = new GraphQLInputObjectType({\n * name: 'GeoPoint',\n * fields: {\n * lat: { type: new GraphQLNonNull(GraphQLFloat) },\n * lon: { type: new GraphQLNonNull(GraphQLFloat) },\n * alt: { type: GraphQLFloat, defaultValue: 0 },\n * }\n * });\n *\n */\nexport class GraphQLInputObjectType {\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);\n this._fields = defineInputFieldMap.bind(undefined, config);\n typeof config.name === 'string' || devAssert(0, 'Must provide name.');\n }\n\n getFields() {\n if (typeof this._fields === 'function') {\n this._fields = this._fields();\n }\n\n return this._fields;\n }\n\n toConfig() {\n const fields = mapValue(this.getFields(), field => ({\n description: field.description,\n type: field.type,\n defaultValue: field.defaultValue,\n extensions: field.extensions,\n astNode: field.astNode\n }));\n return {\n name: this.name,\n description: this.description,\n fields,\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? []\n };\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLInputObjectType';\n }\n\n}\n\nfunction defineInputFieldMap(config) {\n const fieldMap = resolveThunk(config.fields);\n isPlainObj(fieldMap) || devAssert(0, `${config.name} fields must be an object with field names as keys or a function which returns such an object.`);\n return mapValue(fieldMap, (fieldConfig, fieldName) => {\n !('resolve' in fieldConfig) || devAssert(0, `${config.name}.${fieldName} field has a resolve property, but Input Types cannot define resolvers.`);\n return {\n name: fieldName,\n description: fieldConfig.description,\n type: fieldConfig.type,\n defaultValue: fieldConfig.defaultValue,\n deprecationReason: fieldConfig.deprecationReason,\n extensions: fieldConfig.extensions && toObjMap(fieldConfig.extensions),\n astNode: fieldConfig.astNode\n };\n });\n}\n\nexport function isRequiredInputField(field) {\n return isNonNullType(field.type) && field.defaultValue === undefined;\n}\n","import { isInterfaceType, isObjectType, isListType, isNonNullType, isAbstractType } from \"../type/definition.mjs\";\n/**\n * Provided two types, return true if the types are equal (invariant).\n */\n\nexport function isEqualType(typeA, typeB) {\n // Equivalent types are equal.\n if (typeA === typeB) {\n return true;\n } // If either type is non-null, the other must also be non-null.\n\n\n if (isNonNullType(typeA) && isNonNullType(typeB)) {\n return isEqualType(typeA.ofType, typeB.ofType);\n } // If either type is a list, the other must also be a list.\n\n\n if (isListType(typeA) && isListType(typeB)) {\n return isEqualType(typeA.ofType, typeB.ofType);\n } // Otherwise the types are not equal.\n\n\n return false;\n}\n/**\n * Provided a type and a super type, return true if the first type is either\n * equal or a subset of the second super type (covariant).\n */\n\nexport function isTypeSubTypeOf(schema, maybeSubType, superType) {\n // Equivalent type is a valid subtype\n if (maybeSubType === superType) {\n return true;\n } // If superType is non-null, maybeSubType must also be non-null.\n\n\n if (isNonNullType(superType)) {\n if (isNonNullType(maybeSubType)) {\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);\n }\n\n return false;\n }\n\n if (isNonNullType(maybeSubType)) {\n // If superType is nullable, maybeSubType may be non-null or nullable.\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);\n } // If superType type is a list, maybeSubType type must also be a list.\n\n\n if (isListType(superType)) {\n if (isListType(maybeSubType)) {\n return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);\n }\n\n return false;\n }\n\n if (isListType(maybeSubType)) {\n // If superType is not a list, maybeSubType must also be not a list.\n return false;\n } // If superType type is an abstract type, check if it is super type of maybeSubType.\n // Otherwise, the child type is not a valid subtype of the parent type.\n\n\n return isAbstractType(superType) && (isInterfaceType(maybeSubType) || isObjectType(maybeSubType)) && schema.isSubType(superType, maybeSubType);\n}\n/**\n * Provided two composite types, determine if they \"overlap\". Two composite\n * types overlap when the Sets of possible concrete types for each intersect.\n *\n * This is often used to determine if a fragment of a given type could possibly\n * be visited in a context of another type.\n *\n * This function is commutative.\n */\n\nexport function doTypesOverlap(schema, typeA, typeB) {\n // Equivalent types overlap\n if (typeA === typeB) {\n return true;\n }\n\n if (isAbstractType(typeA)) {\n if (isAbstractType(typeB)) {\n // If both types are abstract, then determine if there is any intersection\n // between possible concrete types of each.\n return schema.getPossibleTypes(typeA).some(type => schema.isSubType(typeB, type));\n } // Determine if the latter type is a possible concrete type of the former.\n\n\n return schema.isSubType(typeA, typeB);\n }\n\n if (isAbstractType(typeB)) {\n // Determine if the former type is a possible concrete type of the latter.\n return schema.isSubType(typeB, typeA);\n } // Otherwise the types do not overlap.\n\n\n return false;\n}\n","import inspect from \"../jsutils/inspect.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { print } from \"../language/printer.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nimport { GraphQLScalarType } from \"./definition.mjs\"; // As per the GraphQL Spec, Integers are only treated as valid when a valid\n// 32-bit signed integer, providing the broadest support across platforms.\n//\n// n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because\n// they are internally represented as IEEE 754 doubles.\n\nconst MAX_INT = 2147483647;\nconst MIN_INT = -2147483648;\n\nfunction serializeInt(outputValue) {\n const coercedValue = serializeObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 1 : 0;\n }\n\n let num = coercedValue;\n\n if (typeof coercedValue === 'string' && coercedValue !== '') {\n num = Number(coercedValue);\n }\n\n if (typeof num !== 'number' || !Number.isInteger(num)) {\n throw new GraphQLError(`Int cannot represent non-integer value: ${inspect(coercedValue)}`);\n }\n\n if (num > MAX_INT || num < MIN_INT) {\n throw new GraphQLError('Int cannot represent non 32-bit signed integer value: ' + inspect(coercedValue));\n }\n\n return num;\n}\n\nfunction coerceInt(inputValue) {\n if (typeof inputValue !== 'number' || !Number.isInteger(inputValue)) {\n throw new GraphQLError(`Int cannot represent non-integer value: ${inspect(inputValue)}`);\n }\n\n if (inputValue > MAX_INT || inputValue < MIN_INT) {\n throw new GraphQLError(`Int cannot represent non 32-bit signed integer value: ${inputValue}`);\n }\n\n return inputValue;\n}\n\nexport const GraphQLInt = new GraphQLScalarType({\n name: 'Int',\n description: 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.',\n serialize: serializeInt,\n parseValue: coerceInt,\n\n parseLiteral(valueNode) {\n if (valueNode.kind !== Kind.INT) {\n throw new GraphQLError(`Int cannot represent non-integer value: ${print(valueNode)}`, valueNode);\n }\n\n const num = parseInt(valueNode.value, 10);\n\n if (num > MAX_INT || num < MIN_INT) {\n throw new GraphQLError(`Int cannot represent non 32-bit signed integer value: ${valueNode.value}`, valueNode);\n }\n\n return num;\n }\n\n});\n\nfunction serializeFloat(outputValue) {\n const coercedValue = serializeObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 1 : 0;\n }\n\n let num = coercedValue;\n\n if (typeof coercedValue === 'string' && coercedValue !== '') {\n num = Number(coercedValue);\n }\n\n if (typeof num !== 'number' || !Number.isFinite(num)) {\n throw new GraphQLError(`Float cannot represent non numeric value: ${inspect(coercedValue)}`);\n }\n\n return num;\n}\n\nfunction coerceFloat(inputValue) {\n if (typeof inputValue !== 'number' || !Number.isFinite(inputValue)) {\n throw new GraphQLError(`Float cannot represent non numeric value: ${inspect(inputValue)}`);\n }\n\n return inputValue;\n}\n\nexport const GraphQLFloat = new GraphQLScalarType({\n name: 'Float',\n description: 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).',\n serialize: serializeFloat,\n parseValue: coerceFloat,\n\n parseLiteral(valueNode) {\n if (valueNode.kind !== Kind.FLOAT && valueNode.kind !== Kind.INT) {\n throw new GraphQLError(`Float cannot represent non numeric value: ${print(valueNode)}`, valueNode);\n }\n\n return parseFloat(valueNode.value);\n }\n\n}); // Support serializing objects with custom valueOf() or toJSON() functions -\n// a common way to represent a complex value which can be represented as\n// a string (ex: MongoDB id objects).\n\nfunction serializeObject(outputValue) {\n if (isObjectLike(outputValue)) {\n if (typeof outputValue.valueOf === 'function') {\n const valueOfResult = outputValue.valueOf();\n\n if (!isObjectLike(valueOfResult)) {\n return valueOfResult;\n }\n }\n\n if (typeof outputValue.toJSON === 'function') {\n // $FlowFixMe[incompatible-use]\n return outputValue.toJSON();\n }\n }\n\n return outputValue;\n}\n\nfunction serializeString(outputValue) {\n const coercedValue = serializeObject(outputValue); // Serialize string, boolean and number values to a string, but do not\n // attempt to coerce object, function, symbol, or other types as strings.\n\n if (typeof coercedValue === 'string') {\n return coercedValue;\n }\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue ? 'true' : 'false';\n }\n\n if (typeof coercedValue === 'number' && Number.isFinite(coercedValue)) {\n return coercedValue.toString();\n }\n\n throw new GraphQLError(`String cannot represent value: ${inspect(outputValue)}`);\n}\n\nfunction coerceString(inputValue) {\n if (typeof inputValue !== 'string') {\n throw new GraphQLError(`String cannot represent a non string value: ${inspect(inputValue)}`);\n }\n\n return inputValue;\n}\n\nexport const GraphQLString = new GraphQLScalarType({\n name: 'String',\n description: 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.',\n serialize: serializeString,\n parseValue: coerceString,\n\n parseLiteral(valueNode) {\n if (valueNode.kind !== Kind.STRING) {\n throw new GraphQLError(`String cannot represent a non string value: ${print(valueNode)}`, valueNode);\n }\n\n return valueNode.value;\n }\n\n});\n\nfunction serializeBoolean(outputValue) {\n const coercedValue = serializeObject(outputValue);\n\n if (typeof coercedValue === 'boolean') {\n return coercedValue;\n }\n\n if (Number.isFinite(coercedValue)) {\n return coercedValue !== 0;\n }\n\n throw new GraphQLError(`Boolean cannot represent a non boolean value: ${inspect(coercedValue)}`);\n}\n\nfunction coerceBoolean(inputValue) {\n if (typeof inputValue !== 'boolean') {\n throw new GraphQLError(`Boolean cannot represent a non boolean value: ${inspect(inputValue)}`);\n }\n\n return inputValue;\n}\n\nexport const GraphQLBoolean = new GraphQLScalarType({\n name: 'Boolean',\n description: 'The `Boolean` scalar type represents `true` or `false`.',\n serialize: serializeBoolean,\n parseValue: coerceBoolean,\n\n parseLiteral(valueNode) {\n if (valueNode.kind !== Kind.BOOLEAN) {\n throw new GraphQLError(`Boolean cannot represent a non boolean value: ${print(valueNode)}`, valueNode);\n }\n\n return valueNode.value;\n }\n\n});\n\nfunction serializeID(outputValue) {\n const coercedValue = serializeObject(outputValue);\n\n if (typeof coercedValue === 'string') {\n return coercedValue;\n }\n\n if (Number.isInteger(coercedValue)) {\n return String(coercedValue);\n }\n\n throw new GraphQLError(`ID cannot represent value: ${inspect(outputValue)}`);\n}\n\nfunction coerceID(inputValue) {\n if (typeof inputValue === 'string') {\n return inputValue;\n }\n\n if (typeof inputValue === 'number' && Number.isInteger(inputValue)) {\n return inputValue.toString();\n }\n\n throw new GraphQLError(`ID cannot represent value: ${inspect(inputValue)}`);\n}\n\nexport const GraphQLID = new GraphQLScalarType({\n name: 'ID',\n description: '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.',\n serialize: serializeID,\n parseValue: coerceID,\n\n parseLiteral(valueNode) {\n if (valueNode.kind !== Kind.STRING && valueNode.kind !== Kind.INT) {\n throw new GraphQLError('ID cannot represent a non-string and non-integer value: ' + print(valueNode), valueNode);\n }\n\n return valueNode.value;\n }\n\n});\nexport const specifiedScalarTypes = Object.freeze([GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLID]);\nexport function isSpecifiedScalarType(type) {\n return specifiedScalarTypes.some(({\n name\n }) => type.name === name);\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport isCollection from \"../jsutils/isCollection.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { GraphQLID } from \"../type/scalars.mjs\";\nimport { isLeafType, isEnumType, isInputObjectType, isListType, isNonNullType } from \"../type/definition.mjs\";\n/**\n * Produces a GraphQL Value AST given a JavaScript object.\n * Function will match JavaScript/JSON values to GraphQL AST schema format\n * by using suggested GraphQLInputType. For example:\n *\n * astFromValue(\"value\", GraphQLString)\n *\n * A GraphQL type must be provided, which will be used to interpret different\n * JavaScript values.\n *\n * | JSON Value | GraphQL Value |\n * | ------------- | -------------------- |\n * | Object | Input Object |\n * | Array | List |\n * | Boolean | Boolean |\n * | String | String / Enum Value |\n * | Number | Int / Float |\n * | Mixed | Enum Value |\n * | null | NullValue |\n *\n */\n\nexport function astFromValue(value, type) {\n if (isNonNullType(type)) {\n const astValue = astFromValue(value, type.ofType);\n\n if (astValue?.kind === Kind.NULL) {\n return null;\n }\n\n return astValue;\n } // only explicit null, not undefined, NaN\n\n\n if (value === null) {\n return {\n kind: Kind.NULL\n };\n } // undefined\n\n\n if (value === undefined) {\n return null;\n } // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but\n // the value is not an array, convert the value using the list's item type.\n\n\n if (isListType(type)) {\n const itemType = type.ofType;\n\n if (isCollection(value)) {\n const valuesNodes = []; // Since we transpile for-of in loose mode it doesn't support iterators\n // and it's required to first convert iteratable into array\n\n for (const item of Array.from(value)) {\n const itemNode = astFromValue(item, itemType);\n\n if (itemNode != null) {\n valuesNodes.push(itemNode);\n }\n }\n\n return {\n kind: Kind.LIST,\n values: valuesNodes\n };\n }\n\n return astFromValue(value, itemType);\n } // Populate the fields of the input object by creating ASTs from each value\n // in the JavaScript object according to the fields in the input type.\n\n\n if (isInputObjectType(type)) {\n if (!isObjectLike(value)) {\n return null;\n }\n\n const fieldNodes = [];\n\n for (const field of objectValues(type.getFields())) {\n const fieldValue = astFromValue(value[field.name], field.type);\n\n if (fieldValue) {\n fieldNodes.push({\n kind: Kind.OBJECT_FIELD,\n name: {\n kind: Kind.NAME,\n value: field.name\n },\n value: fieldValue\n });\n }\n }\n\n return {\n kind: Kind.OBJECT,\n fields: fieldNodes\n };\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isLeafType(type)) {\n // Since value is an internally represented value, it must be serialized\n // to an externally represented value before converting into an AST.\n const serialized = type.serialize(value);\n\n if (serialized == null) {\n return null;\n } // Others serialize based on their corresponding JavaScript scalar types.\n\n\n if (typeof serialized === 'boolean') {\n return {\n kind: Kind.BOOLEAN,\n value: serialized\n };\n } // JavaScript numbers can be Int or Float values.\n\n\n if (typeof serialized === 'number' && Number.isFinite(serialized)) {\n const stringNum = String(serialized);\n return integerStringRegExp.test(stringNum) ? {\n kind: Kind.INT,\n value: stringNum\n } : {\n kind: Kind.FLOAT,\n value: stringNum\n };\n }\n\n if (typeof serialized === 'string') {\n // Enum types use Enum literals.\n if (isEnumType(type)) {\n return {\n kind: Kind.ENUM,\n value: serialized\n };\n } // ID types can use Int literals.\n\n\n if (type === GraphQLID && integerStringRegExp.test(serialized)) {\n return {\n kind: Kind.INT,\n value: serialized\n };\n }\n\n return {\n kind: Kind.STRING,\n value: serialized\n };\n }\n\n throw new TypeError(`Cannot convert value to AST: ${inspect(serialized)}.`);\n } // istanbul ignore next (Not reachable. All possible input types have been considered)\n\n\n false || invariant(0, 'Unexpected input type: ' + inspect(type));\n}\n/**\n * IntValue:\n * - NegativeSign? 0\n * - NegativeSign? NonZeroDigit ( Digit+ )?\n */\n\nconst integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/;\n","/**\n * Returns true if the provided object is an Object (i.e. not a string literal)\n * and is either Iterable or Array-like.\n *\n * This may be used in place of [Array.isArray()][isArray] to determine if an\n * object should be iterated-over. It always excludes string literals and\n * includes Arrays (regardless of if it is Iterable). It also includes other\n * Array-like objects such as NodeList, TypedArray, and Buffer.\n *\n * @example\n *\n * isCollection([ 1, 2, 3 ]) // true\n * isCollection('ABC') // false\n * isCollection({ length: 1, 0: 'Alpha' }) // true\n * isCollection({ key: 'value' }) // false\n * isCollection(new Map()) // true\n *\n * @param obj\n * An Object value which might implement the Iterable or Array-like protocols.\n * @return {boolean} true if Iterable or Array-like Object.\n */\n// eslint-disable-next-line no-redeclare\nexport default function isCollection(obj) {\n if (obj == null || typeof obj !== 'object') {\n return false;\n } // Is Array like?\n\n\n const length = obj.length;\n\n if (typeof length === 'number' && length >= 0 && length % 1 === 0) {\n return true;\n } // Is Iterable?\n\n\n return typeof obj[Symbol.iterator] === 'function';\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport { print } from \"../language/printer.mjs\";\nimport { DirectiveLocation } from \"../language/directiveLocation.mjs\";\nimport { astFromValue } from \"../utilities/astFromValue.mjs\";\nimport { GraphQLString, GraphQLBoolean } from \"./scalars.mjs\";\nimport { GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLEnumType, isScalarType, isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isListType, isNonNullType, isAbstractType } from \"./definition.mjs\";\nexport const __Schema = new GraphQLObjectType({\n name: '__Schema',\n description: 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.',\n fields: () => ({\n description: {\n type: GraphQLString,\n resolve: schema => schema.description\n },\n types: {\n description: 'A list of all types supported by this server.',\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Type))),\n\n resolve(schema) {\n return objectValues(schema.getTypeMap());\n }\n\n },\n queryType: {\n description: 'The type that query operations will be rooted at.',\n type: new GraphQLNonNull(__Type),\n resolve: schema => schema.getQueryType()\n },\n mutationType: {\n description: 'If this server supports mutation, the type that mutation operations will be rooted at.',\n type: __Type,\n resolve: schema => schema.getMutationType()\n },\n subscriptionType: {\n description: 'If this server support subscription, the type that subscription operations will be rooted at.',\n type: __Type,\n resolve: schema => schema.getSubscriptionType()\n },\n directives: {\n description: 'A list of all directives supported by this server.',\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Directive))),\n resolve: schema => schema.getDirectives()\n }\n })\n});\nexport const __Directive = new GraphQLObjectType({\n name: '__Directive',\n description: \"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\\n\\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.\",\n fields: () => ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: directive => directive.name\n },\n description: {\n type: GraphQLString,\n resolve: directive => directive.description\n },\n isRepeatable: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: directive => directive.isRepeatable\n },\n locations: {\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__DirectiveLocation))),\n resolve: directive => directive.locations\n },\n args: {\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__InputValue))),\n resolve: directive => directive.args\n }\n })\n});\nexport const __DirectiveLocation = new GraphQLEnumType({\n name: '__DirectiveLocation',\n description: 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.',\n values: {\n QUERY: {\n value: DirectiveLocation.QUERY,\n description: 'Location adjacent to a query operation.'\n },\n MUTATION: {\n value: DirectiveLocation.MUTATION,\n description: 'Location adjacent to a mutation operation.'\n },\n SUBSCRIPTION: {\n value: DirectiveLocation.SUBSCRIPTION,\n description: 'Location adjacent to a subscription operation.'\n },\n FIELD: {\n value: DirectiveLocation.FIELD,\n description: 'Location adjacent to a field.'\n },\n FRAGMENT_DEFINITION: {\n value: DirectiveLocation.FRAGMENT_DEFINITION,\n description: 'Location adjacent to a fragment definition.'\n },\n FRAGMENT_SPREAD: {\n value: DirectiveLocation.FRAGMENT_SPREAD,\n description: 'Location adjacent to a fragment spread.'\n },\n INLINE_FRAGMENT: {\n value: DirectiveLocation.INLINE_FRAGMENT,\n description: 'Location adjacent to an inline fragment.'\n },\n VARIABLE_DEFINITION: {\n value: DirectiveLocation.VARIABLE_DEFINITION,\n description: 'Location adjacent to a variable definition.'\n },\n SCHEMA: {\n value: DirectiveLocation.SCHEMA,\n description: 'Location adjacent to a schema definition.'\n },\n SCALAR: {\n value: DirectiveLocation.SCALAR,\n description: 'Location adjacent to a scalar definition.'\n },\n OBJECT: {\n value: DirectiveLocation.OBJECT,\n description: 'Location adjacent to an object type definition.'\n },\n FIELD_DEFINITION: {\n value: DirectiveLocation.FIELD_DEFINITION,\n description: 'Location adjacent to a field definition.'\n },\n ARGUMENT_DEFINITION: {\n value: DirectiveLocation.ARGUMENT_DEFINITION,\n description: 'Location adjacent to an argument definition.'\n },\n INTERFACE: {\n value: DirectiveLocation.INTERFACE,\n description: 'Location adjacent to an interface definition.'\n },\n UNION: {\n value: DirectiveLocation.UNION,\n description: 'Location adjacent to a union definition.'\n },\n ENUM: {\n value: DirectiveLocation.ENUM,\n description: 'Location adjacent to an enum definition.'\n },\n ENUM_VALUE: {\n value: DirectiveLocation.ENUM_VALUE,\n description: 'Location adjacent to an enum value definition.'\n },\n INPUT_OBJECT: {\n value: DirectiveLocation.INPUT_OBJECT,\n description: 'Location adjacent to an input object type definition.'\n },\n INPUT_FIELD_DEFINITION: {\n value: DirectiveLocation.INPUT_FIELD_DEFINITION,\n description: 'Location adjacent to an input object field definition.'\n }\n }\n});\nexport const __Type = new GraphQLObjectType({\n name: '__Type',\n description: 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\\n\\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByUrl`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.',\n fields: () => ({\n kind: {\n type: new GraphQLNonNull(__TypeKind),\n\n resolve(type) {\n if (isScalarType(type)) {\n return TypeKind.SCALAR;\n }\n\n if (isObjectType(type)) {\n return TypeKind.OBJECT;\n }\n\n if (isInterfaceType(type)) {\n return TypeKind.INTERFACE;\n }\n\n if (isUnionType(type)) {\n return TypeKind.UNION;\n }\n\n if (isEnumType(type)) {\n return TypeKind.ENUM;\n }\n\n if (isInputObjectType(type)) {\n return TypeKind.INPUT_OBJECT;\n }\n\n if (isListType(type)) {\n return TypeKind.LIST;\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isNonNullType(type)) {\n return TypeKind.NON_NULL;\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, `Unexpected type: \"${inspect(type)}\".`);\n }\n\n },\n name: {\n type: GraphQLString,\n resolve: type => type.name !== undefined ? type.name : undefined\n },\n description: {\n type: GraphQLString,\n resolve: type => type.description !== undefined ? type.description : undefined\n },\n specifiedByUrl: {\n type: GraphQLString,\n resolve: obj => obj.specifiedByUrl !== undefined ? obj.specifiedByUrl : undefined\n },\n fields: {\n type: new GraphQLList(new GraphQLNonNull(__Field)),\n args: {\n includeDeprecated: {\n type: GraphQLBoolean,\n defaultValue: false\n }\n },\n\n resolve(type, {\n includeDeprecated\n }) {\n if (isObjectType(type) || isInterfaceType(type)) {\n const fields = objectValues(type.getFields());\n return includeDeprecated ? fields : fields.filter(field => field.deprecationReason == null);\n }\n }\n\n },\n interfaces: {\n type: new GraphQLList(new GraphQLNonNull(__Type)),\n\n resolve(type) {\n if (isObjectType(type) || isInterfaceType(type)) {\n return type.getInterfaces();\n }\n }\n\n },\n possibleTypes: {\n type: new GraphQLList(new GraphQLNonNull(__Type)),\n\n resolve(type, _args, _context, {\n schema\n }) {\n if (isAbstractType(type)) {\n return schema.getPossibleTypes(type);\n }\n }\n\n },\n enumValues: {\n type: new GraphQLList(new GraphQLNonNull(__EnumValue)),\n args: {\n includeDeprecated: {\n type: GraphQLBoolean,\n defaultValue: false\n }\n },\n\n resolve(type, {\n includeDeprecated\n }) {\n if (isEnumType(type)) {\n const values = type.getValues();\n return includeDeprecated ? values : values.filter(field => field.deprecationReason == null);\n }\n }\n\n },\n inputFields: {\n type: new GraphQLList(new GraphQLNonNull(__InputValue)),\n args: {\n includeDeprecated: {\n type: GraphQLBoolean,\n defaultValue: false\n }\n },\n\n resolve(type, {\n includeDeprecated\n }) {\n if (isInputObjectType(type)) {\n const values = objectValues(type.getFields());\n return includeDeprecated ? values : values.filter(field => field.deprecationReason == null);\n }\n }\n\n },\n ofType: {\n type: __Type,\n resolve: type => type.ofType !== undefined ? type.ofType : undefined\n }\n })\n});\nexport const __Field = new GraphQLObjectType({\n name: '__Field',\n description: 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.',\n fields: () => ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: field => field.name\n },\n description: {\n type: GraphQLString,\n resolve: field => field.description\n },\n args: {\n type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__InputValue))),\n args: {\n includeDeprecated: {\n type: GraphQLBoolean,\n defaultValue: false\n }\n },\n\n resolve(field, {\n includeDeprecated\n }) {\n return includeDeprecated ? field.args : field.args.filter(arg => arg.deprecationReason == null);\n }\n\n },\n type: {\n type: new GraphQLNonNull(__Type),\n resolve: field => field.type\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: field => field.deprecationReason != null\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: field => field.deprecationReason\n }\n })\n});\nexport const __InputValue = new GraphQLObjectType({\n name: '__InputValue',\n description: 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.',\n fields: () => ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: inputValue => inputValue.name\n },\n description: {\n type: GraphQLString,\n resolve: inputValue => inputValue.description\n },\n type: {\n type: new GraphQLNonNull(__Type),\n resolve: inputValue => inputValue.type\n },\n defaultValue: {\n type: GraphQLString,\n description: 'A GraphQL-formatted string representing the default value for this input value.',\n\n resolve(inputValue) {\n const {\n type,\n defaultValue\n } = inputValue;\n const valueAST = astFromValue(defaultValue, type);\n return valueAST ? print(valueAST) : null;\n }\n\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: field => field.deprecationReason != null\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: obj => obj.deprecationReason\n }\n })\n});\nexport const __EnumValue = new GraphQLObjectType({\n name: '__EnumValue',\n description: 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.',\n fields: () => ({\n name: {\n type: new GraphQLNonNull(GraphQLString),\n resolve: enumValue => enumValue.name\n },\n description: {\n type: GraphQLString,\n resolve: enumValue => enumValue.description\n },\n isDeprecated: {\n type: new GraphQLNonNull(GraphQLBoolean),\n resolve: enumValue => enumValue.deprecationReason != null\n },\n deprecationReason: {\n type: GraphQLString,\n resolve: enumValue => enumValue.deprecationReason\n }\n })\n});\nexport const TypeKind = Object.freeze({\n SCALAR: 'SCALAR',\n OBJECT: 'OBJECT',\n INTERFACE: 'INTERFACE',\n UNION: 'UNION',\n ENUM: 'ENUM',\n INPUT_OBJECT: 'INPUT_OBJECT',\n LIST: 'LIST',\n NON_NULL: 'NON_NULL'\n});\nexport const __TypeKind = new GraphQLEnumType({\n name: '__TypeKind',\n description: 'An enum describing what kind of type a given `__Type` is.',\n values: {\n SCALAR: {\n value: TypeKind.SCALAR,\n description: 'Indicates this type is a scalar.'\n },\n OBJECT: {\n value: TypeKind.OBJECT,\n description: 'Indicates this type is an object. `fields` and `interfaces` are valid fields.'\n },\n INTERFACE: {\n value: TypeKind.INTERFACE,\n description: 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.'\n },\n UNION: {\n value: TypeKind.UNION,\n description: 'Indicates this type is a union. `possibleTypes` is a valid field.'\n },\n ENUM: {\n value: TypeKind.ENUM,\n description: 'Indicates this type is an enum. `enumValues` is a valid field.'\n },\n INPUT_OBJECT: {\n value: TypeKind.INPUT_OBJECT,\n description: 'Indicates this type is an input object. `inputFields` is a valid field.'\n },\n LIST: {\n value: TypeKind.LIST,\n description: 'Indicates this type is a list. `ofType` is a valid field.'\n },\n NON_NULL: {\n value: TypeKind.NON_NULL,\n description: 'Indicates this type is a non-null. `ofType` is a valid field.'\n }\n }\n});\n/**\n * Note that these are GraphQLField and not GraphQLFieldConfig,\n * so the format for args is different.\n */\n\nexport const SchemaMetaFieldDef = {\n name: '__schema',\n type: new GraphQLNonNull(__Schema),\n description: 'Access the current type schema of this server.',\n args: [],\n resolve: (_source, _args, _context, {\n schema\n }) => schema,\n deprecationReason: undefined,\n extensions: undefined,\n astNode: undefined\n};\nexport const TypeMetaFieldDef = {\n name: '__type',\n type: __Type,\n description: 'Request the type information of a single type.',\n args: [{\n name: 'name',\n description: undefined,\n type: new GraphQLNonNull(GraphQLString),\n defaultValue: undefined,\n deprecationReason: undefined,\n extensions: undefined,\n astNode: undefined\n }],\n resolve: (_source, {\n name\n }, _context, {\n schema\n }) => schema.getType(name),\n deprecationReason: undefined,\n extensions: undefined,\n astNode: undefined\n};\nexport const TypeNameMetaFieldDef = {\n name: '__typename',\n type: new GraphQLNonNull(GraphQLString),\n description: 'The name of the current Object type at runtime.',\n args: [],\n resolve: (_source, _args, _context, {\n parentType\n }) => parentType.name,\n deprecationReason: undefined,\n extensions: undefined,\n astNode: undefined\n};\nexport const introspectionTypes = Object.freeze([__Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind]);\nexport function isIntrospectionType(type) {\n return introspectionTypes.some(({\n name\n }) => type.name === name);\n}\n","import objectEntries from \"../polyfills/objectEntries.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport toObjMap from \"../jsutils/toObjMap.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport instanceOf from \"../jsutils/instanceOf.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport { DirectiveLocation } from \"../language/directiveLocation.mjs\";\nimport { GraphQLString, GraphQLBoolean } from \"./scalars.mjs\";\nimport { argsToArgsConfig, GraphQLNonNull } from \"./definition.mjs\";\n/**\n * Test if the given value is a GraphQL directive.\n */\n\n// eslint-disable-next-line no-redeclare\nexport function isDirective(directive) {\n return instanceOf(directive, GraphQLDirective);\n}\nexport function assertDirective(directive) {\n if (!isDirective(directive)) {\n throw new Error(`Expected ${inspect(directive)} to be a GraphQL directive.`);\n }\n\n return directive;\n}\n/**\n * Directives are used by the GraphQL runtime as a way of modifying execution\n * behavior. Type system creators will usually not create these directly.\n */\n\nexport class GraphQLDirective {\n constructor(config) {\n this.name = config.name;\n this.description = config.description;\n this.locations = config.locations;\n this.isRepeatable = config.isRepeatable ?? false;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n config.name || devAssert(0, 'Directive must be named.');\n Array.isArray(config.locations) || devAssert(0, `@${config.name} locations must be an Array.`);\n const args = config.args ?? {};\n isObjectLike(args) && !Array.isArray(args) || devAssert(0, `@${config.name} args must be an object with argument names as keys.`);\n this.args = objectEntries(args).map(([argName, argConfig]) => ({\n name: argName,\n description: argConfig.description,\n type: argConfig.type,\n defaultValue: argConfig.defaultValue,\n deprecationReason: argConfig.deprecationReason,\n extensions: argConfig.extensions && toObjMap(argConfig.extensions),\n astNode: argConfig.astNode\n }));\n }\n\n toConfig() {\n return {\n name: this.name,\n description: this.description,\n locations: this.locations,\n args: argsToArgsConfig(this.args),\n isRepeatable: this.isRepeatable,\n extensions: this.extensions,\n astNode: this.astNode\n };\n }\n\n toString() {\n return '@' + this.name;\n }\n\n toJSON() {\n return this.toString();\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLDirective';\n }\n\n}\n\n/**\n * Used to conditionally include fields or fragments.\n */\nexport const GraphQLIncludeDirective = new GraphQLDirective({\n name: 'include',\n description: 'Directs the executor to include this field or fragment only when the `if` argument is true.',\n locations: [DirectiveLocation.FIELD, DirectiveLocation.FRAGMENT_SPREAD, DirectiveLocation.INLINE_FRAGMENT],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Included when true.'\n }\n }\n});\n/**\n * Used to conditionally skip (exclude) fields or fragments.\n */\n\nexport const GraphQLSkipDirective = new GraphQLDirective({\n name: 'skip',\n description: 'Directs the executor to skip this field or fragment when the `if` argument is true.',\n locations: [DirectiveLocation.FIELD, DirectiveLocation.FRAGMENT_SPREAD, DirectiveLocation.INLINE_FRAGMENT],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: 'Skipped when true.'\n }\n }\n});\n/**\n * Constant string used for default reason for a deprecation.\n */\n\nexport const DEFAULT_DEPRECATION_REASON = 'No longer supported';\n/**\n * Used to declare element of a GraphQL schema as deprecated.\n */\n\nexport const GraphQLDeprecatedDirective = new GraphQLDirective({\n name: 'deprecated',\n description: 'Marks an element of a GraphQL schema as no longer supported.',\n locations: [DirectiveLocation.FIELD_DEFINITION, DirectiveLocation.ARGUMENT_DEFINITION, DirectiveLocation.INPUT_FIELD_DEFINITION, DirectiveLocation.ENUM_VALUE],\n args: {\n reason: {\n type: GraphQLString,\n description: 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).',\n defaultValue: DEFAULT_DEPRECATION_REASON\n }\n }\n});\n/**\n * Used to provide a URL for specifying the behaviour of custom scalar definitions.\n */\n\nexport const GraphQLSpecifiedByDirective = new GraphQLDirective({\n name: 'specifiedBy',\n description: 'Exposes a URL that specifies the behaviour of this scalar.',\n locations: [DirectiveLocation.SCALAR],\n args: {\n url: {\n type: new GraphQLNonNull(GraphQLString),\n description: 'The URL that specifies the behaviour of this scalar.'\n }\n }\n});\n/**\n * The full list of specified directives.\n */\n\nexport const specifiedDirectives = Object.freeze([GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective]);\nexport function isSpecifiedDirective(directive) {\n return specifiedDirectives.some(({\n name\n }) => name === directive.name);\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport toObjMap from \"../jsutils/toObjMap.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport instanceOf from \"../jsutils/instanceOf.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport { __Schema } from \"./introspection.mjs\";\nimport { GraphQLDirective, isDirective, specifiedDirectives } from \"./directives.mjs\";\nimport { isObjectType, isInterfaceType, isUnionType, isInputObjectType, getNamedType } from \"./definition.mjs\";\n/**\n * Test if the given value is a GraphQL schema.\n */\n\n// eslint-disable-next-line no-redeclare\nexport function isSchema(schema) {\n return instanceOf(schema, GraphQLSchema);\n}\nexport function assertSchema(schema) {\n if (!isSchema(schema)) {\n throw new Error(`Expected ${inspect(schema)} to be a GraphQL schema.`);\n }\n\n return schema;\n}\n/**\n * Schema Definition\n *\n * A Schema is created by supplying the root types of each type of operation,\n * query and mutation (optional). A schema definition is then supplied to the\n * validator and executor.\n *\n * Example:\n *\n * const MyAppSchema = new GraphQLSchema({\n * query: MyAppQueryRootType,\n * mutation: MyAppMutationRootType,\n * })\n *\n * Note: When the schema is constructed, by default only the types that are\n * reachable by traversing the root types are included, other types must be\n * explicitly referenced.\n *\n * Example:\n *\n * const characterInterface = new GraphQLInterfaceType({\n * name: 'Character',\n * ...\n * });\n *\n * const humanType = new GraphQLObjectType({\n * name: 'Human',\n * interfaces: [characterInterface],\n * ...\n * });\n *\n * const droidType = new GraphQLObjectType({\n * name: 'Droid',\n * interfaces: [characterInterface],\n * ...\n * });\n *\n * const schema = new GraphQLSchema({\n * query: new GraphQLObjectType({\n * name: 'Query',\n * fields: {\n * hero: { type: characterInterface, ... },\n * }\n * }),\n * ...\n * // Since this schema references only the `Character` interface it's\n * // necessary to explicitly list the types that implement it if\n * // you want them to be included in the final schema.\n * types: [humanType, droidType],\n * })\n *\n * Note: If an array of `directives` are provided to GraphQLSchema, that will be\n * the exact list of directives represented and allowed. If `directives` is not\n * provided then a default set of the specified directives (e.g. @include and\n * @skip) will be used. If you wish to provide *additional* directives to these\n * specified directives, you must explicitly declare them. Example:\n *\n * const MyAppSchema = new GraphQLSchema({\n * ...\n * directives: specifiedDirectives.concat([ myCustomDirective ]),\n * })\n *\n */\n\nexport class GraphQLSchema {\n // Used as a cache for validateSchema().\n constructor(config) {\n // If this schema was built from a source known to be valid, then it may be\n // marked with assumeValid to avoid an additional type system validation.\n this.__validationErrors = config.assumeValid === true ? [] : undefined; // Check for common mistakes during construction to produce early errors.\n\n isObjectLike(config) || devAssert(0, 'Must provide configuration object.');\n !config.types || Array.isArray(config.types) || devAssert(0, `\"types\" must be Array if provided but got: ${inspect(config.types)}.`);\n !config.directives || Array.isArray(config.directives) || devAssert(0, '\"directives\" must be Array if provided but got: ' + `${inspect(config.directives)}.`);\n this.description = config.description;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n this.extensionASTNodes = config.extensionASTNodes;\n this._queryType = config.query;\n this._mutationType = config.mutation;\n this._subscriptionType = config.subscription; // Provide specified directives (e.g. @include and @skip) by default.\n\n this._directives = config.directives ?? specifiedDirectives; // To preserve order of user-provided types, we add first to add them to\n // the set of \"collected\" types, so `collectReferencedTypes` ignore them.\n\n const allReferencedTypes = new Set(config.types);\n\n if (config.types != null) {\n for (const type of config.types) {\n // When we ready to process this type, we remove it from \"collected\" types\n // and then add it together with all dependent types in the correct position.\n allReferencedTypes.delete(type);\n collectReferencedTypes(type, allReferencedTypes);\n }\n }\n\n if (this._queryType != null) {\n collectReferencedTypes(this._queryType, allReferencedTypes);\n }\n\n if (this._mutationType != null) {\n collectReferencedTypes(this._mutationType, allReferencedTypes);\n }\n\n if (this._subscriptionType != null) {\n collectReferencedTypes(this._subscriptionType, allReferencedTypes);\n }\n\n for (const directive of this._directives) {\n // Directives are not validated until validateSchema() is called.\n if (isDirective(directive)) {\n for (const arg of directive.args) {\n collectReferencedTypes(arg.type, allReferencedTypes);\n }\n }\n }\n\n collectReferencedTypes(__Schema, allReferencedTypes); // Storing the resulting map for reference by the schema.\n\n this._typeMap = Object.create(null);\n this._subTypeMap = Object.create(null); // Keep track of all implementations by interface name.\n\n this._implementationsMap = Object.create(null);\n\n for (const namedType of Array.from(allReferencedTypes)) {\n if (namedType == null) {\n continue;\n }\n\n const typeName = namedType.name;\n typeName || devAssert(0, 'One of the provided types for building the Schema is missing a name.');\n\n if (this._typeMap[typeName] !== undefined) {\n throw new Error(`Schema must contain uniquely named types but contains multiple types named \"${typeName}\".`);\n }\n\n this._typeMap[typeName] = namedType;\n\n if (isInterfaceType(namedType)) {\n // Store implementations by interface.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n\n if (implementations === undefined) {\n implementations = this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: []\n };\n }\n\n implementations.interfaces.push(namedType);\n }\n }\n } else if (isObjectType(namedType)) {\n // Store implementations by objects.\n for (const iface of namedType.getInterfaces()) {\n if (isInterfaceType(iface)) {\n let implementations = this._implementationsMap[iface.name];\n\n if (implementations === undefined) {\n implementations = this._implementationsMap[iface.name] = {\n objects: [],\n interfaces: []\n };\n }\n\n implementations.objects.push(namedType);\n }\n }\n }\n }\n }\n\n getQueryType() {\n return this._queryType;\n }\n\n getMutationType() {\n return this._mutationType;\n }\n\n getSubscriptionType() {\n return this._subscriptionType;\n }\n\n getTypeMap() {\n return this._typeMap;\n }\n\n getType(name) {\n return this.getTypeMap()[name];\n }\n\n getPossibleTypes(abstractType) {\n return isUnionType(abstractType) ? abstractType.getTypes() : this.getImplementations(abstractType).objects;\n }\n\n getImplementations(interfaceType) {\n const implementations = this._implementationsMap[interfaceType.name];\n return implementations ?? {\n objects: [],\n interfaces: []\n };\n }\n\n isSubType(abstractType, maybeSubType) {\n let map = this._subTypeMap[abstractType.name];\n\n if (map === undefined) {\n map = Object.create(null);\n\n if (isUnionType(abstractType)) {\n for (const type of abstractType.getTypes()) {\n map[type.name] = true;\n }\n } else {\n const implementations = this.getImplementations(abstractType);\n\n for (const type of implementations.objects) {\n map[type.name] = true;\n }\n\n for (const type of implementations.interfaces) {\n map[type.name] = true;\n }\n }\n\n this._subTypeMap[abstractType.name] = map;\n }\n\n return map[maybeSubType.name] !== undefined;\n }\n\n getDirectives() {\n return this._directives;\n }\n\n getDirective(name) {\n return this.getDirectives().find(directive => directive.name === name);\n }\n\n toConfig() {\n return {\n description: this.description,\n query: this.getQueryType(),\n mutation: this.getMutationType(),\n subscription: this.getSubscriptionType(),\n types: objectValues(this.getTypeMap()),\n directives: this.getDirectives().slice(),\n extensions: this.extensions,\n astNode: this.astNode,\n extensionASTNodes: this.extensionASTNodes ?? [],\n assumeValid: this.__validationErrors !== undefined\n };\n } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet\n\n\n get [Symbol.toStringTag]() {\n return 'GraphQLSchema';\n }\n\n}\n\nfunction collectReferencedTypes(type, typeSet) {\n const namedType = getNamedType(type);\n\n if (!typeSet.has(namedType)) {\n typeSet.add(namedType);\n\n if (isUnionType(namedType)) {\n for (const memberType of namedType.getTypes()) {\n collectReferencedTypes(memberType, typeSet);\n }\n } else if (isObjectType(namedType) || isInterfaceType(namedType)) {\n for (const interfaceType of namedType.getInterfaces()) {\n collectReferencedTypes(interfaceType, typeSet);\n }\n\n for (const field of objectValues(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n\n for (const arg of field.args) {\n collectReferencedTypes(arg.type, typeSet);\n }\n }\n } else if (isInputObjectType(namedType)) {\n for (const field of objectValues(namedType.getFields())) {\n collectReferencedTypes(field.type, typeSet);\n }\n }\n }\n\n return typeSet;\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nimport { locatedError } from \"../error/locatedError.mjs\";\nimport { isValidNameError } from \"../utilities/assertValidName.mjs\";\nimport { isEqualType, isTypeSubTypeOf } from \"../utilities/typeComparators.mjs\";\nimport { assertSchema } from \"./schema.mjs\";\nimport { isIntrospectionType } from \"./introspection.mjs\";\nimport { isDirective, GraphQLDeprecatedDirective } from \"./directives.mjs\";\nimport { isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isNamedType, isNonNullType, isInputType, isOutputType, isRequiredArgument, isRequiredInputField } from \"./definition.mjs\";\n/**\n * Implements the \"Type Validation\" sub-sections of the specification's\n * \"Type System\" section.\n *\n * Validation runs synchronously, returning an array of encountered errors, or\n * an empty array if no errors were encountered and the Schema is valid.\n */\n\nexport function validateSchema(schema) {\n // First check to ensure the provided value is in fact a GraphQLSchema.\n assertSchema(schema); // If this Schema has already been validated, return the previous results.\n\n if (schema.__validationErrors) {\n return schema.__validationErrors;\n } // Validate the schema, producing a list of errors.\n\n\n const context = new SchemaValidationContext(schema);\n validateRootTypes(context);\n validateDirectives(context);\n validateTypes(context); // Persist the results of validation before returning to ensure validation\n // does not run multiple times for this schema.\n\n const errors = context.getErrors();\n schema.__validationErrors = errors;\n return errors;\n}\n/**\n * Utility function which asserts a schema is valid by throwing an error if\n * it is invalid.\n */\n\nexport function assertValidSchema(schema) {\n const errors = validateSchema(schema);\n\n if (errors.length !== 0) {\n throw new Error(errors.map(error => error.message).join('\\n\\n'));\n }\n}\n\nclass SchemaValidationContext {\n constructor(schema) {\n this._errors = [];\n this.schema = schema;\n }\n\n reportError(message, nodes) {\n const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;\n\n this.addError(new GraphQLError(message, _nodes));\n }\n\n addError(error) {\n this._errors.push(error);\n }\n\n getErrors() {\n return this._errors;\n }\n\n}\n\nfunction validateRootTypes(context) {\n const schema = context.schema;\n const queryType = schema.getQueryType();\n\n if (!queryType) {\n context.reportError('Query root type must be provided.', schema.astNode);\n } else if (!isObjectType(queryType)) {\n context.reportError(`Query root type must be Object type, it cannot be ${inspect(queryType)}.`, getOperationTypeNode(schema, 'query') ?? queryType.astNode);\n }\n\n const mutationType = schema.getMutationType();\n\n if (mutationType && !isObjectType(mutationType)) {\n context.reportError('Mutation root type must be Object type if provided, it cannot be ' + `${inspect(mutationType)}.`, getOperationTypeNode(schema, 'mutation') ?? mutationType.astNode);\n }\n\n const subscriptionType = schema.getSubscriptionType();\n\n if (subscriptionType && !isObjectType(subscriptionType)) {\n context.reportError('Subscription root type must be Object type if provided, it cannot be ' + `${inspect(subscriptionType)}.`, getOperationTypeNode(schema, 'subscription') ?? subscriptionType.astNode);\n }\n}\n\nfunction getOperationTypeNode(schema, operation) {\n const operationNodes = getAllSubNodes(schema, node => node.operationTypes);\n\n for (const node of operationNodes) {\n if (node.operation === operation) {\n return node.type;\n }\n }\n\n return undefined;\n}\n\nfunction validateDirectives(context) {\n for (const directive of context.schema.getDirectives()) {\n // Ensure all directives are in fact GraphQL directives.\n if (!isDirective(directive)) {\n context.reportError(`Expected directive but got: ${inspect(directive)}.`, directive?.astNode);\n continue;\n } // Ensure they are named correctly.\n\n\n validateName(context, directive); // TODO: Ensure proper locations.\n // Ensure the arguments are valid.\n\n for (const arg of directive.args) {\n // Ensure they are named correctly.\n validateName(context, arg); // Ensure the type is an input type.\n\n if (!isInputType(arg.type)) {\n context.reportError(`The type of @${directive.name}(${arg.name}:) must be Input Type ` + `but got: ${inspect(arg.type)}.`, arg.astNode);\n }\n\n if (isRequiredArgument(arg) && arg.deprecationReason != null) {\n context.reportError(`Required argument @${directive.name}(${arg.name}:) cannot be deprecated.`, [getDeprecatedDirectiveNode(arg.astNode), // istanbul ignore next (TODO need to write coverage tests)\n arg.astNode?.type]);\n }\n }\n }\n}\n\nfunction validateName(context, node) {\n // Ensure names are valid, however introspection types opt out.\n const error = isValidNameError(node.name);\n\n if (error) {\n context.addError(locatedError(error, node.astNode));\n }\n}\n\nfunction validateTypes(context) {\n const validateInputObjectCircularRefs = createInputObjectCircularRefsValidator(context);\n const typeMap = context.schema.getTypeMap();\n\n for (const type of objectValues(typeMap)) {\n // Ensure all provided types are in fact GraphQL type.\n if (!isNamedType(type)) {\n context.reportError(`Expected GraphQL named type but got: ${inspect(type)}.`, type.astNode);\n continue;\n } // Ensure it is named correctly (excluding introspection types).\n\n\n if (!isIntrospectionType(type)) {\n validateName(context, type);\n }\n\n if (isObjectType(type)) {\n // Ensure fields are valid\n validateFields(context, type); // Ensure objects implement the interfaces they claim to.\n\n validateInterfaces(context, type);\n } else if (isInterfaceType(type)) {\n // Ensure fields are valid.\n validateFields(context, type); // Ensure interfaces implement the interfaces they claim to.\n\n validateInterfaces(context, type);\n } else if (isUnionType(type)) {\n // Ensure Unions include valid member types.\n validateUnionMembers(context, type);\n } else if (isEnumType(type)) {\n // Ensure Enums have valid values.\n validateEnumValues(context, type);\n } else if (isInputObjectType(type)) {\n // Ensure Input Object fields are valid.\n validateInputFields(context, type); // Ensure Input Objects do not contain non-nullable circular references\n\n validateInputObjectCircularRefs(type);\n }\n }\n}\n\nfunction validateFields(context, type) {\n const fields = objectValues(type.getFields()); // Objects and Interfaces both must define one or more fields.\n\n if (fields.length === 0) {\n context.reportError(`Type ${type.name} must define one or more fields.`, getAllNodes(type));\n }\n\n for (const field of fields) {\n // Ensure they are named correctly.\n validateName(context, field); // Ensure the type is an output type\n\n if (!isOutputType(field.type)) {\n context.reportError(`The type of ${type.name}.${field.name} must be Output Type ` + `but got: ${inspect(field.type)}.`, field.astNode?.type);\n } // Ensure the arguments are valid\n\n\n for (const arg of field.args) {\n const argName = arg.name; // Ensure they are named correctly.\n\n validateName(context, arg); // Ensure the type is an input type\n\n if (!isInputType(arg.type)) {\n context.reportError(`The type of ${type.name}.${field.name}(${argName}:) must be Input ` + `Type but got: ${inspect(arg.type)}.`, arg.astNode?.type);\n }\n\n if (isRequiredArgument(arg) && arg.deprecationReason != null) {\n context.reportError(`Required argument ${type.name}.${field.name}(${argName}:) cannot be deprecated.`, [getDeprecatedDirectiveNode(arg.astNode), // istanbul ignore next (TODO need to write coverage tests)\n arg.astNode?.type]);\n }\n }\n }\n}\n\nfunction validateInterfaces(context, type) {\n const ifaceTypeNames = Object.create(null);\n\n for (const iface of type.getInterfaces()) {\n if (!isInterfaceType(iface)) {\n context.reportError(`Type ${inspect(type)} must only implement Interface types, ` + `it cannot implement ${inspect(iface)}.`, getAllImplementsInterfaceNodes(type, iface));\n continue;\n }\n\n if (type === iface) {\n context.reportError(`Type ${type.name} cannot implement itself because it would create a circular reference.`, getAllImplementsInterfaceNodes(type, iface));\n continue;\n }\n\n if (ifaceTypeNames[iface.name]) {\n context.reportError(`Type ${type.name} can only implement ${iface.name} once.`, getAllImplementsInterfaceNodes(type, iface));\n continue;\n }\n\n ifaceTypeNames[iface.name] = true;\n validateTypeImplementsAncestors(context, type, iface);\n validateTypeImplementsInterface(context, type, iface);\n }\n}\n\nfunction validateTypeImplementsInterface(context, type, iface) {\n const typeFieldMap = type.getFields(); // Assert each interface field is implemented.\n\n for (const ifaceField of objectValues(iface.getFields())) {\n const fieldName = ifaceField.name;\n const typeField = typeFieldMap[fieldName]; // Assert interface field exists on type.\n\n if (!typeField) {\n context.reportError(`Interface field ${iface.name}.${fieldName} expected but ${type.name} does not provide it.`, [ifaceField.astNode, ...getAllNodes(type)]);\n continue;\n } // Assert interface field type is satisfied by type field type, by being\n // a valid subtype. (covariant)\n\n\n if (!isTypeSubTypeOf(context.schema, typeField.type, ifaceField.type)) {\n context.reportError(`Interface field ${iface.name}.${fieldName} expects type ` + `${inspect(ifaceField.type)} but ${type.name}.${fieldName} ` + `is type ${inspect(typeField.type)}.`, [// istanbul ignore next (TODO need to write coverage tests)\n ifaceField.astNode?.type, // istanbul ignore next (TODO need to write coverage tests)\n typeField.astNode?.type]);\n } // Assert each interface field arg is implemented.\n\n\n for (const ifaceArg of ifaceField.args) {\n const argName = ifaceArg.name;\n const typeArg = typeField.args.find(arg => arg.name === argName); // Assert interface field arg exists on object field.\n\n if (!typeArg) {\n context.reportError(`Interface field argument ${iface.name}.${fieldName}(${argName}:) expected but ${type.name}.${fieldName} does not provide it.`, [ifaceArg.astNode, typeField.astNode]);\n continue;\n } // Assert interface field arg type matches object field arg type.\n // (invariant)\n // TODO: change to contravariant?\n\n\n if (!isEqualType(ifaceArg.type, typeArg.type)) {\n context.reportError(`Interface field argument ${iface.name}.${fieldName}(${argName}:) ` + `expects type ${inspect(ifaceArg.type)} but ` + `${type.name}.${fieldName}(${argName}:) is type ` + `${inspect(typeArg.type)}.`, [// istanbul ignore next (TODO need to write coverage tests)\n ifaceArg.astNode?.type, // istanbul ignore next (TODO need to write coverage tests)\n typeArg.astNode?.type]);\n } // TODO: validate default values?\n\n } // Assert additional arguments must not be required.\n\n\n for (const typeArg of typeField.args) {\n const argName = typeArg.name;\n const ifaceArg = ifaceField.args.find(arg => arg.name === argName);\n\n if (!ifaceArg && isRequiredArgument(typeArg)) {\n context.reportError(`Object field ${type.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${iface.name}.${fieldName}.`, [typeArg.astNode, ifaceField.astNode]);\n }\n }\n }\n}\n\nfunction validateTypeImplementsAncestors(context, type, iface) {\n const ifaceInterfaces = type.getInterfaces();\n\n for (const transitive of iface.getInterfaces()) {\n if (ifaceInterfaces.indexOf(transitive) === -1) {\n context.reportError(transitive === type ? `Type ${type.name} cannot implement ${iface.name} because it would create a circular reference.` : `Type ${type.name} must implement ${transitive.name} because it is implemented by ${iface.name}.`, [...getAllImplementsInterfaceNodes(iface, transitive), ...getAllImplementsInterfaceNodes(type, iface)]);\n }\n }\n}\n\nfunction validateUnionMembers(context, union) {\n const memberTypes = union.getTypes();\n\n if (memberTypes.length === 0) {\n context.reportError(`Union type ${union.name} must define one or more member types.`, getAllNodes(union));\n }\n\n const includedTypeNames = Object.create(null);\n\n for (const memberType of memberTypes) {\n if (includedTypeNames[memberType.name]) {\n context.reportError(`Union type ${union.name} can only include type ${memberType.name} once.`, getUnionMemberTypeNodes(union, memberType.name));\n continue;\n }\n\n includedTypeNames[memberType.name] = true;\n\n if (!isObjectType(memberType)) {\n context.reportError(`Union type ${union.name} can only include Object types, ` + `it cannot include ${inspect(memberType)}.`, getUnionMemberTypeNodes(union, String(memberType)));\n }\n }\n}\n\nfunction validateEnumValues(context, enumType) {\n const enumValues = enumType.getValues();\n\n if (enumValues.length === 0) {\n context.reportError(`Enum type ${enumType.name} must define one or more values.`, getAllNodes(enumType));\n }\n\n for (const enumValue of enumValues) {\n const valueName = enumValue.name; // Ensure valid name.\n\n validateName(context, enumValue);\n\n if (valueName === 'true' || valueName === 'false' || valueName === 'null') {\n context.reportError(`Enum type ${enumType.name} cannot include value: ${valueName}.`, enumValue.astNode);\n }\n }\n}\n\nfunction validateInputFields(context, inputObj) {\n const fields = objectValues(inputObj.getFields());\n\n if (fields.length === 0) {\n context.reportError(`Input Object type ${inputObj.name} must define one or more fields.`, getAllNodes(inputObj));\n } // Ensure the arguments are valid\n\n\n for (const field of fields) {\n // Ensure they are named correctly.\n validateName(context, field); // Ensure the type is an input type\n\n if (!isInputType(field.type)) {\n context.reportError(`The type of ${inputObj.name}.${field.name} must be Input Type ` + `but got: ${inspect(field.type)}.`, field.astNode?.type);\n }\n\n if (isRequiredInputField(field) && field.deprecationReason != null) {\n context.reportError(`Required input field ${inputObj.name}.${field.name} cannot be deprecated.`, [getDeprecatedDirectiveNode(field.astNode), // istanbul ignore next (TODO need to write coverage tests)\n field.astNode?.type]);\n }\n }\n}\n\nfunction createInputObjectCircularRefsValidator(context) {\n // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'.\n // Tracks already visited types to maintain O(N) and to ensure that cycles\n // are not redundantly reported.\n const visitedTypes = Object.create(null); // Array of types nodes used to produce meaningful errors\n\n const fieldPath = []; // Position in the type path\n\n const fieldPathIndexByTypeName = Object.create(null);\n return detectCycleRecursive; // This does a straight-forward DFS to find cycles.\n // It does not terminate when a cycle was found but continues to explore\n // the graph to find all possible cycles.\n\n function detectCycleRecursive(inputObj) {\n if (visitedTypes[inputObj.name]) {\n return;\n }\n\n visitedTypes[inputObj.name] = true;\n fieldPathIndexByTypeName[inputObj.name] = fieldPath.length;\n const fields = objectValues(inputObj.getFields());\n\n for (const field of fields) {\n if (isNonNullType(field.type) && isInputObjectType(field.type.ofType)) {\n const fieldType = field.type.ofType;\n const cycleIndex = fieldPathIndexByTypeName[fieldType.name];\n fieldPath.push(field);\n\n if (cycleIndex === undefined) {\n detectCycleRecursive(fieldType);\n } else {\n const cyclePath = fieldPath.slice(cycleIndex);\n const pathStr = cyclePath.map(fieldObj => fieldObj.name).join('.');\n context.reportError(`Cannot reference Input Object \"${fieldType.name}\" within itself through a series of non-null fields: \"${pathStr}\".`, cyclePath.map(fieldObj => fieldObj.astNode));\n }\n\n fieldPath.pop();\n }\n }\n\n fieldPathIndexByTypeName[inputObj.name] = undefined;\n }\n}\n\nfunction getAllNodes(object) {\n const {\n astNode,\n extensionASTNodes\n } = object;\n return astNode ? extensionASTNodes ? [astNode].concat(extensionASTNodes) : [astNode] : extensionASTNodes ?? [];\n}\n\nfunction getAllSubNodes(object, getter) {\n let subNodes = [];\n\n for (const node of getAllNodes(object)) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n subNodes = subNodes.concat(getter(node) ?? []);\n }\n\n return subNodes;\n}\n\nfunction getAllImplementsInterfaceNodes(type, iface) {\n return getAllSubNodes(type, typeNode => typeNode.interfaces).filter(ifaceNode => ifaceNode.name.value === iface.name);\n}\n\nfunction getUnionMemberTypeNodes(union, typeName) {\n return getAllSubNodes(union, unionNode => unionNode.types).filter(typeNode => typeNode.name.value === typeName);\n}\n\nfunction getDeprecatedDirectiveNode(definitionNode) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n return definitionNode?.directives?.find(node => node.name.value === GraphQLDeprecatedDirective.name);\n}\n","import inspect from \"../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"./GraphQLError.mjs\";\n/**\n * Given an arbitrary value, presumably thrown while attempting to execute a\n * GraphQL operation, produce a new GraphQLError aware of the location in the\n * document responsible for the original Error.\n */\n\nexport function locatedError(rawOriginalError, nodes, path) {\n // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.\n const originalError = rawOriginalError instanceof Error ? rawOriginalError : new Error('Unexpected error value: ' + inspect(rawOriginalError)); // Note: this uses a brand-check to support GraphQL errors originating from other contexts.\n\n if (Array.isArray(originalError.path)) {\n return originalError;\n }\n\n return new GraphQLError(originalError.message, originalError.nodes ?? nodes, originalError.source, originalError.positions, path, originalError);\n}\n","import inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { GraphQLList, GraphQLNonNull } from \"../type/definition.mjs\";\n/**\n * Given a Schema and an AST node describing a type, return a GraphQLType\n * definition which applies to that type. For example, if provided the parsed\n * AST node for `[User]`, a GraphQLList instance will be returned, containing\n * the type called \"User\" found in the schema. If a type called \"User\" is not\n * found in the schema, then undefined will be returned.\n */\n\n/* eslint-disable no-redeclare */\n\nexport function typeFromAST(schema, typeNode) {\n /* eslint-enable no-redeclare */\n let innerType;\n\n if (typeNode.kind === Kind.LIST_TYPE) {\n innerType = typeFromAST(schema, typeNode.type);\n return innerType && new GraphQLList(innerType);\n }\n\n if (typeNode.kind === Kind.NON_NULL_TYPE) {\n innerType = typeFromAST(schema, typeNode.type);\n return innerType && new GraphQLNonNull(innerType);\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (typeNode.kind === Kind.NAMED_TYPE) {\n return schema.getType(typeNode.name.value);\n } // istanbul ignore next (Not reachable. All possible type nodes have been considered)\n\n\n false || invariant(0, 'Unexpected type node: ' + inspect(typeNode));\n}\n","import { Kind } from \"../language/kinds.mjs\";\nimport { isNode } from \"../language/ast.mjs\";\nimport { getVisitFn } from \"../language/visitor.mjs\";\nimport { isObjectType, isInterfaceType, isEnumType, isInputObjectType, isListType, isCompositeType, isInputType, isOutputType, getNullableType, getNamedType } from \"../type/definition.mjs\";\nimport { SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef } from \"../type/introspection.mjs\";\nimport { typeFromAST } from \"./typeFromAST.mjs\";\n/**\n * TypeInfo is a utility class which, given a GraphQL schema, can keep track\n * of the current field and type definitions at any point in a GraphQL document\n * AST during a recursive descent by calling `enter(node)` and `leave(node)`.\n */\n\nexport class TypeInfo {\n constructor(schema, // NOTE: this experimental optional second parameter is only needed in order\n // to support non-spec-compliant code bases. You should never need to use it.\n // It may disappear in the future.\n getFieldDefFn, // Initial type may be provided in rare cases to facilitate traversals\n // beginning somewhere other than documents.\n initialType) {\n this._schema = schema;\n this._typeStack = [];\n this._parentTypeStack = [];\n this._inputTypeStack = [];\n this._fieldDefStack = [];\n this._defaultValueStack = [];\n this._directive = null;\n this._argument = null;\n this._enumValue = null;\n this._getFieldDef = getFieldDefFn ?? getFieldDef;\n\n if (initialType) {\n if (isInputType(initialType)) {\n this._inputTypeStack.push(initialType);\n }\n\n if (isCompositeType(initialType)) {\n this._parentTypeStack.push(initialType);\n }\n\n if (isOutputType(initialType)) {\n this._typeStack.push(initialType);\n }\n }\n }\n\n getType() {\n if (this._typeStack.length > 0) {\n return this._typeStack[this._typeStack.length - 1];\n }\n }\n\n getParentType() {\n if (this._parentTypeStack.length > 0) {\n return this._parentTypeStack[this._parentTypeStack.length - 1];\n }\n }\n\n getInputType() {\n if (this._inputTypeStack.length > 0) {\n return this._inputTypeStack[this._inputTypeStack.length - 1];\n }\n }\n\n getParentInputType() {\n if (this._inputTypeStack.length > 1) {\n return this._inputTypeStack[this._inputTypeStack.length - 2];\n }\n }\n\n getFieldDef() {\n if (this._fieldDefStack.length > 0) {\n return this._fieldDefStack[this._fieldDefStack.length - 1];\n }\n }\n\n getDefaultValue() {\n if (this._defaultValueStack.length > 0) {\n return this._defaultValueStack[this._defaultValueStack.length - 1];\n }\n }\n\n getDirective() {\n return this._directive;\n }\n\n getArgument() {\n return this._argument;\n }\n\n getEnumValue() {\n return this._enumValue;\n }\n\n enter(node) {\n const schema = this._schema; // Note: many of the types below are explicitly typed as \"mixed\" to drop\n // any assumptions of a valid schema to ensure runtime types are properly\n // checked before continuing since TypeInfo is used as part of validation\n // which occurs before guarantees of schema and document validity.\n\n switch (node.kind) {\n case Kind.SELECTION_SET:\n {\n const namedType = getNamedType(this.getType());\n\n this._parentTypeStack.push(isCompositeType(namedType) ? namedType : undefined);\n\n break;\n }\n\n case Kind.FIELD:\n {\n const parentType = this.getParentType();\n let fieldDef;\n let fieldType;\n\n if (parentType) {\n fieldDef = this._getFieldDef(schema, parentType, node);\n\n if (fieldDef) {\n fieldType = fieldDef.type;\n }\n }\n\n this._fieldDefStack.push(fieldDef);\n\n this._typeStack.push(isOutputType(fieldType) ? fieldType : undefined);\n\n break;\n }\n\n case Kind.DIRECTIVE:\n this._directive = schema.getDirective(node.name.value);\n break;\n\n case Kind.OPERATION_DEFINITION:\n {\n let type;\n\n switch (node.operation) {\n case 'query':\n type = schema.getQueryType();\n break;\n\n case 'mutation':\n type = schema.getMutationType();\n break;\n\n case 'subscription':\n type = schema.getSubscriptionType();\n break;\n }\n\n this._typeStack.push(isObjectType(type) ? type : undefined);\n\n break;\n }\n\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION:\n {\n const typeConditionAST = node.typeCondition;\n const outputType = typeConditionAST ? typeFromAST(schema, typeConditionAST) : getNamedType(this.getType());\n\n this._typeStack.push(isOutputType(outputType) ? outputType : undefined);\n\n break;\n }\n\n case Kind.VARIABLE_DEFINITION:\n {\n const inputType = typeFromAST(schema, node.type);\n\n this._inputTypeStack.push(isInputType(inputType) ? inputType : undefined);\n\n break;\n }\n\n case Kind.ARGUMENT:\n {\n let argDef;\n let argType;\n const fieldOrDirective = this.getDirective() ?? this.getFieldDef();\n\n if (fieldOrDirective) {\n argDef = fieldOrDirective.args.find(arg => arg.name === node.name.value);\n\n if (argDef) {\n argType = argDef.type;\n }\n }\n\n this._argument = argDef;\n\n this._defaultValueStack.push(argDef ? argDef.defaultValue : undefined);\n\n this._inputTypeStack.push(isInputType(argType) ? argType : undefined);\n\n break;\n }\n\n case Kind.LIST:\n {\n const listType = getNullableType(this.getInputType());\n const itemType = isListType(listType) ? listType.ofType : listType; // List positions never have a default value.\n\n this._defaultValueStack.push(undefined);\n\n this._inputTypeStack.push(isInputType(itemType) ? itemType : undefined);\n\n break;\n }\n\n case Kind.OBJECT_FIELD:\n {\n const objectType = getNamedType(this.getInputType());\n let inputFieldType;\n let inputField;\n\n if (isInputObjectType(objectType)) {\n inputField = objectType.getFields()[node.name.value];\n\n if (inputField) {\n inputFieldType = inputField.type;\n }\n }\n\n this._defaultValueStack.push(inputField ? inputField.defaultValue : undefined);\n\n this._inputTypeStack.push(isInputType(inputFieldType) ? inputFieldType : undefined);\n\n break;\n }\n\n case Kind.ENUM:\n {\n const enumType = getNamedType(this.getInputType());\n let enumValue;\n\n if (isEnumType(enumType)) {\n enumValue = enumType.getValue(node.value);\n }\n\n this._enumValue = enumValue;\n break;\n }\n }\n }\n\n leave(node) {\n switch (node.kind) {\n case Kind.SELECTION_SET:\n this._parentTypeStack.pop();\n\n break;\n\n case Kind.FIELD:\n this._fieldDefStack.pop();\n\n this._typeStack.pop();\n\n break;\n\n case Kind.DIRECTIVE:\n this._directive = null;\n break;\n\n case Kind.OPERATION_DEFINITION:\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION:\n this._typeStack.pop();\n\n break;\n\n case Kind.VARIABLE_DEFINITION:\n this._inputTypeStack.pop();\n\n break;\n\n case Kind.ARGUMENT:\n this._argument = null;\n\n this._defaultValueStack.pop();\n\n this._inputTypeStack.pop();\n\n break;\n\n case Kind.LIST:\n case Kind.OBJECT_FIELD:\n this._defaultValueStack.pop();\n\n this._inputTypeStack.pop();\n\n break;\n\n case Kind.ENUM:\n this._enumValue = null;\n break;\n }\n }\n\n}\n/**\n * Not exactly the same as the executor's definition of getFieldDef, in this\n * statically evaluated environment we do not always have an Object type,\n * and need to handle Interface and Union types.\n */\n\nfunction getFieldDef(schema, parentType, fieldNode) {\n const name = fieldNode.name.value;\n\n if (name === SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {\n return SchemaMetaFieldDef;\n }\n\n if (name === TypeMetaFieldDef.name && schema.getQueryType() === parentType) {\n return TypeMetaFieldDef;\n }\n\n if (name === TypeNameMetaFieldDef.name && isCompositeType(parentType)) {\n return TypeNameMetaFieldDef;\n }\n\n if (isObjectType(parentType) || isInterfaceType(parentType)) {\n return parentType.getFields()[name];\n }\n}\n/**\n * Creates a new visitor instance which maintains a provided TypeInfo instance\n * along with visiting visitor.\n */\n\n\nexport function visitWithTypeInfo(typeInfo, visitor) {\n return {\n enter(node) {\n typeInfo.enter(node);\n const fn = getVisitFn(visitor, node.kind,\n /* isLeaving */\n false);\n\n if (fn) {\n const result = fn.apply(visitor, arguments);\n\n if (result !== undefined) {\n typeInfo.leave(node);\n\n if (isNode(result)) {\n typeInfo.enter(result);\n }\n }\n\n return result;\n }\n },\n\n leave(node) {\n const fn = getVisitFn(visitor, node.kind,\n /* isLeaving */\n true);\n let result;\n\n if (fn) {\n result = fn.apply(visitor, arguments);\n }\n\n typeInfo.leave(node);\n return result;\n }\n\n };\n}\n","import { Kind } from \"./kinds.mjs\";\nexport function isDefinitionNode(node) {\n return isExecutableDefinitionNode(node) || isTypeSystemDefinitionNode(node) || isTypeSystemExtensionNode(node);\n}\nexport function isExecutableDefinitionNode(node) {\n return node.kind === Kind.OPERATION_DEFINITION || node.kind === Kind.FRAGMENT_DEFINITION;\n}\nexport function isSelectionNode(node) {\n return node.kind === Kind.FIELD || node.kind === Kind.FRAGMENT_SPREAD || node.kind === Kind.INLINE_FRAGMENT;\n}\nexport function isValueNode(node) {\n return node.kind === Kind.VARIABLE || node.kind === Kind.INT || node.kind === Kind.FLOAT || node.kind === Kind.STRING || node.kind === Kind.BOOLEAN || node.kind === Kind.NULL || node.kind === Kind.ENUM || node.kind === Kind.LIST || node.kind === Kind.OBJECT;\n}\nexport function isTypeNode(node) {\n return node.kind === Kind.NAMED_TYPE || node.kind === Kind.LIST_TYPE || node.kind === Kind.NON_NULL_TYPE;\n}\nexport function isTypeSystemDefinitionNode(node) {\n return node.kind === Kind.SCHEMA_DEFINITION || isTypeDefinitionNode(node) || node.kind === Kind.DIRECTIVE_DEFINITION;\n}\nexport function isTypeDefinitionNode(node) {\n return node.kind === Kind.SCALAR_TYPE_DEFINITION || node.kind === Kind.OBJECT_TYPE_DEFINITION || node.kind === Kind.INTERFACE_TYPE_DEFINITION || node.kind === Kind.UNION_TYPE_DEFINITION || node.kind === Kind.ENUM_TYPE_DEFINITION || node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION;\n}\nexport function isTypeSystemExtensionNode(node) {\n return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);\n}\nexport function isTypeExtensionNode(node) {\n return node.kind === Kind.SCALAR_TYPE_EXTENSION || node.kind === Kind.OBJECT_TYPE_EXTENSION || node.kind === Kind.INTERFACE_TYPE_EXTENSION || node.kind === Kind.UNION_TYPE_EXTENSION || node.kind === Kind.ENUM_TYPE_EXTENSION || node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION;\n}\n","import didYouMean from \"../../jsutils/didYouMean.mjs\";\nimport suggestionList from \"../../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { isTypeDefinitionNode, isTypeSystemDefinitionNode, isTypeSystemExtensionNode } from \"../../language/predicates.mjs\";\nimport { specifiedScalarTypes } from \"../../type/scalars.mjs\";\nimport { introspectionTypes } from \"../../type/introspection.mjs\";\n\n/**\n * Known type names\n *\n * A GraphQL document is only valid if referenced types (specifically\n * variable definitions and fragment conditions) are defined by the type schema.\n */\nexport function KnownTypeNamesRule(context) {\n const schema = context.getSchema();\n const existingTypesMap = schema ? schema.getTypeMap() : Object.create(null);\n const definedTypes = Object.create(null);\n\n for (const def of context.getDocument().definitions) {\n if (isTypeDefinitionNode(def)) {\n definedTypes[def.name.value] = true;\n }\n }\n\n const typeNames = Object.keys(existingTypesMap).concat(Object.keys(definedTypes));\n return {\n NamedType(node, _1, parent, _2, ancestors) {\n const typeName = node.name.value;\n\n if (!existingTypesMap[typeName] && !definedTypes[typeName]) {\n const definitionNode = ancestors[2] ?? parent;\n const isSDL = definitionNode != null && isSDLNode(definitionNode);\n\n if (isSDL && isStandardTypeName(typeName)) {\n return;\n }\n\n const suggestedTypes = suggestionList(typeName, isSDL ? standardTypeNames.concat(typeNames) : typeNames);\n context.reportError(new GraphQLError(`Unknown type \"${typeName}\".` + didYouMean(suggestedTypes), node));\n }\n }\n\n };\n}\nconst standardTypeNames = [...specifiedScalarTypes, ...introspectionTypes].map(type => type.name);\n\nfunction isStandardTypeName(typeName) {\n return standardTypeNames.indexOf(typeName) !== -1;\n}\n\nfunction isSDLNode(value) {\n return !Array.isArray(value) && (isTypeSystemDefinitionNode(value) || isTypeSystemExtensionNode(value));\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * No unused fragments\n *\n * A GraphQL document is only valid if all fragment definitions are spread\n * within operations, or spread within other fragments spread within operations.\n */\nexport function NoUnusedFragmentsRule(context) {\n const operationDefs = [];\n const fragmentDefs = [];\n return {\n OperationDefinition(node) {\n operationDefs.push(node);\n return false;\n },\n\n FragmentDefinition(node) {\n fragmentDefs.push(node);\n return false;\n },\n\n Document: {\n leave() {\n const fragmentNameUsed = Object.create(null);\n\n for (const operation of operationDefs) {\n for (const fragment of context.getRecursivelyReferencedFragments(operation)) {\n fragmentNameUsed[fragment.name.value] = true;\n }\n }\n\n for (const fragmentDef of fragmentDefs) {\n const fragName = fragmentDef.name.value;\n\n if (fragmentNameUsed[fragName] !== true) {\n context.reportError(new GraphQLError(`Fragment \"${fragName}\" is never used.`, fragmentDef));\n }\n }\n }\n\n }\n };\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport invariant from \"../../jsutils/invariant.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { DirectiveLocation } from \"../../language/directiveLocation.mjs\";\nimport { specifiedDirectives } from \"../../type/directives.mjs\";\n\n/**\n * Known directives\n *\n * A GraphQL document is only valid if all `@directives` are known by the\n * schema and legally positioned.\n */\nexport function KnownDirectivesRule(context) {\n const locationsMap = Object.create(null);\n const schema = context.getSchema();\n const definedDirectives = schema ? schema.getDirectives() : specifiedDirectives;\n\n for (const directive of definedDirectives) {\n locationsMap[directive.name] = directive.locations;\n }\n\n const astDefinitions = context.getDocument().definitions;\n\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n locationsMap[def.name.value] = def.locations.map(name => name.value);\n }\n }\n\n return {\n Directive(node, _key, _parent, _path, ancestors) {\n const name = node.name.value;\n const locations = locationsMap[name];\n\n if (!locations) {\n context.reportError(new GraphQLError(`Unknown directive \"@${name}\".`, node));\n return;\n }\n\n const candidateLocation = getDirectiveLocationForASTPath(ancestors);\n\n if (candidateLocation && locations.indexOf(candidateLocation) === -1) {\n context.reportError(new GraphQLError(`Directive \"@${name}\" may not be used on ${candidateLocation}.`, node));\n }\n }\n\n };\n}\n\nfunction getDirectiveLocationForASTPath(ancestors) {\n const appliedTo = ancestors[ancestors.length - 1];\n !Array.isArray(appliedTo) || invariant(0);\n\n switch (appliedTo.kind) {\n case Kind.OPERATION_DEFINITION:\n return getDirectiveLocationForOperation(appliedTo.operation);\n\n case Kind.FIELD:\n return DirectiveLocation.FIELD;\n\n case Kind.FRAGMENT_SPREAD:\n return DirectiveLocation.FRAGMENT_SPREAD;\n\n case Kind.INLINE_FRAGMENT:\n return DirectiveLocation.INLINE_FRAGMENT;\n\n case Kind.FRAGMENT_DEFINITION:\n return DirectiveLocation.FRAGMENT_DEFINITION;\n\n case Kind.VARIABLE_DEFINITION:\n return DirectiveLocation.VARIABLE_DEFINITION;\n\n case Kind.SCHEMA_DEFINITION:\n case Kind.SCHEMA_EXTENSION:\n return DirectiveLocation.SCHEMA;\n\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.SCALAR_TYPE_EXTENSION:\n return DirectiveLocation.SCALAR;\n\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_EXTENSION:\n return DirectiveLocation.OBJECT;\n\n case Kind.FIELD_DEFINITION:\n return DirectiveLocation.FIELD_DEFINITION;\n\n case Kind.INTERFACE_TYPE_DEFINITION:\n case Kind.INTERFACE_TYPE_EXTENSION:\n return DirectiveLocation.INTERFACE;\n\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.UNION_TYPE_EXTENSION:\n return DirectiveLocation.UNION;\n\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_EXTENSION:\n return DirectiveLocation.ENUM;\n\n case Kind.ENUM_VALUE_DEFINITION:\n return DirectiveLocation.ENUM_VALUE;\n\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_EXTENSION:\n return DirectiveLocation.INPUT_OBJECT;\n\n case Kind.INPUT_VALUE_DEFINITION:\n {\n const parentNode = ancestors[ancestors.length - 3];\n return parentNode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ? DirectiveLocation.INPUT_FIELD_DEFINITION : DirectiveLocation.ARGUMENT_DEFINITION;\n }\n }\n}\n\nfunction getDirectiveLocationForOperation(operation) {\n switch (operation) {\n case 'query':\n return DirectiveLocation.QUERY;\n\n case 'mutation':\n return DirectiveLocation.MUTATION;\n\n case 'subscription':\n return DirectiveLocation.SUBSCRIPTION;\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, 'Unexpected operation: ' + inspect(operation));\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { isTypeDefinitionNode, isTypeExtensionNode } from \"../../language/predicates.mjs\";\nimport { specifiedDirectives } from \"../../type/directives.mjs\";\n\n/**\n * Unique directive names per location\n *\n * A GraphQL document is only valid if all non-repeatable directives at\n * a given location are uniquely named.\n */\nexport function UniqueDirectivesPerLocationRule(context) {\n const uniqueDirectiveMap = Object.create(null);\n const schema = context.getSchema();\n const definedDirectives = schema ? schema.getDirectives() : specifiedDirectives;\n\n for (const directive of definedDirectives) {\n uniqueDirectiveMap[directive.name] = !directive.isRepeatable;\n }\n\n const astDefinitions = context.getDocument().definitions;\n\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n uniqueDirectiveMap[def.name.value] = !def.repeatable;\n }\n }\n\n const schemaDirectives = Object.create(null);\n const typeDirectivesMap = Object.create(null);\n return {\n // Many different AST nodes may contain directives. Rather than listing\n // them all, just listen for entering any node, and check to see if it\n // defines any directives.\n enter(node) {\n if (node.directives == null) {\n return;\n }\n\n let seenDirectives;\n\n if (node.kind === Kind.SCHEMA_DEFINITION || node.kind === Kind.SCHEMA_EXTENSION) {\n seenDirectives = schemaDirectives;\n } else if (isTypeDefinitionNode(node) || isTypeExtensionNode(node)) {\n const typeName = node.name.value;\n seenDirectives = typeDirectivesMap[typeName];\n\n if (seenDirectives === undefined) {\n typeDirectivesMap[typeName] = seenDirectives = Object.create(null);\n }\n } else {\n seenDirectives = Object.create(null);\n }\n\n for (const directive of node.directives) {\n const directiveName = directive.name.value;\n\n if (uniqueDirectiveMap[directiveName]) {\n if (seenDirectives[directiveName]) {\n context.reportError(new GraphQLError(`The directive \"@${directiveName}\" can only be used once at this location.`, [seenDirectives[directiveName], directive]));\n } else {\n seenDirectives[directiveName] = directive;\n }\n }\n }\n }\n\n };\n}\n","import didYouMean from \"../../jsutils/didYouMean.mjs\";\nimport suggestionList from \"../../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { specifiedDirectives } from \"../../type/directives.mjs\";\n\n/**\n * Known argument names\n *\n * A GraphQL field is only valid if all supplied arguments are defined by\n * that field.\n */\nexport function KnownArgumentNamesRule(context) {\n return { // eslint-disable-next-line new-cap\n ...KnownArgumentNamesOnDirectivesRule(context),\n\n Argument(argNode) {\n const argDef = context.getArgument();\n const fieldDef = context.getFieldDef();\n const parentType = context.getParentType();\n\n if (!argDef && fieldDef && parentType) {\n const argName = argNode.name.value;\n const knownArgsNames = fieldDef.args.map(arg => arg.name);\n const suggestions = suggestionList(argName, knownArgsNames);\n context.reportError(new GraphQLError(`Unknown argument \"${argName}\" on field \"${parentType.name}.${fieldDef.name}\".` + didYouMean(suggestions), argNode));\n }\n }\n\n };\n}\n/**\n * @internal\n */\n\nexport function KnownArgumentNamesOnDirectivesRule(context) {\n const directiveArgs = Object.create(null);\n const schema = context.getSchema();\n const definedDirectives = schema ? schema.getDirectives() : specifiedDirectives;\n\n for (const directive of definedDirectives) {\n directiveArgs[directive.name] = directive.args.map(arg => arg.name);\n }\n\n const astDefinitions = context.getDocument().definitions;\n\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argsNodes = def.arguments ?? [];\n directiveArgs[def.name.value] = argsNodes.map(arg => arg.name.value);\n }\n }\n\n return {\n Directive(directiveNode) {\n const directiveName = directiveNode.name.value;\n const knownArgs = directiveArgs[directiveName];\n\n if (directiveNode.arguments && knownArgs) {\n for (const argNode of directiveNode.arguments) {\n const argName = argNode.name.value;\n\n if (knownArgs.indexOf(argName) === -1) {\n const suggestions = suggestionList(argName, knownArgs);\n context.reportError(new GraphQLError(`Unknown argument \"${argName}\" on directive \"@${directiveName}\".` + didYouMean(suggestions), argNode));\n }\n }\n }\n\n return false;\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique argument names\n *\n * A GraphQL field or directive is only valid if all supplied arguments are\n * uniquely named.\n */\nexport function UniqueArgumentNamesRule(context) {\n let knownArgNames = Object.create(null);\n return {\n Field() {\n knownArgNames = Object.create(null);\n },\n\n Directive() {\n knownArgNames = Object.create(null);\n },\n\n Argument(node) {\n const argName = node.name.value;\n\n if (knownArgNames[argName]) {\n context.reportError(new GraphQLError(`There can be only one argument named \"${argName}\".`, [knownArgNames[argName], node.name]));\n } else {\n knownArgNames[argName] = node.name;\n }\n\n return false;\n }\n\n };\n}\n","import objectValues from \"../../polyfills/objectValues.mjs\";\nimport keyMap from \"../../jsutils/keyMap.mjs\";\nimport inspect from \"../../jsutils/inspect.mjs\";\nimport didYouMean from \"../../jsutils/didYouMean.mjs\";\nimport suggestionList from \"../../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { print } from \"../../language/printer.mjs\";\nimport { isLeafType, isInputObjectType, isListType, isNonNullType, isRequiredInputField, getNullableType, getNamedType } from \"../../type/definition.mjs\";\n\n/**\n * Value literals of correct type\n *\n * A GraphQL document is only valid if all value literals are of the type\n * expected at their position.\n */\nexport function ValuesOfCorrectTypeRule(context) {\n return {\n ListValue(node) {\n // Note: TypeInfo will traverse into a list's item type, so look to the\n // parent input type to check if it is a list.\n const type = getNullableType(context.getParentInputType());\n\n if (!isListType(type)) {\n isValidValueNode(context, node);\n return false; // Don't traverse further.\n }\n },\n\n ObjectValue(node) {\n const type = getNamedType(context.getInputType());\n\n if (!isInputObjectType(type)) {\n isValidValueNode(context, node);\n return false; // Don't traverse further.\n } // Ensure every required field exists.\n\n\n const fieldNodeMap = keyMap(node.fields, field => field.name.value);\n\n for (const fieldDef of objectValues(type.getFields())) {\n const fieldNode = fieldNodeMap[fieldDef.name];\n\n if (!fieldNode && isRequiredInputField(fieldDef)) {\n const typeStr = inspect(fieldDef.type);\n context.reportError(new GraphQLError(`Field \"${type.name}.${fieldDef.name}\" of required type \"${typeStr}\" was not provided.`, node));\n }\n }\n },\n\n ObjectField(node) {\n const parentType = getNamedType(context.getParentInputType());\n const fieldType = context.getInputType();\n\n if (!fieldType && isInputObjectType(parentType)) {\n const suggestions = suggestionList(node.name.value, Object.keys(parentType.getFields()));\n context.reportError(new GraphQLError(`Field \"${node.name.value}\" is not defined by type \"${parentType.name}\".` + didYouMean(suggestions), node));\n }\n },\n\n NullValue(node) {\n const type = context.getInputType();\n\n if (isNonNullType(type)) {\n context.reportError(new GraphQLError(`Expected value of type \"${inspect(type)}\", found ${print(node)}.`, node));\n }\n },\n\n EnumValue: node => isValidValueNode(context, node),\n IntValue: node => isValidValueNode(context, node),\n FloatValue: node => isValidValueNode(context, node),\n StringValue: node => isValidValueNode(context, node),\n BooleanValue: node => isValidValueNode(context, node)\n };\n}\n/**\n * Any value literal may be a valid representation of a Scalar, depending on\n * that scalar type.\n */\n\nfunction isValidValueNode(context, node) {\n // Report any error at the full type expected by the location.\n const locationType = context.getInputType();\n\n if (!locationType) {\n return;\n }\n\n const type = getNamedType(locationType);\n\n if (!isLeafType(type)) {\n const typeStr = inspect(locationType);\n context.reportError(new GraphQLError(`Expected value of type \"${typeStr}\", found ${print(node)}.`, node));\n return;\n } // Scalars and Enums determine if a literal value is valid via parseLiteral(),\n // which may throw or return an invalid value to indicate failure.\n\n\n try {\n const parseResult = type.parseLiteral(node, undefined\n /* variables */\n );\n\n if (parseResult === undefined) {\n const typeStr = inspect(locationType);\n context.reportError(new GraphQLError(`Expected value of type \"${typeStr}\", found ${print(node)}.`, node));\n }\n } catch (error) {\n const typeStr = inspect(locationType);\n\n if (error instanceof GraphQLError) {\n context.reportError(error);\n } else {\n context.reportError(new GraphQLError(`Expected value of type \"${typeStr}\", found ${print(node)}; ` + error.message, node, undefined, undefined, undefined, error));\n }\n }\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport keyMap from \"../../jsutils/keyMap.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { print } from \"../../language/printer.mjs\";\nimport { specifiedDirectives } from \"../../type/directives.mjs\";\nimport { isType, isRequiredArgument } from \"../../type/definition.mjs\";\n\n/**\n * Provided required arguments\n *\n * A field or directive is only valid if all required (non-null without a\n * default value) field arguments have been provided.\n */\nexport function ProvidedRequiredArgumentsRule(context) {\n return { // eslint-disable-next-line new-cap\n ...ProvidedRequiredArgumentsOnDirectivesRule(context),\n Field: {\n // Validate on leave to allow for deeper errors to appear first.\n leave(fieldNode) {\n const fieldDef = context.getFieldDef();\n\n if (!fieldDef) {\n return false;\n } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n\n const argNodes = fieldNode.arguments ?? [];\n const argNodeMap = keyMap(argNodes, arg => arg.name.value);\n\n for (const argDef of fieldDef.args) {\n const argNode = argNodeMap[argDef.name];\n\n if (!argNode && isRequiredArgument(argDef)) {\n const argTypeStr = inspect(argDef.type);\n context.reportError(new GraphQLError(`Field \"${fieldDef.name}\" argument \"${argDef.name}\" of type \"${argTypeStr}\" is required, but it was not provided.`, fieldNode));\n }\n }\n }\n\n }\n };\n}\n/**\n * @internal\n */\n\nexport function ProvidedRequiredArgumentsOnDirectivesRule(context) {\n const requiredArgsMap = Object.create(null);\n const schema = context.getSchema();\n const definedDirectives = schema ? schema.getDirectives() : specifiedDirectives;\n\n for (const directive of definedDirectives) {\n requiredArgsMap[directive.name] = keyMap(directive.args.filter(isRequiredArgument), arg => arg.name);\n }\n\n const astDefinitions = context.getDocument().definitions;\n\n for (const def of astDefinitions) {\n if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argNodes = def.arguments ?? [];\n requiredArgsMap[def.name.value] = keyMap(argNodes.filter(isRequiredArgumentNode), arg => arg.name.value);\n }\n }\n\n return {\n Directive: {\n // Validate on leave to allow for deeper errors to appear first.\n leave(directiveNode) {\n const directiveName = directiveNode.name.value;\n const requiredArgs = requiredArgsMap[directiveName];\n\n if (requiredArgs) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argNodes = directiveNode.arguments ?? [];\n const argNodeMap = keyMap(argNodes, arg => arg.name.value);\n\n for (const argName of Object.keys(requiredArgs)) {\n if (!argNodeMap[argName]) {\n const argType = requiredArgs[argName].type;\n const argTypeStr = isType(argType) ? inspect(argType) : print(argType);\n context.reportError(new GraphQLError(`Directive \"@${directiveName}\" argument \"${argName}\" of type \"${argTypeStr}\" is required, but it was not provided.`, directiveNode));\n }\n }\n }\n }\n\n }\n };\n}\n\nfunction isRequiredArgumentNode(arg) {\n return arg.type.kind === Kind.NON_NULL_TYPE && arg.defaultValue == null;\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { isNonNullType } from \"../../type/definition.mjs\";\nimport { typeFromAST } from \"../../utilities/typeFromAST.mjs\";\nimport { isTypeSubTypeOf } from \"../../utilities/typeComparators.mjs\";\n\n/**\n * Variables passed to field arguments conform to type\n */\nexport function VariablesInAllowedPositionRule(context) {\n let varDefMap = Object.create(null);\n return {\n OperationDefinition: {\n enter() {\n varDefMap = Object.create(null);\n },\n\n leave(operation) {\n const usages = context.getRecursiveVariableUsages(operation);\n\n for (const {\n node,\n type,\n defaultValue\n } of usages) {\n const varName = node.name.value;\n const varDef = varDefMap[varName];\n\n if (varDef && type) {\n // A var type is allowed if it is the same or more strict (e.g. is\n // a subtype of) than the expected type. It can be more strict if\n // the variable type is non-null when the expected type is nullable.\n // If both are list types, the variable item type can be more strict\n // than the expected item type (contravariant).\n const schema = context.getSchema();\n const varType = typeFromAST(schema, varDef.type);\n\n if (varType && !allowedVariableUsage(schema, varType, varDef.defaultValue, type, defaultValue)) {\n const varTypeStr = inspect(varType);\n const typeStr = inspect(type);\n context.reportError(new GraphQLError(`Variable \"$${varName}\" of type \"${varTypeStr}\" used in position expecting type \"${typeStr}\".`, [varDef, node]));\n }\n }\n }\n }\n\n },\n\n VariableDefinition(node) {\n varDefMap[node.variable.name.value] = node;\n }\n\n };\n}\n/**\n * Returns true if the variable is allowed in the location it was found,\n * which includes considering if default values exist for either the variable\n * or the location at which it is located.\n */\n\nfunction allowedVariableUsage(schema, varType, varDefaultValue, locationType, locationDefaultValue) {\n if (isNonNullType(locationType) && !isNonNullType(varType)) {\n const hasNonNullVariableDefaultValue = varDefaultValue != null && varDefaultValue.kind !== Kind.NULL;\n const hasLocationDefaultValue = locationDefaultValue !== undefined;\n\n if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) {\n return false;\n }\n\n const nullableLocationType = locationType.ofType;\n return isTypeSubTypeOf(schema, varType, nullableLocationType);\n }\n\n return isTypeSubTypeOf(schema, varType, locationType);\n}\n","import objectEntries from \"../../polyfills/objectEntries.mjs\";\nimport inspect from \"../../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { print } from \"../../language/printer.mjs\";\nimport { getNamedType, isNonNullType, isLeafType, isObjectType, isListType, isInterfaceType } from \"../../type/definition.mjs\";\nimport { typeFromAST } from \"../../utilities/typeFromAST.mjs\";\n\nfunction reasonMessage(reason) {\n if (Array.isArray(reason)) {\n return reason.map(([responseName, subReason]) => `subfields \"${responseName}\" conflict because ` + reasonMessage(subReason)).join(' and ');\n }\n\n return reason;\n}\n/**\n * Overlapping fields can be merged\n *\n * A selection set is only valid if all fields (including spreading any\n * fragments) either correspond to distinct response names or can be merged\n * without ambiguity.\n */\n\n\nexport function OverlappingFieldsCanBeMergedRule(context) {\n // A memoization for when two fragments are compared \"between\" each other for\n // conflicts. Two fragments may be compared many times, so memoizing this can\n // dramatically improve the performance of this validator.\n const comparedFragmentPairs = new PairSet(); // A cache for the \"field map\" and list of fragment names found in any given\n // selection set. Selection sets may be asked for this information multiple\n // times, so this improves the performance of this validator.\n\n const cachedFieldsAndFragmentNames = new Map();\n return {\n SelectionSet(selectionSet) {\n const conflicts = findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, context.getParentType(), selectionSet);\n\n for (const [[responseName, reason], fields1, fields2] of conflicts) {\n const reasonMsg = reasonMessage(reason);\n context.reportError(new GraphQLError(`Fields \"${responseName}\" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`, fields1.concat(fields2)));\n }\n }\n\n };\n}\n\n/**\n * Algorithm:\n *\n * Conflicts occur when two fields exist in a query which will produce the same\n * response name, but represent differing values, thus creating a conflict.\n * The algorithm below finds all conflicts via making a series of comparisons\n * between fields. In order to compare as few fields as possible, this makes\n * a series of comparisons \"within\" sets of fields and \"between\" sets of fields.\n *\n * Given any selection set, a collection produces both a set of fields by\n * also including all inline fragments, as well as a list of fragments\n * referenced by fragment spreads.\n *\n * A) Each selection set represented in the document first compares \"within\" its\n * collected set of fields, finding any conflicts between every pair of\n * overlapping fields.\n * Note: This is the *only time* that a the fields \"within\" a set are compared\n * to each other. After this only fields \"between\" sets are compared.\n *\n * B) Also, if any fragment is referenced in a selection set, then a\n * comparison is made \"between\" the original set of fields and the\n * referenced fragment.\n *\n * C) Also, if multiple fragments are referenced, then comparisons\n * are made \"between\" each referenced fragment.\n *\n * D) When comparing \"between\" a set of fields and a referenced fragment, first\n * a comparison is made between each field in the original set of fields and\n * each field in the the referenced set of fields.\n *\n * E) Also, if any fragment is referenced in the referenced selection set,\n * then a comparison is made \"between\" the original set of fields and the\n * referenced fragment (recursively referring to step D).\n *\n * F) When comparing \"between\" two fragments, first a comparison is made between\n * each field in the first referenced set of fields and each field in the the\n * second referenced set of fields.\n *\n * G) Also, any fragments referenced by the first must be compared to the\n * second, and any fragments referenced by the second must be compared to the\n * first (recursively referring to step F).\n *\n * H) When comparing two fields, if both have selection sets, then a comparison\n * is made \"between\" both selection sets, first comparing the set of fields in\n * the first selection set with the set of fields in the second.\n *\n * I) Also, if any fragment is referenced in either selection set, then a\n * comparison is made \"between\" the other set of fields and the\n * referenced fragment.\n *\n * J) Also, if two fragments are referenced in both selection sets, then a\n * comparison is made \"between\" the two fragments.\n *\n */\n// Find all conflicts found \"within\" a selection set, including those found\n// via spreading in fragments. Called when visiting each SelectionSet in the\n// GraphQL Document.\nfunction findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentType, selectionSet) {\n const conflicts = [];\n const [fieldMap, fragmentNames] = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet); // (A) Find find all conflicts \"within\" the fields of this selection set.\n // Note: this is the *only place* `collectConflictsWithin` is called.\n\n collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, fieldMap);\n\n if (fragmentNames.length !== 0) {\n // (B) Then collect conflicts between these fields and those represented by\n // each spread fragment name found.\n for (let i = 0; i < fragmentNames.length; i++) {\n collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, fieldMap, fragmentNames[i]); // (C) Then compare this fragment with all other fragments found in this\n // selection set to collect conflicts between fragments spread together.\n // This compares each item in the list of fragment names to every other\n // item in that same list (except for itself).\n\n for (let j = i + 1; j < fragmentNames.length; j++) {\n collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, fragmentNames[i], fragmentNames[j]);\n }\n }\n }\n\n return conflicts;\n} // Collect all conflicts found between a set of fields and a fragment reference\n// including via spreading in any nested fragments.\n\n\nfunction collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {\n const fragment = context.getFragment(fragmentName);\n\n if (!fragment) {\n return;\n }\n\n const [fieldMap2, fragmentNames2] = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment); // Do not compare a fragment's fieldMap to itself.\n\n if (fieldMap === fieldMap2) {\n return;\n } // (D) First collect any conflicts between the provided collection of fields\n // and the collection of fields represented by the given fragment.\n\n\n collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fieldMap2); // (E) Then collect any conflicts between the provided collection of fields\n // and any fragment names found in the given fragment.\n\n for (let i = 0; i < fragmentNames2.length; i++) {\n collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentNames2[i]);\n }\n} // Collect all conflicts found between two fragments, including via spreading in\n// any nested fragments.\n\n\nfunction collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentName1, fragmentName2) {\n // No need to compare a fragment to itself.\n if (fragmentName1 === fragmentName2) {\n return;\n } // Memoize so two fragments are not compared for conflicts more than once.\n\n\n if (comparedFragmentPairs.has(fragmentName1, fragmentName2, areMutuallyExclusive)) {\n return;\n }\n\n comparedFragmentPairs.add(fragmentName1, fragmentName2, areMutuallyExclusive);\n const fragment1 = context.getFragment(fragmentName1);\n const fragment2 = context.getFragment(fragmentName2);\n\n if (!fragment1 || !fragment2) {\n return;\n }\n\n const [fieldMap1, fragmentNames1] = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment1);\n const [fieldMap2, fragmentNames2] = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2); // (F) First, collect all conflicts between these two collections of fields\n // (not including any nested fragments).\n\n collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fieldMap2); // (G) Then collect conflicts between the first fragment and any nested\n // fragments spread in the second fragment.\n\n for (let j = 0; j < fragmentNames2.length; j++) {\n collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentName1, fragmentNames2[j]);\n } // (G) Then collect conflicts between the second fragment and any nested\n // fragments spread in the first fragment.\n\n\n for (let i = 0; i < fragmentNames1.length; i++) {\n collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentNames1[i], fragmentName2);\n }\n} // Find all conflicts found between two selection sets, including those found\n// via spreading in fragments. Called when determining if conflicts exist\n// between the sub-fields of two overlapping fields.\n\n\nfunction findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, parentType1, selectionSet1, parentType2, selectionSet2) {\n const conflicts = [];\n const [fieldMap1, fragmentNames1] = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType1, selectionSet1);\n const [fieldMap2, fragmentNames2] = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType2, selectionSet2); // (H) First, collect all conflicts between these two collections of field.\n\n collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fieldMap2); // (I) Then collect conflicts between the first collection of fields and\n // those referenced by each fragment name associated with the second.\n\n if (fragmentNames2.length !== 0) {\n for (let j = 0; j < fragmentNames2.length; j++) {\n collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fragmentNames2[j]);\n }\n } // (I) Then collect conflicts between the second collection of fields and\n // those referenced by each fragment name associated with the first.\n\n\n if (fragmentNames1.length !== 0) {\n for (let i = 0; i < fragmentNames1.length; i++) {\n collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap2, fragmentNames1[i]);\n }\n } // (J) Also collect conflicts between any fragment names by the first and\n // fragment names by the second. This compares each item in the first set of\n // names to each item in the second set of names.\n\n\n for (let i = 0; i < fragmentNames1.length; i++) {\n for (let j = 0; j < fragmentNames2.length; j++) {\n collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentNames1[i], fragmentNames2[j]);\n }\n }\n\n return conflicts;\n} // Collect all Conflicts \"within\" one collection of fields.\n\n\nfunction collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, fieldMap) {\n // A field map is a keyed collection, where each key represents a response\n // name and the value at that key is a list of all fields which provide that\n // response name. For every response name, if there are multiple fields, they\n // must be compared to find a potential conflict.\n for (const [responseName, fields] of objectEntries(fieldMap)) {\n // This compares every field in the list to every other field in this list\n // (except to itself). If the list only has one item, nothing needs to\n // be compared.\n if (fields.length > 1) {\n for (let i = 0; i < fields.length; i++) {\n for (let j = i + 1; j < fields.length; j++) {\n const conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, // within one collection is never mutually exclusive\n responseName, fields[i], fields[j]);\n\n if (conflict) {\n conflicts.push(conflict);\n }\n }\n }\n }\n }\n} // Collect all Conflicts between two collections of fields. This is similar to,\n// but different from the `collectConflictsWithin` function above. This check\n// assumes that `collectConflictsWithin` has already been called on each\n// provided collection of fields. This is true because this validator traverses\n// each individual selection set.\n\n\nfunction collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, fieldMap1, fieldMap2) {\n // A field map is a keyed collection, where each key represents a response\n // name and the value at that key is a list of all fields which provide that\n // response name. For any response name which appears in both provided field\n // maps, each field from the first field map must be compared to every field\n // in the second field map to find potential conflicts.\n for (const responseName of Object.keys(fieldMap1)) {\n const fields2 = fieldMap2[responseName];\n\n if (fields2) {\n const fields1 = fieldMap1[responseName];\n\n for (let i = 0; i < fields1.length; i++) {\n for (let j = 0; j < fields2.length; j++) {\n const conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, fields1[i], fields2[j]);\n\n if (conflict) {\n conflicts.push(conflict);\n }\n }\n }\n }\n }\n} // Determines if there is a conflict between two particular fields, including\n// comparing their sub-fields.\n\n\nfunction findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, field1, field2) {\n const [parentType1, node1, def1] = field1;\n const [parentType2, node2, def2] = field2; // If it is known that two fields could not possibly apply at the same\n // time, due to the parent types, then it is safe to permit them to diverge\n // in aliased field or arguments used as they will not present any ambiguity\n // by differing.\n // It is known that two parent types could never overlap if they are\n // different Object types. Interface or Union types might overlap - if not\n // in the current state of the schema, then perhaps in some future version,\n // thus may not safely diverge.\n\n const areMutuallyExclusive = parentFieldsAreMutuallyExclusive || parentType1 !== parentType2 && isObjectType(parentType1) && isObjectType(parentType2);\n\n if (!areMutuallyExclusive) {\n // Two aliases must refer to the same field.\n const name1 = node1.name.value;\n const name2 = node2.name.value;\n\n if (name1 !== name2) {\n return [[responseName, `\"${name1}\" and \"${name2}\" are different fields`], [node1], [node2]];\n } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n\n const args1 = node1.arguments ?? []; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n const args2 = node2.arguments ?? []; // Two field calls must have the same arguments.\n\n if (!sameArguments(args1, args2)) {\n return [[responseName, 'they have differing arguments'], [node1], [node2]];\n }\n } // The return type for each field.\n\n\n const type1 = def1?.type;\n const type2 = def2?.type;\n\n if (type1 && type2 && doTypesConflict(type1, type2)) {\n return [[responseName, `they return conflicting types \"${inspect(type1)}\" and \"${inspect(type2)}\"`], [node1], [node2]];\n } // Collect and compare sub-fields. Use the same \"visited fragment names\" list\n // for both collections so fields in a fragment reference are never\n // compared to themselves.\n\n\n const selectionSet1 = node1.selectionSet;\n const selectionSet2 = node2.selectionSet;\n\n if (selectionSet1 && selectionSet2) {\n const conflicts = findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, getNamedType(type1), selectionSet1, getNamedType(type2), selectionSet2);\n return subfieldConflicts(conflicts, responseName, node1, node2);\n }\n}\n\nfunction sameArguments(arguments1, arguments2) {\n if (arguments1.length !== arguments2.length) {\n return false;\n }\n\n return arguments1.every(argument1 => {\n const argument2 = arguments2.find(argument => argument.name.value === argument1.name.value);\n\n if (!argument2) {\n return false;\n }\n\n return sameValue(argument1.value, argument2.value);\n });\n}\n\nfunction sameValue(value1, value2) {\n return print(value1) === print(value2);\n} // Two types conflict if both types could not apply to a value simultaneously.\n// Composite types are ignored as their individual field types will be compared\n// later recursively. However List and Non-Null types must match.\n\n\nfunction doTypesConflict(type1, type2) {\n if (isListType(type1)) {\n return isListType(type2) ? doTypesConflict(type1.ofType, type2.ofType) : true;\n }\n\n if (isListType(type2)) {\n return true;\n }\n\n if (isNonNullType(type1)) {\n return isNonNullType(type2) ? doTypesConflict(type1.ofType, type2.ofType) : true;\n }\n\n if (isNonNullType(type2)) {\n return true;\n }\n\n if (isLeafType(type1) || isLeafType(type2)) {\n return type1 !== type2;\n }\n\n return false;\n} // Given a selection set, return the collection of fields (a mapping of response\n// name to field nodes and definitions) as well as a list of fragment names\n// referenced via fragment spreads.\n\n\nfunction getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet) {\n let cached = cachedFieldsAndFragmentNames.get(selectionSet);\n\n if (!cached) {\n const nodeAndDefs = Object.create(null);\n const fragmentNames = Object.create(null);\n\n _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames);\n\n cached = [nodeAndDefs, Object.keys(fragmentNames)];\n cachedFieldsAndFragmentNames.set(selectionSet, cached);\n }\n\n return cached;\n} // Given a reference to a fragment, return the represented collection of fields\n// as well as a list of nested fragment names referenced via fragment spreads.\n\n\nfunction getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment) {\n // Short-circuit building a type from the node if possible.\n const cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet);\n\n if (cached) {\n return cached;\n }\n\n const fragmentType = typeFromAST(context.getSchema(), fragment.typeCondition);\n return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment.selectionSet);\n}\n\nfunction _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {\n for (const selection of selectionSet.selections) {\n switch (selection.kind) {\n case Kind.FIELD:\n {\n const fieldName = selection.name.value;\n let fieldDef;\n\n if (isObjectType(parentType) || isInterfaceType(parentType)) {\n fieldDef = parentType.getFields()[fieldName];\n }\n\n const responseName = selection.alias ? selection.alias.value : fieldName;\n\n if (!nodeAndDefs[responseName]) {\n nodeAndDefs[responseName] = [];\n }\n\n nodeAndDefs[responseName].push([parentType, selection, fieldDef]);\n break;\n }\n\n case Kind.FRAGMENT_SPREAD:\n fragmentNames[selection.name.value] = true;\n break;\n\n case Kind.INLINE_FRAGMENT:\n {\n const typeCondition = selection.typeCondition;\n const inlineFragmentType = typeCondition ? typeFromAST(context.getSchema(), typeCondition) : parentType;\n\n _collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);\n\n break;\n }\n }\n }\n} // Given a series of Conflicts which occurred between two sub-fields, generate\n// a single Conflict.\n\n\nfunction subfieldConflicts(conflicts, responseName, node1, node2) {\n if (conflicts.length > 0) {\n return [[responseName, conflicts.map(([reason]) => reason)], conflicts.reduce((allFields, [, fields1]) => allFields.concat(fields1), [node1]), conflicts.reduce((allFields, [,, fields2]) => allFields.concat(fields2), [node2])];\n }\n}\n/**\n * A way to keep track of pairs of things when the ordering of the pair does\n * not matter. We do this by maintaining a sort of double adjacency sets.\n */\n\n\nclass PairSet {\n constructor() {\n this._data = Object.create(null);\n }\n\n has(a, b, areMutuallyExclusive) {\n const first = this._data[a];\n const result = first && first[b];\n\n if (result === undefined) {\n return false;\n } // areMutuallyExclusive being false is a superset of being true,\n // hence if we want to know if this PairSet \"has\" these two with no\n // exclusivity, we have to ensure it was added as such.\n\n\n if (areMutuallyExclusive === false) {\n return result === false;\n }\n\n return true;\n }\n\n add(a, b, areMutuallyExclusive) {\n this._pairSetAdd(a, b, areMutuallyExclusive);\n\n this._pairSetAdd(b, a, areMutuallyExclusive);\n }\n\n _pairSetAdd(a, b, areMutuallyExclusive) {\n let map = this._data[a];\n\n if (!map) {\n map = Object.create(null);\n this._data[a] = map;\n }\n\n map[b] = areMutuallyExclusive;\n }\n\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique input field names\n *\n * A GraphQL input object value is only valid if all supplied fields are\n * uniquely named.\n */\nexport function UniqueInputFieldNamesRule(context) {\n const knownNameStack = [];\n let knownNames = Object.create(null);\n return {\n ObjectValue: {\n enter() {\n knownNameStack.push(knownNames);\n knownNames = Object.create(null);\n },\n\n leave() {\n knownNames = knownNameStack.pop();\n }\n\n },\n\n ObjectField(node) {\n const fieldName = node.name.value;\n\n if (knownNames[fieldName]) {\n context.reportError(new GraphQLError(`There can be only one input field named \"${fieldName}\".`, [knownNames[fieldName], node.name]));\n } else {\n knownNames[fieldName] = node.name;\n }\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { isObjectType, isInterfaceType, isInputObjectType } from \"../../type/definition.mjs\";\n\n/**\n * Unique field definition names\n *\n * A GraphQL complex type is only valid if all its fields are uniquely named.\n */\nexport function UniqueFieldDefinitionNamesRule(context) {\n const schema = context.getSchema();\n const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);\n const knownFieldNames = Object.create(null);\n return {\n InputObjectTypeDefinition: checkFieldUniqueness,\n InputObjectTypeExtension: checkFieldUniqueness,\n InterfaceTypeDefinition: checkFieldUniqueness,\n InterfaceTypeExtension: checkFieldUniqueness,\n ObjectTypeDefinition: checkFieldUniqueness,\n ObjectTypeExtension: checkFieldUniqueness\n };\n\n function checkFieldUniqueness(node) {\n const typeName = node.name.value;\n\n if (!knownFieldNames[typeName]) {\n knownFieldNames[typeName] = Object.create(null);\n } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n\n const fieldNodes = node.fields ?? [];\n const fieldNames = knownFieldNames[typeName];\n\n for (const fieldDef of fieldNodes) {\n const fieldName = fieldDef.name.value;\n\n if (hasField(existingTypeMap[typeName], fieldName)) {\n context.reportError(new GraphQLError(`Field \"${typeName}.${fieldName}\" already exists in the schema. It cannot also be defined in this type extension.`, fieldDef.name));\n } else if (fieldNames[fieldName]) {\n context.reportError(new GraphQLError(`Field \"${typeName}.${fieldName}\" can only be defined once.`, [fieldNames[fieldName], fieldDef.name]));\n } else {\n fieldNames[fieldName] = fieldDef.name;\n }\n }\n\n return false;\n }\n}\n\nfunction hasField(type, fieldName) {\n if (isObjectType(type) || isInterfaceType(type) || isInputObjectType(type)) {\n return type.getFields()[fieldName] != null;\n }\n\n return false;\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport invariant from \"../../jsutils/invariant.mjs\";\nimport didYouMean from \"../../jsutils/didYouMean.mjs\";\nimport suggestionList from \"../../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { isTypeDefinitionNode } from \"../../language/predicates.mjs\";\nimport { isScalarType, isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType } from \"../../type/definition.mjs\";\n\n/**\n * Possible type extension\n *\n * A type extension is only valid if the type is defined and has the same kind.\n */\nexport function PossibleTypeExtensionsRule(context) {\n const schema = context.getSchema();\n const definedTypes = Object.create(null);\n\n for (const def of context.getDocument().definitions) {\n if (isTypeDefinitionNode(def)) {\n definedTypes[def.name.value] = def;\n }\n }\n\n return {\n ScalarTypeExtension: checkExtension,\n ObjectTypeExtension: checkExtension,\n InterfaceTypeExtension: checkExtension,\n UnionTypeExtension: checkExtension,\n EnumTypeExtension: checkExtension,\n InputObjectTypeExtension: checkExtension\n };\n\n function checkExtension(node) {\n const typeName = node.name.value;\n const defNode = definedTypes[typeName];\n const existingType = schema?.getType(typeName);\n let expectedKind;\n\n if (defNode) {\n expectedKind = defKindToExtKind[defNode.kind];\n } else if (existingType) {\n expectedKind = typeToExtKind(existingType);\n }\n\n if (expectedKind) {\n if (expectedKind !== node.kind) {\n const kindStr = extensionKindToTypeName(node.kind);\n context.reportError(new GraphQLError(`Cannot extend non-${kindStr} type \"${typeName}\".`, defNode ? [defNode, node] : node));\n }\n } else {\n let allTypeNames = Object.keys(definedTypes);\n\n if (schema) {\n allTypeNames = allTypeNames.concat(Object.keys(schema.getTypeMap()));\n }\n\n const suggestedTypes = suggestionList(typeName, allTypeNames);\n context.reportError(new GraphQLError(`Cannot extend type \"${typeName}\" because it is not defined.` + didYouMean(suggestedTypes), node.name));\n }\n }\n}\nconst defKindToExtKind = {\n [Kind.SCALAR_TYPE_DEFINITION]: Kind.SCALAR_TYPE_EXTENSION,\n [Kind.OBJECT_TYPE_DEFINITION]: Kind.OBJECT_TYPE_EXTENSION,\n [Kind.INTERFACE_TYPE_DEFINITION]: Kind.INTERFACE_TYPE_EXTENSION,\n [Kind.UNION_TYPE_DEFINITION]: Kind.UNION_TYPE_EXTENSION,\n [Kind.ENUM_TYPE_DEFINITION]: Kind.ENUM_TYPE_EXTENSION,\n [Kind.INPUT_OBJECT_TYPE_DEFINITION]: Kind.INPUT_OBJECT_TYPE_EXTENSION\n};\n\nfunction typeToExtKind(type) {\n if (isScalarType(type)) {\n return Kind.SCALAR_TYPE_EXTENSION;\n }\n\n if (isObjectType(type)) {\n return Kind.OBJECT_TYPE_EXTENSION;\n }\n\n if (isInterfaceType(type)) {\n return Kind.INTERFACE_TYPE_EXTENSION;\n }\n\n if (isUnionType(type)) {\n return Kind.UNION_TYPE_EXTENSION;\n }\n\n if (isEnumType(type)) {\n return Kind.ENUM_TYPE_EXTENSION;\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isInputObjectType(type)) {\n return Kind.INPUT_OBJECT_TYPE_EXTENSION;\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, 'Unexpected type: ' + inspect(type));\n}\n\nfunction extensionKindToTypeName(kind) {\n switch (kind) {\n case Kind.SCALAR_TYPE_EXTENSION:\n return 'scalar';\n\n case Kind.OBJECT_TYPE_EXTENSION:\n return 'object';\n\n case Kind.INTERFACE_TYPE_EXTENSION:\n return 'interface';\n\n case Kind.UNION_TYPE_EXTENSION:\n return 'union';\n\n case Kind.ENUM_TYPE_EXTENSION:\n return 'enum';\n\n case Kind.INPUT_OBJECT_TYPE_EXTENSION:\n return 'input object';\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, 'Unexpected kind: ' + inspect(kind));\n}\n","// Spec Section: \"Executable Definitions\"\nimport { ExecutableDefinitionsRule } from \"./rules/ExecutableDefinitionsRule.mjs\"; // Spec Section: \"Operation Name Uniqueness\"\n\nimport { UniqueOperationNamesRule } from \"./rules/UniqueOperationNamesRule.mjs\"; // Spec Section: \"Lone Anonymous Operation\"\n\nimport { LoneAnonymousOperationRule } from \"./rules/LoneAnonymousOperationRule.mjs\"; // Spec Section: \"Subscriptions with Single Root Field\"\n\nimport { SingleFieldSubscriptionsRule } from \"./rules/SingleFieldSubscriptionsRule.mjs\"; // Spec Section: \"Fragment Spread Type Existence\"\n\nimport { KnownTypeNamesRule } from \"./rules/KnownTypeNamesRule.mjs\"; // Spec Section: \"Fragments on Composite Types\"\n\nimport { FragmentsOnCompositeTypesRule } from \"./rules/FragmentsOnCompositeTypesRule.mjs\"; // Spec Section: \"Variables are Input Types\"\n\nimport { VariablesAreInputTypesRule } from \"./rules/VariablesAreInputTypesRule.mjs\"; // Spec Section: \"Leaf Field Selections\"\n\nimport { ScalarLeafsRule } from \"./rules/ScalarLeafsRule.mjs\"; // Spec Section: \"Field Selections on Objects, Interfaces, and Unions Types\"\n\nimport { FieldsOnCorrectTypeRule } from \"./rules/FieldsOnCorrectTypeRule.mjs\"; // Spec Section: \"Fragment Name Uniqueness\"\n\nimport { UniqueFragmentNamesRule } from \"./rules/UniqueFragmentNamesRule.mjs\"; // Spec Section: \"Fragment spread target defined\"\n\nimport { KnownFragmentNamesRule } from \"./rules/KnownFragmentNamesRule.mjs\"; // Spec Section: \"Fragments must be used\"\n\nimport { NoUnusedFragmentsRule } from \"./rules/NoUnusedFragmentsRule.mjs\"; // Spec Section: \"Fragment spread is possible\"\n\nimport { PossibleFragmentSpreadsRule } from \"./rules/PossibleFragmentSpreadsRule.mjs\"; // Spec Section: \"Fragments must not form cycles\"\n\nimport { NoFragmentCyclesRule } from \"./rules/NoFragmentCyclesRule.mjs\"; // Spec Section: \"Variable Uniqueness\"\n\nimport { UniqueVariableNamesRule } from \"./rules/UniqueVariableNamesRule.mjs\"; // Spec Section: \"All Variable Used Defined\"\n\nimport { NoUndefinedVariablesRule } from \"./rules/NoUndefinedVariablesRule.mjs\"; // Spec Section: \"All Variables Used\"\n\nimport { NoUnusedVariablesRule } from \"./rules/NoUnusedVariablesRule.mjs\"; // Spec Section: \"Directives Are Defined\"\n\nimport { KnownDirectivesRule } from \"./rules/KnownDirectivesRule.mjs\"; // Spec Section: \"Directives Are Unique Per Location\"\n\nimport { UniqueDirectivesPerLocationRule } from \"./rules/UniqueDirectivesPerLocationRule.mjs\"; // Spec Section: \"Argument Names\"\n\nimport { KnownArgumentNamesRule, KnownArgumentNamesOnDirectivesRule } from \"./rules/KnownArgumentNamesRule.mjs\"; // Spec Section: \"Argument Uniqueness\"\n\nimport { UniqueArgumentNamesRule } from \"./rules/UniqueArgumentNamesRule.mjs\"; // Spec Section: \"Value Type Correctness\"\n\nimport { ValuesOfCorrectTypeRule } from \"./rules/ValuesOfCorrectTypeRule.mjs\"; // Spec Section: \"Argument Optionality\"\n\nimport { ProvidedRequiredArgumentsRule, ProvidedRequiredArgumentsOnDirectivesRule } from \"./rules/ProvidedRequiredArgumentsRule.mjs\"; // Spec Section: \"All Variable Usages Are Allowed\"\n\nimport { VariablesInAllowedPositionRule } from \"./rules/VariablesInAllowedPositionRule.mjs\"; // Spec Section: \"Field Selection Merging\"\n\nimport { OverlappingFieldsCanBeMergedRule } from \"./rules/OverlappingFieldsCanBeMergedRule.mjs\"; // Spec Section: \"Input Object Field Uniqueness\"\n\nimport { UniqueInputFieldNamesRule } from \"./rules/UniqueInputFieldNamesRule.mjs\"; // SDL-specific validation rules\n\nimport { LoneSchemaDefinitionRule } from \"./rules/LoneSchemaDefinitionRule.mjs\";\nimport { UniqueOperationTypesRule } from \"./rules/UniqueOperationTypesRule.mjs\";\nimport { UniqueTypeNamesRule } from \"./rules/UniqueTypeNamesRule.mjs\";\nimport { UniqueEnumValueNamesRule } from \"./rules/UniqueEnumValueNamesRule.mjs\";\nimport { UniqueFieldDefinitionNamesRule } from \"./rules/UniqueFieldDefinitionNamesRule.mjs\";\nimport { UniqueDirectiveNamesRule } from \"./rules/UniqueDirectiveNamesRule.mjs\";\nimport { PossibleTypeExtensionsRule } from \"./rules/PossibleTypeExtensionsRule.mjs\";\n/**\n * This set includes all validation rules defined by the GraphQL spec.\n *\n * The order of the rules in this list has been adjusted to lead to the\n * most clear output when encountering multiple validation errors.\n */\n\nexport const specifiedRules = Object.freeze([ExecutableDefinitionsRule, UniqueOperationNamesRule, LoneAnonymousOperationRule, SingleFieldSubscriptionsRule, KnownTypeNamesRule, FragmentsOnCompositeTypesRule, VariablesAreInputTypesRule, ScalarLeafsRule, FieldsOnCorrectTypeRule, UniqueFragmentNamesRule, KnownFragmentNamesRule, NoUnusedFragmentsRule, PossibleFragmentSpreadsRule, NoFragmentCyclesRule, UniqueVariableNamesRule, NoUndefinedVariablesRule, NoUnusedVariablesRule, KnownDirectivesRule, UniqueDirectivesPerLocationRule, KnownArgumentNamesRule, UniqueArgumentNamesRule, ValuesOfCorrectTypeRule, ProvidedRequiredArgumentsRule, VariablesInAllowedPositionRule, OverlappingFieldsCanBeMergedRule, UniqueInputFieldNamesRule]);\n/**\n * @internal\n */\n\nexport const specifiedSDLRules = Object.freeze([LoneSchemaDefinitionRule, UniqueOperationTypesRule, UniqueTypeNamesRule, UniqueEnumValueNamesRule, UniqueFieldDefinitionNamesRule, UniqueDirectiveNamesRule, KnownTypeNamesRule, KnownDirectivesRule, UniqueDirectivesPerLocationRule, PossibleTypeExtensionsRule, KnownArgumentNamesOnDirectivesRule, UniqueArgumentNamesRule, UniqueInputFieldNamesRule, ProvidedRequiredArgumentsOnDirectivesRule]);\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\nimport { isExecutableDefinitionNode } from \"../../language/predicates.mjs\";\n\n/**\n * Executable definitions\n *\n * A GraphQL document is only valid for execution if all definitions are either\n * operation or fragment definitions.\n */\nexport function ExecutableDefinitionsRule(context) {\n return {\n Document(node) {\n for (const definition of node.definitions) {\n if (!isExecutableDefinitionNode(definition)) {\n const defName = definition.kind === Kind.SCHEMA_DEFINITION || definition.kind === Kind.SCHEMA_EXTENSION ? 'schema' : '\"' + definition.name.value + '\"';\n context.reportError(new GraphQLError(`The ${defName} definition is not executable.`, definition));\n }\n }\n\n return false;\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique operation names\n *\n * A GraphQL document is only valid if all defined operations have unique names.\n */\nexport function UniqueOperationNamesRule(context) {\n const knownOperationNames = Object.create(null);\n return {\n OperationDefinition(node) {\n const operationName = node.name;\n\n if (operationName) {\n if (knownOperationNames[operationName.value]) {\n context.reportError(new GraphQLError(`There can be only one operation named \"${operationName.value}\".`, [knownOperationNames[operationName.value], operationName]));\n } else {\n knownOperationNames[operationName.value] = operationName;\n }\n }\n\n return false;\n },\n\n FragmentDefinition: () => false\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { Kind } from \"../../language/kinds.mjs\";\n\n/**\n * Lone anonymous operation\n *\n * A GraphQL document is only valid if when it contains an anonymous operation\n * (the query short-hand) that it contains only that one operation definition.\n */\nexport function LoneAnonymousOperationRule(context) {\n let operationCount = 0;\n return {\n Document(node) {\n operationCount = node.definitions.filter(definition => definition.kind === Kind.OPERATION_DEFINITION).length;\n },\n\n OperationDefinition(node) {\n if (!node.name && operationCount > 1) {\n context.reportError(new GraphQLError('This anonymous operation must be the only defined operation.', node));\n }\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Subscriptions must only include one field.\n *\n * A GraphQL subscription is valid only if it contains a single root field.\n */\nexport function SingleFieldSubscriptionsRule(context) {\n return {\n OperationDefinition(node) {\n if (node.operation === 'subscription') {\n if (node.selectionSet.selections.length !== 1) {\n context.reportError(new GraphQLError(node.name ? `Subscription \"${node.name.value}\" must select only one top level field.` : 'Anonymous Subscription must select only one top level field.', node.selectionSet.selections.slice(1)));\n }\n }\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { print } from \"../../language/printer.mjs\";\nimport { isCompositeType } from \"../../type/definition.mjs\";\nimport { typeFromAST } from \"../../utilities/typeFromAST.mjs\";\n\n/**\n * Fragments on composite type\n *\n * Fragments use a type condition to determine if they apply, since fragments\n * can only be spread into a composite type (object, interface, or union), the\n * type condition must also be a composite type.\n */\nexport function FragmentsOnCompositeTypesRule(context) {\n return {\n InlineFragment(node) {\n const typeCondition = node.typeCondition;\n\n if (typeCondition) {\n const type = typeFromAST(context.getSchema(), typeCondition);\n\n if (type && !isCompositeType(type)) {\n const typeStr = print(typeCondition);\n context.reportError(new GraphQLError(`Fragment cannot condition on non composite type \"${typeStr}\".`, typeCondition));\n }\n }\n },\n\n FragmentDefinition(node) {\n const type = typeFromAST(context.getSchema(), node.typeCondition);\n\n if (type && !isCompositeType(type)) {\n const typeStr = print(node.typeCondition);\n context.reportError(new GraphQLError(`Fragment \"${node.name.value}\" cannot condition on non composite type \"${typeStr}\".`, node.typeCondition));\n }\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { print } from \"../../language/printer.mjs\";\nimport { isInputType } from \"../../type/definition.mjs\";\nimport { typeFromAST } from \"../../utilities/typeFromAST.mjs\";\n\n/**\n * Variables are input types\n *\n * A GraphQL operation is only valid if all the variables it defines are of\n * input types (scalar, enum, or input object).\n */\nexport function VariablesAreInputTypesRule(context) {\n return {\n VariableDefinition(node) {\n const type = typeFromAST(context.getSchema(), node.type);\n\n if (type && !isInputType(type)) {\n const variableName = node.variable.name.value;\n const typeName = print(node.type);\n context.reportError(new GraphQLError(`Variable \"$${variableName}\" cannot be non-input type \"${typeName}\".`, node.type));\n }\n }\n\n };\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { getNamedType, isLeafType } from \"../../type/definition.mjs\";\n\n/**\n * Scalar leafs\n *\n * A GraphQL document is valid only if all leaf fields (fields without\n * sub selections) are of scalar or enum types.\n */\nexport function ScalarLeafsRule(context) {\n return {\n Field(node) {\n const type = context.getType();\n const selectionSet = node.selectionSet;\n\n if (type) {\n if (isLeafType(getNamedType(type))) {\n if (selectionSet) {\n const fieldName = node.name.value;\n const typeStr = inspect(type);\n context.reportError(new GraphQLError(`Field \"${fieldName}\" must not have a selection since type \"${typeStr}\" has no subfields.`, selectionSet));\n }\n } else if (!selectionSet) {\n const fieldName = node.name.value;\n const typeStr = inspect(type);\n context.reportError(new GraphQLError(`Field \"${fieldName}\" of type \"${typeStr}\" must have a selection of subfields. Did you mean \"${fieldName} { ... }\"?`, node));\n }\n }\n }\n\n };\n}\n","import didYouMean from \"../../jsutils/didYouMean.mjs\";\nimport suggestionList from \"../../jsutils/suggestionList.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { isObjectType, isInterfaceType, isAbstractType } from \"../../type/definition.mjs\";\n\n/**\n * Fields on correct type\n *\n * A GraphQL document is only valid if all fields selected are defined by the\n * parent type, or are an allowed meta field such as __typename.\n */\nexport function FieldsOnCorrectTypeRule(context) {\n return {\n Field(node) {\n const type = context.getParentType();\n\n if (type) {\n const fieldDef = context.getFieldDef();\n\n if (!fieldDef) {\n // This field doesn't exist, lets look for suggestions.\n const schema = context.getSchema();\n const fieldName = node.name.value; // First determine if there are any suggested types to condition on.\n\n let suggestion = didYouMean('to use an inline fragment on', getSuggestedTypeNames(schema, type, fieldName)); // If there are no suggested types, then perhaps this was a typo?\n\n if (suggestion === '') {\n suggestion = didYouMean(getSuggestedFieldNames(type, fieldName));\n } // Report an error, including helpful suggestions.\n\n\n context.reportError(new GraphQLError(`Cannot query field \"${fieldName}\" on type \"${type.name}\".` + suggestion, node));\n }\n }\n }\n\n };\n}\n/**\n * Go through all of the implementations of type, as well as the interfaces that\n * they implement. If any of those types include the provided field, suggest them,\n * sorted by how often the type is referenced.\n */\n\nfunction getSuggestedTypeNames(schema, type, fieldName) {\n if (!isAbstractType(type)) {\n // Must be an Object type, which does not have possible fields.\n return [];\n }\n\n const suggestedTypes = new Set();\n const usageCount = Object.create(null);\n\n for (const possibleType of schema.getPossibleTypes(type)) {\n if (!possibleType.getFields()[fieldName]) {\n continue;\n } // This object type defines this field.\n\n\n suggestedTypes.add(possibleType);\n usageCount[possibleType.name] = 1;\n\n for (const possibleInterface of possibleType.getInterfaces()) {\n if (!possibleInterface.getFields()[fieldName]) {\n continue;\n } // This interface type defines this field.\n\n\n suggestedTypes.add(possibleInterface);\n usageCount[possibleInterface.name] = (usageCount[possibleInterface.name] ?? 0) + 1;\n }\n }\n\n return Array.from(suggestedTypes).sort((typeA, typeB) => {\n // Suggest both interface and object types based on how common they are.\n const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name];\n\n if (usageCountDiff !== 0) {\n return usageCountDiff;\n } // Suggest super types first followed by subtypes\n\n\n if (isInterfaceType(typeA) && schema.isSubType(typeA, typeB)) {\n return -1;\n }\n\n if (isInterfaceType(typeB) && schema.isSubType(typeB, typeA)) {\n return 1;\n }\n\n return typeA.name.localeCompare(typeB.name);\n }).map(x => x.name);\n}\n/**\n * For the field name provided, determine if there are any similar field names\n * that may be the result of a typo.\n */\n\n\nfunction getSuggestedFieldNames(type, fieldName) {\n if (isObjectType(type) || isInterfaceType(type)) {\n const possibleFieldNames = Object.keys(type.getFields());\n return suggestionList(fieldName, possibleFieldNames);\n } // Otherwise, must be a Union type, which does not define fields.\n\n\n return [];\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique fragment names\n *\n * A GraphQL document is only valid if all defined fragments have unique names.\n */\nexport function UniqueFragmentNamesRule(context) {\n const knownFragmentNames = Object.create(null);\n return {\n OperationDefinition: () => false,\n\n FragmentDefinition(node) {\n const fragmentName = node.name.value;\n\n if (knownFragmentNames[fragmentName]) {\n context.reportError(new GraphQLError(`There can be only one fragment named \"${fragmentName}\".`, [knownFragmentNames[fragmentName], node.name]));\n } else {\n knownFragmentNames[fragmentName] = node.name;\n }\n\n return false;\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Known fragment names\n *\n * A GraphQL document is only valid if all `...Fragment` fragment spreads refer\n * to fragments defined in the same document.\n */\nexport function KnownFragmentNamesRule(context) {\n return {\n FragmentSpread(node) {\n const fragmentName = node.name.value;\n const fragment = context.getFragment(fragmentName);\n\n if (!fragment) {\n context.reportError(new GraphQLError(`Unknown fragment \"${fragmentName}\".`, node.name));\n }\n }\n\n };\n}\n","import inspect from \"../../jsutils/inspect.mjs\";\nimport { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { isCompositeType } from \"../../type/definition.mjs\";\nimport { typeFromAST } from \"../../utilities/typeFromAST.mjs\";\nimport { doTypesOverlap } from \"../../utilities/typeComparators.mjs\";\n\n/**\n * Possible fragment spread\n *\n * A fragment spread is only valid if the type condition could ever possibly\n * be true: if there is a non-empty intersection of the possible parent types,\n * and possible types which pass the type condition.\n */\nexport function PossibleFragmentSpreadsRule(context) {\n return {\n InlineFragment(node) {\n const fragType = context.getType();\n const parentType = context.getParentType();\n\n if (isCompositeType(fragType) && isCompositeType(parentType) && !doTypesOverlap(context.getSchema(), fragType, parentType)) {\n const parentTypeStr = inspect(parentType);\n const fragTypeStr = inspect(fragType);\n context.reportError(new GraphQLError(`Fragment cannot be spread here as objects of type \"${parentTypeStr}\" can never be of type \"${fragTypeStr}\".`, node));\n }\n },\n\n FragmentSpread(node) {\n const fragName = node.name.value;\n const fragType = getFragmentType(context, fragName);\n const parentType = context.getParentType();\n\n if (fragType && parentType && !doTypesOverlap(context.getSchema(), fragType, parentType)) {\n const parentTypeStr = inspect(parentType);\n const fragTypeStr = inspect(fragType);\n context.reportError(new GraphQLError(`Fragment \"${fragName}\" cannot be spread here as objects of type \"${parentTypeStr}\" can never be of type \"${fragTypeStr}\".`, node));\n }\n }\n\n };\n}\n\nfunction getFragmentType(context, name) {\n const frag = context.getFragment(name);\n\n if (frag) {\n const type = typeFromAST(context.getSchema(), frag.typeCondition);\n\n if (isCompositeType(type)) {\n return type;\n }\n }\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nexport function NoFragmentCyclesRule(context) {\n // Tracks already visited fragments to maintain O(N) and to ensure that cycles\n // are not redundantly reported.\n const visitedFrags = Object.create(null); // Array of AST nodes used to produce meaningful errors\n\n const spreadPath = []; // Position in the spread path\n\n const spreadPathIndexByName = Object.create(null);\n return {\n OperationDefinition: () => false,\n\n FragmentDefinition(node) {\n detectCycleRecursive(node);\n return false;\n }\n\n }; // This does a straight-forward DFS to find cycles.\n // It does not terminate when a cycle was found but continues to explore\n // the graph to find all possible cycles.\n\n function detectCycleRecursive(fragment) {\n if (visitedFrags[fragment.name.value]) {\n return;\n }\n\n const fragmentName = fragment.name.value;\n visitedFrags[fragmentName] = true;\n const spreadNodes = context.getFragmentSpreads(fragment.selectionSet);\n\n if (spreadNodes.length === 0) {\n return;\n }\n\n spreadPathIndexByName[fragmentName] = spreadPath.length;\n\n for (const spreadNode of spreadNodes) {\n const spreadName = spreadNode.name.value;\n const cycleIndex = spreadPathIndexByName[spreadName];\n spreadPath.push(spreadNode);\n\n if (cycleIndex === undefined) {\n const spreadFragment = context.getFragment(spreadName);\n\n if (spreadFragment) {\n detectCycleRecursive(spreadFragment);\n }\n } else {\n const cyclePath = spreadPath.slice(cycleIndex);\n const viaPath = cyclePath.slice(0, -1).map(s => '\"' + s.name.value + '\"').join(', ');\n context.reportError(new GraphQLError(`Cannot spread fragment \"${spreadName}\" within itself` + (viaPath !== '' ? ` via ${viaPath}.` : '.'), cyclePath));\n }\n\n spreadPath.pop();\n }\n\n spreadPathIndexByName[fragmentName] = undefined;\n }\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique variable names\n *\n * A GraphQL operation is only valid if all its variables are uniquely named.\n */\nexport function UniqueVariableNamesRule(context) {\n let knownVariableNames = Object.create(null);\n return {\n OperationDefinition() {\n knownVariableNames = Object.create(null);\n },\n\n VariableDefinition(node) {\n const variableName = node.variable.name.value;\n\n if (knownVariableNames[variableName]) {\n context.reportError(new GraphQLError(`There can be only one variable named \"$${variableName}\".`, [knownVariableNames[variableName], node.variable.name]));\n } else {\n knownVariableNames[variableName] = node.variable.name;\n }\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * No undefined variables\n *\n * A GraphQL operation is only valid if all variables encountered, both directly\n * and via fragment spreads, are defined by that operation.\n */\nexport function NoUndefinedVariablesRule(context) {\n let variableNameDefined = Object.create(null);\n return {\n OperationDefinition: {\n enter() {\n variableNameDefined = Object.create(null);\n },\n\n leave(operation) {\n const usages = context.getRecursiveVariableUsages(operation);\n\n for (const {\n node\n } of usages) {\n const varName = node.name.value;\n\n if (variableNameDefined[varName] !== true) {\n context.reportError(new GraphQLError(operation.name ? `Variable \"$${varName}\" is not defined by operation \"${operation.name.value}\".` : `Variable \"$${varName}\" is not defined.`, [node, operation]));\n }\n }\n }\n\n },\n\n VariableDefinition(node) {\n variableNameDefined[node.variable.name.value] = true;\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * No unused variables\n *\n * A GraphQL operation is only valid if all variables defined by an operation\n * are used, either directly or within a spread fragment.\n */\nexport function NoUnusedVariablesRule(context) {\n let variableDefs = [];\n return {\n OperationDefinition: {\n enter() {\n variableDefs = [];\n },\n\n leave(operation) {\n const variableNameUsed = Object.create(null);\n const usages = context.getRecursiveVariableUsages(operation);\n\n for (const {\n node\n } of usages) {\n variableNameUsed[node.name.value] = true;\n }\n\n for (const variableDef of variableDefs) {\n const variableName = variableDef.variable.name.value;\n\n if (variableNameUsed[variableName] !== true) {\n context.reportError(new GraphQLError(operation.name ? `Variable \"$${variableName}\" is never used in operation \"${operation.name.value}\".` : `Variable \"$${variableName}\" is never used.`, variableDef));\n }\n }\n }\n\n },\n\n VariableDefinition(def) {\n variableDefs.push(def);\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Lone Schema definition\n *\n * A GraphQL document is only valid if it contains only one schema definition.\n */\nexport function LoneSchemaDefinitionRule(context) {\n const oldSchema = context.getSchema();\n const alreadyDefined = oldSchema?.astNode ?? oldSchema?.getQueryType() ?? oldSchema?.getMutationType() ?? oldSchema?.getSubscriptionType();\n let schemaDefinitionsCount = 0;\n return {\n SchemaDefinition(node) {\n if (alreadyDefined) {\n context.reportError(new GraphQLError('Cannot define a new schema within a schema extension.', node));\n return;\n }\n\n if (schemaDefinitionsCount > 0) {\n context.reportError(new GraphQLError('Must provide only one schema definition.', node));\n }\n\n ++schemaDefinitionsCount;\n }\n\n };\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique operation types\n *\n * A GraphQL document is only valid if it has only one type per operation.\n */\nexport function UniqueOperationTypesRule(context) {\n const schema = context.getSchema();\n const definedOperationTypes = Object.create(null);\n const existingOperationTypes = schema ? {\n query: schema.getQueryType(),\n mutation: schema.getMutationType(),\n subscription: schema.getSubscriptionType()\n } : {};\n return {\n SchemaDefinition: checkOperationTypes,\n SchemaExtension: checkOperationTypes\n };\n\n function checkOperationTypes(node) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const operationTypesNodes = node.operationTypes ?? [];\n\n for (const operationType of operationTypesNodes) {\n const operation = operationType.operation;\n const alreadyDefinedOperationType = definedOperationTypes[operation];\n\n if (existingOperationTypes[operation]) {\n context.reportError(new GraphQLError(`Type for ${operation} already defined in the schema. It cannot be redefined.`, operationType));\n } else if (alreadyDefinedOperationType) {\n context.reportError(new GraphQLError(`There can be only one ${operation} type in schema.`, [alreadyDefinedOperationType, operationType]));\n } else {\n definedOperationTypes[operation] = operationType;\n }\n }\n\n return false;\n }\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique type names\n *\n * A GraphQL document is only valid if all defined types have unique names.\n */\nexport function UniqueTypeNamesRule(context) {\n const knownTypeNames = Object.create(null);\n const schema = context.getSchema();\n return {\n ScalarTypeDefinition: checkTypeName,\n ObjectTypeDefinition: checkTypeName,\n InterfaceTypeDefinition: checkTypeName,\n UnionTypeDefinition: checkTypeName,\n EnumTypeDefinition: checkTypeName,\n InputObjectTypeDefinition: checkTypeName\n };\n\n function checkTypeName(node) {\n const typeName = node.name.value;\n\n if (schema?.getType(typeName)) {\n context.reportError(new GraphQLError(`Type \"${typeName}\" already exists in the schema. It cannot also be defined in this type definition.`, node.name));\n return;\n }\n\n if (knownTypeNames[typeName]) {\n context.reportError(new GraphQLError(`There can be only one type named \"${typeName}\".`, [knownTypeNames[typeName], node.name]));\n } else {\n knownTypeNames[typeName] = node.name;\n }\n\n return false;\n }\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\nimport { isEnumType } from \"../../type/definition.mjs\";\n\n/**\n * Unique enum value names\n *\n * A GraphQL enum type is only valid if all its values are uniquely named.\n */\nexport function UniqueEnumValueNamesRule(context) {\n const schema = context.getSchema();\n const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);\n const knownValueNames = Object.create(null);\n return {\n EnumTypeDefinition: checkValueUniqueness,\n EnumTypeExtension: checkValueUniqueness\n };\n\n function checkValueUniqueness(node) {\n const typeName = node.name.value;\n\n if (!knownValueNames[typeName]) {\n knownValueNames[typeName] = Object.create(null);\n } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n\n const valueNodes = node.values ?? [];\n const valueNames = knownValueNames[typeName];\n\n for (const valueDef of valueNodes) {\n const valueName = valueDef.name.value;\n const existingType = existingTypeMap[typeName];\n\n if (isEnumType(existingType) && existingType.getValue(valueName)) {\n context.reportError(new GraphQLError(`Enum value \"${typeName}.${valueName}\" already exists in the schema. It cannot also be defined in this type extension.`, valueDef.name));\n } else if (valueNames[valueName]) {\n context.reportError(new GraphQLError(`Enum value \"${typeName}.${valueName}\" can only be defined once.`, [valueNames[valueName], valueDef.name]));\n } else {\n valueNames[valueName] = valueDef.name;\n }\n }\n\n return false;\n }\n}\n","import { GraphQLError } from \"../../error/GraphQLError.mjs\";\n\n/**\n * Unique directive names\n *\n * A GraphQL document is only valid if all defined directives have unique names.\n */\nexport function UniqueDirectiveNamesRule(context) {\n const knownDirectiveNames = Object.create(null);\n const schema = context.getSchema();\n return {\n DirectiveDefinition(node) {\n const directiveName = node.name.value;\n\n if (schema?.getDirective(directiveName)) {\n context.reportError(new GraphQLError(`Directive \"@${directiveName}\" already exists in the schema. It cannot be redefined.`, node.name));\n return;\n }\n\n if (knownDirectiveNames[directiveName]) {\n context.reportError(new GraphQLError(`There can be only one directive named \"@${directiveName}\".`, [knownDirectiveNames[directiveName], node.name]));\n } else {\n knownDirectiveNames[directiveName] = node.name;\n }\n\n return false;\n }\n\n };\n}\n","import { Kind } from \"../language/kinds.mjs\";\nimport { visit } from \"../language/visitor.mjs\";\nimport { TypeInfo, visitWithTypeInfo } from \"../utilities/TypeInfo.mjs\";\n\n/**\n * An instance of this class is passed as the \"this\" context to all validators,\n * allowing access to commonly useful contextual information from within a\n * validation rule.\n */\nexport class ASTValidationContext {\n constructor(ast, onError) {\n this._ast = ast;\n this._fragments = undefined;\n this._fragmentSpreads = new Map();\n this._recursivelyReferencedFragments = new Map();\n this._onError = onError;\n }\n\n reportError(error) {\n this._onError(error);\n }\n\n getDocument() {\n return this._ast;\n }\n\n getFragment(name) {\n let fragments = this._fragments;\n\n if (!fragments) {\n this._fragments = fragments = this.getDocument().definitions.reduce((frags, statement) => {\n if (statement.kind === Kind.FRAGMENT_DEFINITION) {\n frags[statement.name.value] = statement;\n }\n\n return frags;\n }, Object.create(null));\n }\n\n return fragments[name];\n }\n\n getFragmentSpreads(node) {\n let spreads = this._fragmentSpreads.get(node);\n\n if (!spreads) {\n spreads = [];\n const setsToVisit = [node];\n\n while (setsToVisit.length !== 0) {\n const set = setsToVisit.pop();\n\n for (const selection of set.selections) {\n if (selection.kind === Kind.FRAGMENT_SPREAD) {\n spreads.push(selection);\n } else if (selection.selectionSet) {\n setsToVisit.push(selection.selectionSet);\n }\n }\n }\n\n this._fragmentSpreads.set(node, spreads);\n }\n\n return spreads;\n }\n\n getRecursivelyReferencedFragments(operation) {\n let fragments = this._recursivelyReferencedFragments.get(operation);\n\n if (!fragments) {\n fragments = [];\n const collectedNames = Object.create(null);\n const nodesToVisit = [operation.selectionSet];\n\n while (nodesToVisit.length !== 0) {\n const node = nodesToVisit.pop();\n\n for (const spread of this.getFragmentSpreads(node)) {\n const fragName = spread.name.value;\n\n if (collectedNames[fragName] !== true) {\n collectedNames[fragName] = true;\n const fragment = this.getFragment(fragName);\n\n if (fragment) {\n fragments.push(fragment);\n nodesToVisit.push(fragment.selectionSet);\n }\n }\n }\n }\n\n this._recursivelyReferencedFragments.set(operation, fragments);\n }\n\n return fragments;\n }\n\n}\nexport class SDLValidationContext extends ASTValidationContext {\n constructor(ast, schema, onError) {\n super(ast, onError);\n this._schema = schema;\n }\n\n getSchema() {\n return this._schema;\n }\n\n}\nexport class ValidationContext extends ASTValidationContext {\n constructor(schema, ast, typeInfo, onError) {\n super(ast, onError);\n this._schema = schema;\n this._typeInfo = typeInfo;\n this._variableUsages = new Map();\n this._recursiveVariableUsages = new Map();\n }\n\n getSchema() {\n return this._schema;\n }\n\n getVariableUsages(node) {\n let usages = this._variableUsages.get(node);\n\n if (!usages) {\n const newUsages = [];\n const typeInfo = new TypeInfo(this._schema);\n visit(node, visitWithTypeInfo(typeInfo, {\n VariableDefinition: () => false,\n\n Variable(variable) {\n newUsages.push({\n node: variable,\n type: typeInfo.getInputType(),\n defaultValue: typeInfo.getDefaultValue()\n });\n }\n\n }));\n usages = newUsages;\n\n this._variableUsages.set(node, usages);\n }\n\n return usages;\n }\n\n getRecursiveVariableUsages(operation) {\n let usages = this._recursiveVariableUsages.get(operation);\n\n if (!usages) {\n usages = this.getVariableUsages(operation);\n\n for (const frag of this.getRecursivelyReferencedFragments(operation)) {\n usages = usages.concat(this.getVariableUsages(frag));\n }\n\n this._recursiveVariableUsages.set(operation, usages);\n }\n\n return usages;\n }\n\n getType() {\n return this._typeInfo.getType();\n }\n\n getParentType() {\n return this._typeInfo.getParentType();\n }\n\n getInputType() {\n return this._typeInfo.getInputType();\n }\n\n getParentInputType() {\n return this._typeInfo.getParentInputType();\n }\n\n getFieldDef() {\n return this._typeInfo.getFieldDef();\n }\n\n getDirective() {\n return this._typeInfo.getDirective();\n }\n\n getArgument() {\n return this._typeInfo.getArgument();\n }\n\n getEnumValue() {\n return this._typeInfo.getEnumValue();\n }\n\n}\n","import devAssert from \"../jsutils/devAssert.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nimport { visit, visitInParallel } from \"../language/visitor.mjs\";\nimport { assertValidSchema } from \"../type/validate.mjs\";\nimport { TypeInfo, visitWithTypeInfo } from \"../utilities/TypeInfo.mjs\";\nimport { specifiedRules, specifiedSDLRules } from \"./specifiedRules.mjs\";\nimport { SDLValidationContext, ValidationContext } from \"./ValidationContext.mjs\";\n/**\n * Implements the \"Validation\" section of the spec.\n *\n * Validation runs synchronously, returning an array of encountered errors, or\n * an empty array if no errors were encountered and the document is valid.\n *\n * A list of specific validation rules may be provided. If not provided, the\n * default list of rules defined by the GraphQL specification will be used.\n *\n * Each validation rules is a function which returns a visitor\n * (see the language/visitor API). Visitor methods are expected to return\n * GraphQLErrors, or Arrays of GraphQLErrors when invalid.\n *\n * Optionally a custom TypeInfo instance may be provided. If not provided, one\n * will be created from the provided schema.\n */\n\nexport function validate(schema, documentAST, rules = specifiedRules, typeInfo = new TypeInfo(schema), options = {\n maxErrors: undefined\n}) {\n documentAST || devAssert(0, 'Must provide document.'); // If the schema used for validation is invalid, throw an error.\n\n assertValidSchema(schema);\n const abortObj = Object.freeze({});\n const errors = [];\n const context = new ValidationContext(schema, documentAST, typeInfo, error => {\n if (options.maxErrors != null && errors.length >= options.maxErrors) {\n errors.push(new GraphQLError('Too many validation errors, error limit reached. Validation aborted.'));\n throw abortObj;\n }\n\n errors.push(error);\n }); // This uses a specialized visitor which runs multiple visitors in parallel,\n // while maintaining the visitor skip and break API.\n\n const visitor = visitInParallel(rules.map(rule => rule(context))); // Visit the whole document with each instance of all provided rules.\n\n try {\n visit(documentAST, visitWithTypeInfo(typeInfo, visitor));\n } catch (e) {\n if (e !== abortObj) {\n throw e;\n }\n }\n\n return errors;\n}\n/**\n * @internal\n */\n\nexport function validateSDL(documentAST, schemaToExtend, rules = specifiedSDLRules) {\n const errors = [];\n const context = new SDLValidationContext(documentAST, schemaToExtend, error => {\n errors.push(error);\n });\n const visitors = rules.map(rule => rule(context));\n visit(documentAST, visitInParallel(visitors));\n return errors;\n}\n/**\n * Utility function which asserts a SDL document is valid by throwing an error\n * if it is invalid.\n *\n * @internal\n */\n\nexport function assertValidSDL(documentAST) {\n const errors = validateSDL(documentAST);\n\n if (errors.length !== 0) {\n throw new Error(errors.map(error => error.message).join('\\n\\n'));\n }\n}\n/**\n * Utility function which asserts a SDL document is valid by throwing an error\n * if it is invalid.\n *\n * @internal\n */\n\nexport function assertValidSDLExtension(documentAST, schema) {\n const errors = validateSDL(documentAST, schema);\n\n if (errors.length !== 0) {\n throw new Error(errors.map(error => error.message).join('\\n\\n'));\n }\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport keyMap from \"../jsutils/keyMap.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { isLeafType, isInputObjectType, isListType, isNonNullType } from \"../type/definition.mjs\";\n/**\n * Produces a JavaScript value given a GraphQL Value AST.\n *\n * A GraphQL type must be provided, which will be used to interpret different\n * GraphQL Value literals.\n *\n * Returns `undefined` when the value could not be validly coerced according to\n * the provided type.\n *\n * | GraphQL Value | JSON Value |\n * | -------------------- | ------------- |\n * | Input Object | Object |\n * | List | Array |\n * | Boolean | Boolean |\n * | String | String |\n * | Int / Float | Number |\n * | Enum Value | Mixed |\n * | NullValue | null |\n *\n */\n\nexport function valueFromAST(valueNode, type, variables) {\n if (!valueNode) {\n // When there is no node, then there is also no value.\n // Importantly, this is different from returning the value null.\n return;\n }\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n\n if (variables == null || variables[variableName] === undefined) {\n // No valid return value.\n return;\n }\n\n const variableValue = variables[variableName];\n\n if (variableValue === null && isNonNullType(type)) {\n return; // Invalid: intentionally return no value.\n } // Note: This does no further checking that this variable is correct.\n // This assumes that this query has been validated and the variable\n // usage here is of the correct type.\n\n\n return variableValue;\n }\n\n if (isNonNullType(type)) {\n if (valueNode.kind === Kind.NULL) {\n return; // Invalid: intentionally return no value.\n }\n\n return valueFromAST(valueNode, type.ofType, variables);\n }\n\n if (valueNode.kind === Kind.NULL) {\n // This is explicitly returning the value null.\n return null;\n }\n\n if (isListType(type)) {\n const itemType = type.ofType;\n\n if (valueNode.kind === Kind.LIST) {\n const coercedValues = [];\n\n for (const itemNode of valueNode.values) {\n if (isMissingVariable(itemNode, variables)) {\n // If an array contains a missing variable, it is either coerced to\n // null or if the item type is non-null, it considered invalid.\n if (isNonNullType(itemType)) {\n return; // Invalid: intentionally return no value.\n }\n\n coercedValues.push(null);\n } else {\n const itemValue = valueFromAST(itemNode, itemType, variables);\n\n if (itemValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n\n coercedValues.push(itemValue);\n }\n }\n\n return coercedValues;\n }\n\n const coercedValue = valueFromAST(valueNode, itemType, variables);\n\n if (coercedValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n\n return [coercedValue];\n }\n\n if (isInputObjectType(type)) {\n if (valueNode.kind !== Kind.OBJECT) {\n return; // Invalid: intentionally return no value.\n }\n\n const coercedObj = Object.create(null);\n const fieldNodes = keyMap(valueNode.fields, field => field.name.value);\n\n for (const field of objectValues(type.getFields())) {\n const fieldNode = fieldNodes[field.name];\n\n if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {\n if (field.defaultValue !== undefined) {\n coercedObj[field.name] = field.defaultValue;\n } else if (isNonNullType(field.type)) {\n return; // Invalid: intentionally return no value.\n }\n\n continue;\n }\n\n const fieldValue = valueFromAST(fieldNode.value, field.type, variables);\n\n if (fieldValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n\n coercedObj[field.name] = fieldValue;\n }\n\n return coercedObj;\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isLeafType(type)) {\n // Scalars and Enums fulfill parsing a literal value via parseLiteral().\n // Invalid values represent a failure to parse correctly, in which case\n // no value is returned.\n let result;\n\n try {\n result = type.parseLiteral(valueNode, variables);\n } catch (_error) {\n return; // Invalid: intentionally return no value.\n }\n\n if (result === undefined) {\n return; // Invalid: intentionally return no value.\n }\n\n return result;\n } // istanbul ignore next (Not reachable. All possible input types have been considered)\n\n\n false || invariant(0, 'Unexpected input type: ' + inspect(type));\n} // Returns true if the provided valueNode is a variable which is not defined\n// in the set of variables.\n\nfunction isMissingVariable(valueNode, variables) {\n return valueNode.kind === Kind.VARIABLE && (variables == null || variables[valueNode.name.value] === undefined);\n}\n","import keyMap from \"../jsutils/keyMap.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport printPathArray from \"../jsutils/printPathArray.mjs\";\nimport { GraphQLError } from \"../error/GraphQLError.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { print } from \"../language/printer.mjs\";\nimport { isInputType, isNonNullType } from \"../type/definition.mjs\";\nimport { typeFromAST } from \"../utilities/typeFromAST.mjs\";\nimport { valueFromAST } from \"../utilities/valueFromAST.mjs\";\nimport { coerceInputValue } from \"../utilities/coerceInputValue.mjs\";\n\n/**\n * Prepares an object map of variableValues of the correct type based on the\n * provided variable definitions and arbitrary input. If the input cannot be\n * parsed to match the variable definitions, a GraphQLError will be thrown.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getVariableValues(schema, varDefNodes, inputs, options) {\n const errors = [];\n const maxErrors = options?.maxErrors;\n\n try {\n const coerced = coerceVariableValues(schema, varDefNodes, inputs, error => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError('Too many errors processing variables, error limit reached. Execution aborted.');\n }\n\n errors.push(error);\n });\n\n if (errors.length === 0) {\n return {\n coerced\n };\n }\n } catch (error) {\n errors.push(error);\n }\n\n return {\n errors\n };\n}\n\nfunction coerceVariableValues(schema, varDefNodes, inputs, onError) {\n const coercedValues = {};\n\n for (const varDefNode of varDefNodes) {\n const varName = varDefNode.variable.name.value;\n const varType = typeFromAST(schema, varDefNode.type);\n\n if (!isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = print(varDefNode.type);\n onError(new GraphQLError(`Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`, varDefNode.type));\n continue;\n }\n\n if (!hasOwnProperty(inputs, varName)) {\n if (varDefNode.defaultValue) {\n coercedValues[varName] = valueFromAST(varDefNode.defaultValue, varType);\n } else if (isNonNullType(varType)) {\n const varTypeStr = inspect(varType);\n onError(new GraphQLError(`Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`, varDefNode));\n }\n\n continue;\n }\n\n const value = inputs[varName];\n\n if (value === null && isNonNullType(varType)) {\n const varTypeStr = inspect(varType);\n onError(new GraphQLError(`Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`, varDefNode));\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(value, varType, (path, invalidValue, error) => {\n let prefix = `Variable \"$${varName}\" got invalid value ` + inspect(invalidValue);\n\n if (path.length > 0) {\n prefix += ` at \"${varName}${printPathArray(path)}\"`;\n }\n\n onError(new GraphQLError(prefix + '; ' + error.message, varDefNode, undefined, undefined, undefined, error.originalError));\n });\n }\n\n return coercedValues;\n}\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\n\n\nexport function getArgumentValues(def, node, variableValues) {\n const coercedValues = {}; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n\n const argumentNodes = node.arguments ?? [];\n const argNodeMap = keyMap(argumentNodes, arg => arg.name.value);\n\n for (const argDef of def.args) {\n const name = argDef.name;\n const argType = argDef.type;\n const argumentNode = argNodeMap[name];\n\n if (!argumentNode) {\n if (argDef.defaultValue !== undefined) {\n coercedValues[name] = argDef.defaultValue;\n } else if (isNonNullType(argType)) {\n throw new GraphQLError(`Argument \"${name}\" of required type \"${inspect(argType)}\" ` + 'was not provided.', node);\n }\n\n continue;\n }\n\n const valueNode = argumentNode.value;\n let isNull = valueNode.kind === Kind.NULL;\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n\n if (variableValues == null || !hasOwnProperty(variableValues, variableName)) {\n if (argDef.defaultValue !== undefined) {\n coercedValues[name] = argDef.defaultValue;\n } else if (isNonNullType(argType)) {\n throw new GraphQLError(`Argument \"${name}\" of required type \"${inspect(argType)}\" ` + `was provided the variable \"$${variableName}\" which was not provided a runtime value.`, valueNode);\n }\n\n continue;\n }\n\n isNull = variableValues[variableName] == null;\n }\n\n if (isNull && isNonNullType(argType)) {\n throw new GraphQLError(`Argument \"${name}\" of non-null type \"${inspect(argType)}\" ` + 'must not be null.', valueNode);\n }\n\n const coercedValue = valueFromAST(valueNode, argType, variableValues);\n\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectTypeRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw new GraphQLError(`Argument \"${name}\" has invalid value ${print(valueNode)}.`, valueNode);\n }\n\n coercedValues[name] = coercedValue;\n }\n\n return coercedValues;\n}\n/**\n * Prepares an object map of argument values given a directive definition\n * and a AST node which may contain directives. Optionally also accepts a map\n * of variable values.\n *\n * If the directive does not exist on the node, returns undefined.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\n\nexport function getDirectiveValues(directiveDef, node, variableValues) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const directiveNode = node.directives?.find(directive => directive.name.value === directiveDef.name);\n\n if (directiveNode) {\n return getArgumentValues(directiveDef, directiveNode, variableValues);\n }\n}\n\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport keyValMap from \"../jsutils/keyValMap.mjs\";\nimport isObjectLike from \"../jsutils/isObjectLike.mjs\";\nimport { parseValue } from \"../language/parser.mjs\";\nimport { GraphQLSchema } from \"../type/schema.mjs\";\nimport { GraphQLDirective } from \"../type/directives.mjs\";\nimport { specifiedScalarTypes } from \"../type/scalars.mjs\";\nimport { introspectionTypes, TypeKind } from \"../type/introspection.mjs\";\nimport { isInputType, isOutputType, GraphQLList, GraphQLNonNull, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType, assertNullableType, assertObjectType, assertInterfaceType } from \"../type/definition.mjs\";\nimport { valueFromAST } from \"./valueFromAST.mjs\";\n/**\n * Build a GraphQLSchema for use by client tools.\n *\n * Given the result of a client running the introspection query, creates and\n * returns a GraphQLSchema instance which can be then used with all graphql-js\n * tools, but cannot be used to execute a query, as introspection does not\n * represent the \"resolver\", \"parse\" or \"serialize\" functions or any other\n * server-internal mechanisms.\n *\n * This function expects a complete introspection result. Don't forget to check\n * the \"errors\" field of a server response before calling this function.\n */\n\nexport function buildClientSchema(introspection, options) {\n isObjectLike(introspection) && isObjectLike(introspection.__schema) || devAssert(0, `Invalid or incomplete introspection result. Ensure that you are passing \"data\" property of introspection response and no \"errors\" was returned alongside: ${inspect(introspection)}.`); // Get the schema from the introspection result.\n\n const schemaIntrospection = introspection.__schema; // Iterate through all types, getting the type definition for each.\n\n const typeMap = keyValMap(schemaIntrospection.types, typeIntrospection => typeIntrospection.name, typeIntrospection => buildType(typeIntrospection)); // Include standard types only if they are used.\n\n for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) {\n if (typeMap[stdType.name]) {\n typeMap[stdType.name] = stdType;\n }\n } // Get the root Query, Mutation, and Subscription types.\n\n\n const queryType = schemaIntrospection.queryType ? getObjectType(schemaIntrospection.queryType) : null;\n const mutationType = schemaIntrospection.mutationType ? getObjectType(schemaIntrospection.mutationType) : null;\n const subscriptionType = schemaIntrospection.subscriptionType ? getObjectType(schemaIntrospection.subscriptionType) : null; // Get the directives supported by Introspection, assuming empty-set if\n // directives were not queried for.\n\n const directives = schemaIntrospection.directives ? schemaIntrospection.directives.map(buildDirective) : []; // Then produce and return a Schema with these types.\n\n return new GraphQLSchema({\n description: schemaIntrospection.description,\n query: queryType,\n mutation: mutationType,\n subscription: subscriptionType,\n types: objectValues(typeMap),\n directives,\n assumeValid: options?.assumeValid\n }); // Given a type reference in introspection, return the GraphQLType instance.\n // preferring cached instances before building new instances.\n\n function getType(typeRef) {\n if (typeRef.kind === TypeKind.LIST) {\n const itemRef = typeRef.ofType;\n\n if (!itemRef) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n\n return new GraphQLList(getType(itemRef));\n }\n\n if (typeRef.kind === TypeKind.NON_NULL) {\n const nullableRef = typeRef.ofType;\n\n if (!nullableRef) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n\n const nullableType = getType(nullableRef);\n return new GraphQLNonNull(assertNullableType(nullableType));\n }\n\n return getNamedType(typeRef);\n }\n\n function getNamedType(typeRef) {\n const typeName = typeRef.name;\n\n if (!typeName) {\n throw new Error(`Unknown type reference: ${inspect(typeRef)}.`);\n }\n\n const type = typeMap[typeName];\n\n if (!type) {\n throw new Error(`Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`);\n }\n\n return type;\n }\n\n function getObjectType(typeRef) {\n return assertObjectType(getNamedType(typeRef));\n }\n\n function getInterfaceType(typeRef) {\n return assertInterfaceType(getNamedType(typeRef));\n } // Given a type's introspection result, construct the correct\n // GraphQLType instance.\n\n\n function buildType(type) {\n if (type != null && type.name != null && type.kind != null) {\n switch (type.kind) {\n case TypeKind.SCALAR:\n return buildScalarDef(type);\n\n case TypeKind.OBJECT:\n return buildObjectDef(type);\n\n case TypeKind.INTERFACE:\n return buildInterfaceDef(type);\n\n case TypeKind.UNION:\n return buildUnionDef(type);\n\n case TypeKind.ENUM:\n return buildEnumDef(type);\n\n case TypeKind.INPUT_OBJECT:\n return buildInputObjectDef(type);\n }\n }\n\n const typeStr = inspect(type);\n throw new Error(`Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${typeStr}.`);\n }\n\n function buildScalarDef(scalarIntrospection) {\n return new GraphQLScalarType({\n name: scalarIntrospection.name,\n description: scalarIntrospection.description,\n specifiedByUrl: scalarIntrospection.specifiedByUrl\n });\n }\n\n function buildImplementationsList(implementingIntrospection) {\n // TODO: Temporary workaround until GraphQL ecosystem will fully support\n // 'interfaces' on interface types.\n if (implementingIntrospection.interfaces === null && implementingIntrospection.kind === TypeKind.INTERFACE) {\n return [];\n }\n\n if (!implementingIntrospection.interfaces) {\n const implementingIntrospectionStr = inspect(implementingIntrospection);\n throw new Error(`Introspection result missing interfaces: ${implementingIntrospectionStr}.`);\n }\n\n return implementingIntrospection.interfaces.map(getInterfaceType);\n }\n\n function buildObjectDef(objectIntrospection) {\n return new GraphQLObjectType({\n name: objectIntrospection.name,\n description: objectIntrospection.description,\n interfaces: () => buildImplementationsList(objectIntrospection),\n fields: () => buildFieldDefMap(objectIntrospection)\n });\n }\n\n function buildInterfaceDef(interfaceIntrospection) {\n return new GraphQLInterfaceType({\n name: interfaceIntrospection.name,\n description: interfaceIntrospection.description,\n interfaces: () => buildImplementationsList(interfaceIntrospection),\n fields: () => buildFieldDefMap(interfaceIntrospection)\n });\n }\n\n function buildUnionDef(unionIntrospection) {\n if (!unionIntrospection.possibleTypes) {\n const unionIntrospectionStr = inspect(unionIntrospection);\n throw new Error(`Introspection result missing possibleTypes: ${unionIntrospectionStr}.`);\n }\n\n return new GraphQLUnionType({\n name: unionIntrospection.name,\n description: unionIntrospection.description,\n types: () => unionIntrospection.possibleTypes.map(getObjectType)\n });\n }\n\n function buildEnumDef(enumIntrospection) {\n if (!enumIntrospection.enumValues) {\n const enumIntrospectionStr = inspect(enumIntrospection);\n throw new Error(`Introspection result missing enumValues: ${enumIntrospectionStr}.`);\n }\n\n return new GraphQLEnumType({\n name: enumIntrospection.name,\n description: enumIntrospection.description,\n values: keyValMap(enumIntrospection.enumValues, valueIntrospection => valueIntrospection.name, valueIntrospection => ({\n description: valueIntrospection.description,\n deprecationReason: valueIntrospection.deprecationReason\n }))\n });\n }\n\n function buildInputObjectDef(inputObjectIntrospection) {\n if (!inputObjectIntrospection.inputFields) {\n const inputObjectIntrospectionStr = inspect(inputObjectIntrospection);\n throw new Error(`Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`);\n }\n\n return new GraphQLInputObjectType({\n name: inputObjectIntrospection.name,\n description: inputObjectIntrospection.description,\n fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields)\n });\n }\n\n function buildFieldDefMap(typeIntrospection) {\n if (!typeIntrospection.fields) {\n throw new Error(`Introspection result missing fields: ${inspect(typeIntrospection)}.`);\n }\n\n return keyValMap(typeIntrospection.fields, fieldIntrospection => fieldIntrospection.name, buildField);\n }\n\n function buildField(fieldIntrospection) {\n const type = getType(fieldIntrospection.type);\n\n if (!isOutputType(type)) {\n const typeStr = inspect(type);\n throw new Error(`Introspection must provide output type for fields, but received: ${typeStr}.`);\n }\n\n if (!fieldIntrospection.args) {\n const fieldIntrospectionStr = inspect(fieldIntrospection);\n throw new Error(`Introspection result missing field args: ${fieldIntrospectionStr}.`);\n }\n\n return {\n description: fieldIntrospection.description,\n deprecationReason: fieldIntrospection.deprecationReason,\n type,\n args: buildInputValueDefMap(fieldIntrospection.args)\n };\n }\n\n function buildInputValueDefMap(inputValueIntrospections) {\n return keyValMap(inputValueIntrospections, inputValue => inputValue.name, buildInputValue);\n }\n\n function buildInputValue(inputValueIntrospection) {\n const type = getType(inputValueIntrospection.type);\n\n if (!isInputType(type)) {\n const typeStr = inspect(type);\n throw new Error(`Introspection must provide input type for arguments, but received: ${typeStr}.`);\n }\n\n const defaultValue = inputValueIntrospection.defaultValue != null ? valueFromAST(parseValue(inputValueIntrospection.defaultValue), type) : undefined;\n return {\n description: inputValueIntrospection.description,\n type,\n defaultValue,\n deprecationReason: inputValueIntrospection.deprecationReason\n };\n }\n\n function buildDirective(directiveIntrospection) {\n if (!directiveIntrospection.args) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(`Introspection result missing directive args: ${directiveIntrospectionStr}.`);\n }\n\n if (!directiveIntrospection.locations) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(`Introspection result missing directive locations: ${directiveIntrospectionStr}.`);\n }\n\n return new GraphQLDirective({\n name: directiveIntrospection.name,\n description: directiveIntrospection.description,\n isRepeatable: directiveIntrospection.isRepeatable,\n locations: directiveIntrospection.locations.slice(),\n args: buildInputValueDefMap(directiveIntrospection.args)\n });\n }\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport keyMap from \"../jsutils/keyMap.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport mapValue from \"../jsutils/mapValue.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport devAssert from \"../jsutils/devAssert.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { isTypeDefinitionNode, isTypeExtensionNode } from \"../language/predicates.mjs\";\nimport { assertValidSDLExtension } from \"../validation/validate.mjs\";\nimport { getDirectiveValues } from \"../execution/values.mjs\";\nimport { assertSchema, GraphQLSchema } from \"../type/schema.mjs\";\nimport { specifiedScalarTypes, isSpecifiedScalarType } from \"../type/scalars.mjs\";\nimport { introspectionTypes, isIntrospectionType } from \"../type/introspection.mjs\";\nimport { GraphQLDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective } from \"../type/directives.mjs\";\nimport { isScalarType, isObjectType, isInterfaceType, isUnionType, isListType, isNonNullType, isEnumType, isInputObjectType, GraphQLList, GraphQLNonNull, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType } from \"../type/definition.mjs\";\nimport { valueFromAST } from \"./valueFromAST.mjs\";\n\n/**\n * Produces a new schema given an existing schema and a document which may\n * contain GraphQL type extensions and definitions. The original schema will\n * remain unaltered.\n *\n * Because a schema represents a graph of references, a schema cannot be\n * extended without effectively making an entire copy. We do not know until it's\n * too late if subgraphs remain unchanged.\n *\n * This algorithm copies the provided schema, applying extensions while\n * producing the copy. The original schema remains unaltered.\n */\nexport function extendSchema(schema, documentAST, options) {\n assertSchema(schema);\n documentAST != null && documentAST.kind === Kind.DOCUMENT || devAssert(0, 'Must provide valid Document AST.');\n\n if (options?.assumeValid !== true && options?.assumeValidSDL !== true) {\n assertValidSDLExtension(documentAST, schema);\n }\n\n const schemaConfig = schema.toConfig();\n const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options);\n return schemaConfig === extendedConfig ? schema : new GraphQLSchema(extendedConfig);\n}\n/**\n * @internal\n */\n\nexport function extendSchemaImpl(schemaConfig, documentAST, options) {\n // Collect the type definitions and extensions found in the document.\n const typeDefs = [];\n const typeExtensionsMap = Object.create(null); // New directives and types are separate because a directives and types can\n // have the same name. For example, a type named \"skip\".\n\n const directiveDefs = [];\n let schemaDef; // Schema extensions are collected which may add additional operation types.\n\n const schemaExtensions = [];\n\n for (const def of documentAST.definitions) {\n if (def.kind === Kind.SCHEMA_DEFINITION) {\n schemaDef = def;\n } else if (def.kind === Kind.SCHEMA_EXTENSION) {\n schemaExtensions.push(def);\n } else if (isTypeDefinitionNode(def)) {\n typeDefs.push(def);\n } else if (isTypeExtensionNode(def)) {\n const extendedTypeName = def.name.value;\n const existingTypeExtensions = typeExtensionsMap[extendedTypeName];\n typeExtensionsMap[extendedTypeName] = existingTypeExtensions ? existingTypeExtensions.concat([def]) : [def];\n } else if (def.kind === Kind.DIRECTIVE_DEFINITION) {\n directiveDefs.push(def);\n }\n } // If this document contains no new types, extensions, or directives then\n // return the same unmodified GraphQLSchema instance.\n\n\n if (Object.keys(typeExtensionsMap).length === 0 && typeDefs.length === 0 && directiveDefs.length === 0 && schemaExtensions.length === 0 && schemaDef == null) {\n return schemaConfig;\n }\n\n const typeMap = Object.create(null);\n\n for (const existingType of schemaConfig.types) {\n typeMap[existingType.name] = extendNamedType(existingType);\n }\n\n for (const typeNode of typeDefs) {\n const name = typeNode.name.value;\n typeMap[name] = stdTypeMap[name] ?? buildType(typeNode);\n }\n\n const operationTypes = {\n // Get the extended root operation types.\n query: schemaConfig.query && replaceNamedType(schemaConfig.query),\n mutation: schemaConfig.mutation && replaceNamedType(schemaConfig.mutation),\n subscription: schemaConfig.subscription && replaceNamedType(schemaConfig.subscription),\n // Then, incorporate schema definition and all schema extensions.\n ...(schemaDef && getOperationTypes([schemaDef])),\n ...getOperationTypes(schemaExtensions)\n }; // Then produce and return a Schema config with these types.\n\n return {\n description: schemaDef?.description?.value,\n ...operationTypes,\n types: objectValues(typeMap),\n directives: [...schemaConfig.directives.map(replaceDirective), ...directiveDefs.map(buildDirective)],\n extensions: undefined,\n astNode: schemaDef ?? schemaConfig.astNode,\n extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExtensions),\n assumeValid: options?.assumeValid ?? false\n }; // Below are functions used for producing this schema that have closed over\n // this scope and have access to the schema, cache, and newly defined types.\n\n function replaceType(type) {\n if (isListType(type)) {\n // $FlowFixMe[incompatible-return]\n return new GraphQLList(replaceType(type.ofType));\n }\n\n if (isNonNullType(type)) {\n // $FlowFixMe[incompatible-return]\n return new GraphQLNonNull(replaceType(type.ofType));\n }\n\n return replaceNamedType(type);\n }\n\n function replaceNamedType(type) {\n // Note: While this could make early assertions to get the correctly\n // typed values, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n return typeMap[type.name];\n }\n\n function replaceDirective(directive) {\n const config = directive.toConfig();\n return new GraphQLDirective({ ...config,\n args: mapValue(config.args, extendArg)\n });\n }\n\n function extendNamedType(type) {\n if (isIntrospectionType(type) || isSpecifiedScalarType(type)) {\n // Builtin types are not extended.\n return type;\n }\n\n if (isScalarType(type)) {\n return extendScalarType(type);\n }\n\n if (isObjectType(type)) {\n return extendObjectType(type);\n }\n\n if (isInterfaceType(type)) {\n return extendInterfaceType(type);\n }\n\n if (isUnionType(type)) {\n return extendUnionType(type);\n }\n\n if (isEnumType(type)) {\n return extendEnumType(type);\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isInputObjectType(type)) {\n return extendInputObjectType(type);\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, 'Unexpected type: ' + inspect(type));\n }\n\n function extendInputObjectType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[config.name] ?? [];\n return new GraphQLInputObjectType({ ...config,\n fields: () => ({ ...mapValue(config.fields, field => ({ ...field,\n type: replaceType(field.type)\n })),\n ...buildInputFieldMap(extensions)\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendEnumType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[type.name] ?? [];\n return new GraphQLEnumType({ ...config,\n values: { ...config.values,\n ...buildEnumValueMap(extensions)\n },\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendScalarType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[config.name] ?? [];\n let specifiedByUrl = config.specifiedByUrl;\n\n for (const extensionNode of extensions) {\n specifiedByUrl = getSpecifiedByUrl(extensionNode) ?? specifiedByUrl;\n }\n\n return new GraphQLScalarType({ ...config,\n specifiedByUrl,\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendObjectType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[config.name] ?? [];\n return new GraphQLObjectType({ ...config,\n interfaces: () => [...type.getInterfaces().map(replaceNamedType), ...buildInterfaces(extensions)],\n fields: () => ({ ...mapValue(config.fields, extendField),\n ...buildFieldMap(extensions)\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendInterfaceType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[config.name] ?? [];\n return new GraphQLInterfaceType({ ...config,\n interfaces: () => [...type.getInterfaces().map(replaceNamedType), ...buildInterfaces(extensions)],\n fields: () => ({ ...mapValue(config.fields, extendField),\n ...buildFieldMap(extensions)\n }),\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendUnionType(type) {\n const config = type.toConfig();\n const extensions = typeExtensionsMap[config.name] ?? [];\n return new GraphQLUnionType({ ...config,\n types: () => [...type.getTypes().map(replaceNamedType), ...buildUnionTypes(extensions)],\n extensionASTNodes: config.extensionASTNodes.concat(extensions)\n });\n }\n\n function extendField(field) {\n return { ...field,\n type: replaceType(field.type),\n // $FlowFixMe[incompatible-call]\n args: mapValue(field.args, extendArg)\n };\n }\n\n function extendArg(arg) {\n return { ...arg,\n type: replaceType(arg.type)\n };\n }\n\n function getOperationTypes(nodes) {\n const opTypes = {};\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const operationTypesNodes = node.operationTypes ?? [];\n\n for (const operationType of operationTypesNodes) {\n opTypes[operationType.operation] = getNamedType(operationType.type);\n }\n } // Note: While this could make early assertions to get the correctly\n // typed values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n\n\n return opTypes;\n }\n\n function getNamedType(node) {\n const name = node.name.value;\n const type = stdTypeMap[name] ?? typeMap[name];\n\n if (type === undefined) {\n throw new Error(`Unknown type: \"${name}\".`);\n }\n\n return type;\n }\n\n function getWrappedType(node) {\n if (node.kind === Kind.LIST_TYPE) {\n return new GraphQLList(getWrappedType(node.type));\n }\n\n if (node.kind === Kind.NON_NULL_TYPE) {\n // $FlowFixMe[incompatible-call]\n return new GraphQLNonNull(getWrappedType(node.type));\n }\n\n return getNamedType(node);\n }\n\n function buildDirective(node) {\n const locations = node.locations.map(({\n value\n }) => value);\n return new GraphQLDirective({\n name: node.name.value,\n description: node.description?.value,\n locations,\n isRepeatable: node.repeatable,\n args: buildArgumentMap(node.arguments),\n astNode: node\n });\n }\n\n function buildFieldMap(nodes) {\n const fieldConfigMap = Object.create(null);\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const nodeFields = node.fields ?? [];\n\n for (const field of nodeFields) {\n fieldConfigMap[field.name.value] = {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n type: getWrappedType(field.type),\n description: field.description?.value,\n args: buildArgumentMap(field.arguments),\n deprecationReason: getDeprecationReason(field),\n astNode: field\n };\n }\n }\n\n return fieldConfigMap;\n }\n\n function buildArgumentMap(args) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argsNodes = args ?? [];\n const argConfigMap = Object.create(null);\n\n for (const arg of argsNodes) {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n const type = getWrappedType(arg.type);\n argConfigMap[arg.name.value] = {\n type,\n description: arg.description?.value,\n defaultValue: valueFromAST(arg.defaultValue, type),\n deprecationReason: getDeprecationReason(arg),\n astNode: arg\n };\n }\n\n return argConfigMap;\n }\n\n function buildInputFieldMap(nodes) {\n const inputFieldMap = Object.create(null);\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const fieldsNodes = node.fields ?? [];\n\n for (const field of fieldsNodes) {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n const type = getWrappedType(field.type);\n inputFieldMap[field.name.value] = {\n type,\n description: field.description?.value,\n defaultValue: valueFromAST(field.defaultValue, type),\n deprecationReason: getDeprecationReason(field),\n astNode: field\n };\n }\n }\n\n return inputFieldMap;\n }\n\n function buildEnumValueMap(nodes) {\n const enumValueMap = Object.create(null);\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const valuesNodes = node.values ?? [];\n\n for (const value of valuesNodes) {\n enumValueMap[value.name.value] = {\n description: value.description?.value,\n deprecationReason: getDeprecationReason(value),\n astNode: value\n };\n }\n }\n\n return enumValueMap;\n }\n\n function buildInterfaces(nodes) {\n const interfaces = [];\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const interfacesNodes = node.interfaces ?? [];\n\n for (const type of interfacesNodes) {\n // Note: While this could make assertions to get the correctly typed\n // values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable\n // results.\n interfaces.push(getNamedType(type));\n }\n }\n\n return interfaces;\n }\n\n function buildUnionTypes(nodes) {\n const types = [];\n\n for (const node of nodes) {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const typeNodes = node.types ?? [];\n\n for (const type of typeNodes) {\n // Note: While this could make assertions to get the correctly typed\n // values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable\n // results.\n types.push(getNamedType(type));\n }\n }\n\n return types;\n }\n\n function buildType(astNode) {\n const name = astNode.name.value;\n const extensionNodes = typeExtensionsMap[name] ?? [];\n\n switch (astNode.kind) {\n case Kind.OBJECT_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n const allNodes = [astNode, ...extensionASTNodes];\n return new GraphQLObjectType({\n name,\n description: astNode.description?.value,\n interfaces: () => buildInterfaces(allNodes),\n fields: () => buildFieldMap(allNodes),\n astNode,\n extensionASTNodes\n });\n }\n\n case Kind.INTERFACE_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n const allNodes = [astNode, ...extensionASTNodes];\n return new GraphQLInterfaceType({\n name,\n description: astNode.description?.value,\n interfaces: () => buildInterfaces(allNodes),\n fields: () => buildFieldMap(allNodes),\n astNode,\n extensionASTNodes\n });\n }\n\n case Kind.ENUM_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n const allNodes = [astNode, ...extensionASTNodes];\n return new GraphQLEnumType({\n name,\n description: astNode.description?.value,\n values: buildEnumValueMap(allNodes),\n astNode,\n extensionASTNodes\n });\n }\n\n case Kind.UNION_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n const allNodes = [astNode, ...extensionASTNodes];\n return new GraphQLUnionType({\n name,\n description: astNode.description?.value,\n types: () => buildUnionTypes(allNodes),\n astNode,\n extensionASTNodes\n });\n }\n\n case Kind.SCALAR_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n return new GraphQLScalarType({\n name,\n description: astNode.description?.value,\n specifiedByUrl: getSpecifiedByUrl(astNode),\n astNode,\n extensionASTNodes\n });\n }\n\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n {\n const extensionASTNodes = extensionNodes;\n const allNodes = [astNode, ...extensionASTNodes];\n return new GraphQLInputObjectType({\n name,\n description: astNode.description?.value,\n fields: () => buildInputFieldMap(allNodes),\n astNode,\n extensionASTNodes\n });\n }\n } // istanbul ignore next (Not reachable. All possible type definition nodes have been considered)\n\n\n false || invariant(0, 'Unexpected type definition node: ' + inspect(astNode));\n }\n}\nconst stdTypeMap = keyMap(specifiedScalarTypes.concat(introspectionTypes), type => type.name);\n/**\n * Given a field or enum value node, returns the string value for the\n * deprecation reason.\n */\n\nfunction getDeprecationReason(node) {\n const deprecated = getDirectiveValues(GraphQLDeprecatedDirective, node);\n return deprecated?.reason;\n}\n/**\n * Given a scalar node, returns the string value for the specifiedByUrl.\n */\n\n\nfunction getSpecifiedByUrl(node) {\n const specifiedBy = getDirectiveValues(GraphQLSpecifiedByDirective, node);\n return specifiedBy?.url;\n}\n","import devAssert from \"../jsutils/devAssert.mjs\";\nimport { Kind } from \"../language/kinds.mjs\";\nimport { parse } from \"../language/parser.mjs\";\nimport { assertValidSDL } from \"../validation/validate.mjs\";\nimport { GraphQLSchema } from \"../type/schema.mjs\";\nimport { specifiedDirectives } from \"../type/directives.mjs\";\nimport { extendSchemaImpl } from \"./extendSchema.mjs\";\n\n/**\n * This takes the ast of a schema document produced by the parse function in\n * src/language/parser.js.\n *\n * If no schema definition is provided, then it will look for types named Query\n * and Mutation.\n *\n * Given that AST it constructs a GraphQLSchema. The resulting schema\n * has no resolve methods, so execution will use default resolvers.\n */\nexport function buildASTSchema(documentAST, options) {\n documentAST != null && documentAST.kind === Kind.DOCUMENT || devAssert(0, 'Must provide valid Document AST.');\n\n if (options?.assumeValid !== true && options?.assumeValidSDL !== true) {\n assertValidSDL(documentAST);\n }\n\n const emptySchemaConfig = {\n description: undefined,\n types: [],\n directives: [],\n extensions: undefined,\n extensionASTNodes: [],\n assumeValid: false\n };\n const config = extendSchemaImpl(emptySchemaConfig, documentAST, options);\n\n if (config.astNode == null) {\n for (const type of config.types) {\n switch (type.name) {\n // Note: While this could make early assertions to get the correctly\n // typed values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n case 'Query':\n config.query = type;\n break;\n\n case 'Mutation':\n config.mutation = type;\n break;\n\n case 'Subscription':\n config.subscription = type;\n break;\n }\n }\n }\n\n const {\n directives\n } = config; // If specified directives were not explicitly declared, add them.\n\n for (const stdDirective of specifiedDirectives) {\n if (directives.every(directive => directive.name !== stdDirective.name)) {\n directives.push(stdDirective);\n }\n }\n\n return new GraphQLSchema(config);\n}\n/**\n * A helper function to build a GraphQLSchema directly from a source\n * document.\n */\n\nexport function buildSchema(source, options) {\n const document = parse(source, {\n noLocation: options?.noLocation,\n experimentalFragmentVariables: options?.experimentalFragmentVariables\n });\n return buildASTSchema(document, {\n assumeValidSDL: options?.assumeValidSDL,\n assumeValid: options?.assumeValid\n });\n}\n","import objectValues from \"../polyfills/objectValues.mjs\";\nimport inspect from \"../jsutils/inspect.mjs\";\nimport invariant from \"../jsutils/invariant.mjs\";\nimport { print } from \"../language/printer.mjs\";\nimport { printBlockString } from \"../language/blockString.mjs\";\nimport { isIntrospectionType } from \"../type/introspection.mjs\";\nimport { GraphQLString, isSpecifiedScalarType } from \"../type/scalars.mjs\";\nimport { DEFAULT_DEPRECATION_REASON, isSpecifiedDirective } from \"../type/directives.mjs\";\nimport { isScalarType, isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType } from \"../type/definition.mjs\";\nimport { astFromValue } from \"./astFromValue.mjs\";\nexport function printSchema(schema) {\n return printFilteredSchema(schema, n => !isSpecifiedDirective(n), isDefinedType);\n}\nexport function printIntrospectionSchema(schema) {\n return printFilteredSchema(schema, isSpecifiedDirective, isIntrospectionType);\n}\n\nfunction isDefinedType(type) {\n return !isSpecifiedScalarType(type) && !isIntrospectionType(type);\n}\n\nfunction printFilteredSchema(schema, directiveFilter, typeFilter) {\n const directives = schema.getDirectives().filter(directiveFilter);\n const types = objectValues(schema.getTypeMap()).filter(typeFilter);\n return [printSchemaDefinition(schema)].concat(directives.map(directive => printDirective(directive)), types.map(type => printType(type))).filter(Boolean).join('\\n\\n') + '\\n';\n}\n\nfunction printSchemaDefinition(schema) {\n if (schema.description == null && isSchemaOfCommonNames(schema)) {\n return;\n }\n\n const operationTypes = [];\n const queryType = schema.getQueryType();\n\n if (queryType) {\n operationTypes.push(` query: ${queryType.name}`);\n }\n\n const mutationType = schema.getMutationType();\n\n if (mutationType) {\n operationTypes.push(` mutation: ${mutationType.name}`);\n }\n\n const subscriptionType = schema.getSubscriptionType();\n\n if (subscriptionType) {\n operationTypes.push(` subscription: ${subscriptionType.name}`);\n }\n\n return printDescription(schema) + `schema {\\n${operationTypes.join('\\n')}\\n}`;\n}\n/**\n * GraphQL schema define root types for each type of operation. These types are\n * the same as any other type and can be named in any manner, however there is\n * a common naming convention:\n *\n * schema {\n * query: Query\n * mutation: Mutation\n * }\n *\n * When using this naming convention, the schema description can be omitted.\n */\n\n\nfunction isSchemaOfCommonNames(schema) {\n const queryType = schema.getQueryType();\n\n if (queryType && queryType.name !== 'Query') {\n return false;\n }\n\n const mutationType = schema.getMutationType();\n\n if (mutationType && mutationType.name !== 'Mutation') {\n return false;\n }\n\n const subscriptionType = schema.getSubscriptionType();\n\n if (subscriptionType && subscriptionType.name !== 'Subscription') {\n return false;\n }\n\n return true;\n}\n\nexport function printType(type) {\n if (isScalarType(type)) {\n return printScalar(type);\n }\n\n if (isObjectType(type)) {\n return printObject(type);\n }\n\n if (isInterfaceType(type)) {\n return printInterface(type);\n }\n\n if (isUnionType(type)) {\n return printUnion(type);\n }\n\n if (isEnumType(type)) {\n return printEnum(type);\n } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n\n\n if (isInputObjectType(type)) {\n return printInputObject(type);\n } // istanbul ignore next (Not reachable. All possible types have been considered)\n\n\n false || invariant(0, 'Unexpected type: ' + inspect(type));\n}\n\nfunction printScalar(type) {\n return printDescription(type) + `scalar ${type.name}` + printSpecifiedByUrl(type);\n}\n\nfunction printImplementedInterfaces(type) {\n const interfaces = type.getInterfaces();\n return interfaces.length ? ' implements ' + interfaces.map(i => i.name).join(' & ') : '';\n}\n\nfunction printObject(type) {\n return printDescription(type) + `type ${type.name}` + printImplementedInterfaces(type) + printFields(type);\n}\n\nfunction printInterface(type) {\n return printDescription(type) + `interface ${type.name}` + printImplementedInterfaces(type) + printFields(type);\n}\n\nfunction printUnion(type) {\n const types = type.getTypes();\n const possibleTypes = types.length ? ' = ' + types.join(' | ') : '';\n return printDescription(type) + 'union ' + type.name + possibleTypes;\n}\n\nfunction printEnum(type) {\n const values = type.getValues().map((value, i) => printDescription(value, ' ', !i) + ' ' + value.name + printDeprecated(value.deprecationReason));\n return printDescription(type) + `enum ${type.name}` + printBlock(values);\n}\n\nfunction printInputObject(type) {\n const fields = objectValues(type.getFields()).map((f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f));\n return printDescription(type) + `input ${type.name}` + printBlock(fields);\n}\n\nfunction printFields(type) {\n const fields = objectValues(type.getFields()).map((f, i) => printDescription(f, ' ', !i) + ' ' + f.name + printArgs(f.args, ' ') + ': ' + String(f.type) + printDeprecated(f.deprecationReason));\n return printBlock(fields);\n}\n\nfunction printBlock(items) {\n return items.length !== 0 ? ' {\\n' + items.join('\\n') + '\\n}' : '';\n}\n\nfunction printArgs(args, indentation = '') {\n if (args.length === 0) {\n return '';\n } // If every arg does not have a description, print them on one line.\n\n\n if (args.every(arg => !arg.description)) {\n return '(' + args.map(printInputValue).join(', ') + ')';\n }\n\n return '(\\n' + args.map((arg, i) => printDescription(arg, ' ' + indentation, !i) + ' ' + indentation + printInputValue(arg)).join('\\n') + '\\n' + indentation + ')';\n}\n\nfunction printInputValue(arg) {\n const defaultAST = astFromValue(arg.defaultValue, arg.type);\n let argDecl = arg.name + ': ' + String(arg.type);\n\n if (defaultAST) {\n argDecl += ` = ${print(defaultAST)}`;\n }\n\n return argDecl + printDeprecated(arg.deprecationReason);\n}\n\nfunction printDirective(directive) {\n return printDescription(directive) + 'directive @' + directive.name + printArgs(directive.args) + (directive.isRepeatable ? ' repeatable' : '') + ' on ' + directive.locations.join(' | ');\n}\n\nfunction printDeprecated(reason) {\n if (reason == null) {\n return '';\n }\n\n const reasonAST = astFromValue(reason, GraphQLString);\n\n if (reasonAST && reason !== DEFAULT_DEPRECATION_REASON) {\n return ' @deprecated(reason: ' + print(reasonAST) + ')';\n }\n\n return ' @deprecated';\n}\n\nfunction printSpecifiedByUrl(scalar) {\n if (scalar.specifiedByUrl == null) {\n return '';\n }\n\n const url = scalar.specifiedByUrl;\n const urlAST = astFromValue(url, GraphQLString);\n urlAST || invariant(0, 'Unexpected null value returned from `astFromValue` for specifiedByUrl');\n return ' @specifiedBy(url: ' + print(urlAST) + ')';\n}\n\nfunction printDescription(def, indentation = '', firstInBlock = true) {\n const {\n description\n } = def;\n\n if (description == null) {\n return '';\n }\n\n const preferMultipleLines = description.length > 70;\n const blockString = printBlockString(description, '', preferMultipleLines);\n const prefix = indentation && !firstInBlock ? '\\n' + indentation : indentation;\n return prefix + blockString.replace(/\\n/g, '\\n' + indentation) + '\\n';\n}\n",null,null,null,null,null,"import { GraphQLError } from \"../error/GraphQLError.mjs\";\n\n/**\n * Extracts the root type of the operation from the schema.\n */\nexport function getOperationRootType(schema, operation) {\n if (operation.operation === 'query') {\n const queryType = schema.getQueryType();\n\n if (!queryType) {\n throw new GraphQLError('Schema does not define the required query root type.', operation);\n }\n\n return queryType;\n }\n\n if (operation.operation === 'mutation') {\n const mutationType = schema.getMutationType();\n\n if (!mutationType) {\n throw new GraphQLError('Schema is not configured for mutations.', operation);\n }\n\n return mutationType;\n }\n\n if (operation.operation === 'subscription') {\n const subscriptionType = schema.getSubscriptionType();\n\n if (!subscriptionType) {\n throw new GraphQLError('Schema is not configured for subscriptions.', operation);\n }\n\n return subscriptionType;\n }\n\n throw new GraphQLError('Can only have query, mutation and subscription operations.', operation);\n}\n",null,"/**\n * Provided a collection of ASTs, presumably each from different files,\n * concatenate the ASTs together into batched AST, useful for validating many\n * GraphQL source files which together represent one conceptual application.\n */\nexport function concatAST(documents) {\n let definitions = [];\n\n for (const doc of documents) {\n definitions = definitions.concat(doc.definitions);\n }\n\n return {\n kind: 'Document',\n definitions\n };\n}\n"],"names":["isObjectLike","value","getLocation","source","position","lineRegexp","match","line","column","exec","body","index","length","printLocation","location","printSourceLocation","start","sourceLocation","firstLineColumnOffset","locationOffset","whitespace","lineIndex","lineOffset","lineNum","columnOffset","columnNum","locationStr","name","lines","split","locationLine","subLineIndex","Math","floor","subLineColumnNum","subLines","i","push","slice","printPrefixedLines","map","subLine","existingLines","filter","_","undefined","padLen","max","prefix","leftPad","str","join","len","Array","GraphQLError","Error","constructor","message","nodes","positions","path","originalError","extensions","super","_nodes","isArray","_source","loc","_locations","_positions","reduce","list","node","pos","_extensions","originalExtensions","Object","defineProperties","this","enumerable","writable","locations","stack","defineProperty","configurable","captureStackTrace","toString","error","output","printError","get","Symbol","toStringTag","syntaxError","description","Kind","freeze","NAME","DOCUMENT","OPERATION_DEFINITION","VARIABLE_DEFINITION","SELECTION_SET","FIELD","ARGUMENT","FRAGMENT_SPREAD","INLINE_FRAGMENT","FRAGMENT_DEFINITION","VARIABLE","INT","FLOAT","STRING","BOOLEAN","NULL","ENUM","LIST","OBJECT","OBJECT_FIELD","DIRECTIVE","NAMED_TYPE","LIST_TYPE","NON_NULL_TYPE","SCHEMA_DEFINITION","OPERATION_TYPE_DEFINITION","SCALAR_TYPE_DEFINITION","OBJECT_TYPE_DEFINITION","FIELD_DEFINITION","INPUT_VALUE_DEFINITION","INTERFACE_TYPE_DEFINITION","UNION_TYPE_DEFINITION","ENUM_TYPE_DEFINITION","ENUM_VALUE_DEFINITION","INPUT_OBJECT_TYPE_DEFINITION","DIRECTIVE_DEFINITION","SCHEMA_EXTENSION","SCALAR_TYPE_EXTENSION","OBJECT_TYPE_EXTENSION","INTERFACE_TYPE_EXTENSION","UNION_TYPE_EXTENSION","ENUM_TYPE_EXTENSION","INPUT_OBJECT_TYPE_EXTENSION","Location","startToken","endToken","end","toJSON","for","Token","kind","prev","next","isNode","maybeNode","TokenKind","SOF","EOF","BANG","DOLLAR","AMP","PAREN_L","PAREN_R","SPREAD","COLON","EQUALS","AT","BRACKET_L","BRACKET_R","BRACE_L","PIPE","BRACE_R","BLOCK_STRING","COMMENT","inspect","formatValue","seenValues","JSON","stringify","previouslySeenValues","indexOf","jsonValue","array","min","remaining","items","formatArray","object","keys","tag","prototype","call","replace","getObjectTag","key","formatObject","formatObjectValue","String","devAssert","condition","Boolean","Source","DirectiveLocation","QUERY","MUTATION","SUBSCRIPTION","SCHEMA","SCALAR","ARGUMENT_DEFINITION","INTERFACE","UNION","ENUM_VALUE","INPUT_OBJECT","INPUT_FIELD_DEFINITION","dedentBlockStringValue","rawString","commonIndent","isFirstLine","isEmptyLine","indent","charCodeAt","getBlockStringIndentation","startLine","isBlank","endLine","printBlockString","indentation","preferMultipleLines","isSingleLine","hasLeadingSpace","hasTrailingQuote","hasTrailingSlash","printAsMultipleLines","result","Lexer","startOfFileToken","lastToken","token","lineStart","advance","lookahead","readToken","printCharCode","code","isNaN","fromCharCode","toUpperCase","lexer","bodyLength","col","readComment","readBlockString","readString","readNumber","readName","unexpectedCharacterMessage","firstCode","isFloat","readDigits","isNameStart","chunkStart","charCode","a","b","c","d","char2hex","rawValue","parse","options","Parser","parseDocument","sourceObj","instanceOf","isSource","_lexer","_options","parseName","expectToken","definitions","many","parseDefinition","peek","parseOperationDefinition","parseFragmentDefinition","parseTypeSystemDefinition","parseTypeSystemExtension","peekDescription","unexpected","operation","variableDefinitions","directives","selectionSet","parseSelectionSet","parseOperationType","parseVariableDefinitions","parseDirectives","operationToken","optionalMany","parseVariableDefinition","variable","parseVariable","type","parseTypeReference","defaultValue","expectOptionalToken","parseValueLiteral","selections","parseSelection","parseFragment","parseField","nameOrAlias","alias","arguments","parseArguments","isConst","item","parseConstArgument","parseArgument","hasTypeCondition","expectOptionalKeyword","parseFragmentName","typeCondition","parseNamedType","expectKeyword","experimentalFragmentVariables","parseList","parseObject","parseStringLiteral","block","values","any","fields","parseObjectField","parseDirective","keywordToken","parseSchemaDefinition","parseScalarTypeDefinition","parseObjectTypeDefinition","parseInterfaceTypeDefinition","parseUnionTypeDefinition","parseEnumTypeDefinition","parseInputObjectTypeDefinition","parseDirectiveDefinition","parseDescription","operationTypes","parseOperationTypeDefinition","interfaces","parseImplementsInterfaces","parseFieldsDefinition","delimitedMany","parseFieldDefinition","args","parseArgumentDefs","parseInputValueDef","types","parseUnionMemberTypes","parseEnumValuesDefinition","parseEnumValueDefinition","parseInputFieldsDefinition","parseSchemaExtension","parseScalarTypeExtension","parseObjectTypeExtension","parseInterfaceTypeExtension","parseUnionTypeExtension","parseEnumTypeExtension","parseInputObjectTypeExtension","repeatable","parseDirectiveLocations","parseDirectiveLocation","noLocation","getTokenKindDesc","getTokenDesc","atToken","openKind","parseFn","closeKind","delimiterKind","isPunctuatorTokenKind","QueryDocumentKeys","Name","Document","OperationDefinition","VariableDefinition","Variable","SelectionSet","Field","Argument","FragmentSpread","InlineFragment","FragmentDefinition","IntValue","FloatValue","StringValue","BooleanValue","NullValue","EnumValue","ListValue","ObjectValue","ObjectField","Directive","NamedType","ListType","NonNullType","SchemaDefinition","OperationTypeDefinition","ScalarTypeDefinition","ObjectTypeDefinition","FieldDefinition","InputValueDefinition","InterfaceTypeDefinition","UnionTypeDefinition","EnumTypeDefinition","EnumValueDefinition","InputObjectTypeDefinition","DirectiveDefinition","SchemaExtension","ScalarTypeExtension","ObjectTypeExtension","InterfaceTypeExtension","UnionTypeExtension","EnumTypeExtension","InputObjectTypeExtension","BREAK","visit","root","visitor","visitorKeys","parent","inArray","edits","ancestors","newRoot","isLeaving","isEdited","pop","clone","k","editOffset","ii","editKey","editValue","splice","visitFn","getVisitFn","visitInParallel","visitors","skipping","enter","fn","apply","leave","kindVisitor","kindSpecificVisitor","specificVisitor","specificKindVisitor","objectValues","obj","NAME_RX","objectEntries","entries","keyMap","keyFn","create","mapValue","toObjMap","getPrototypeOf","keyValMap","valFn","didYouMean","firstArg","secondArg","subMessage","suggestionsArg","suggestions","x","selected","lastItem","identityFunc","suggestionList","input","optionsByDistance","lexicalDistance","LexicalDistance","threshold","option","distance","measure","sort","distanceDiff","localeCompare","_input","_inputLowerCase","toLowerCase","_inputArray","stringToArray","_rows","fill","optionLowerCase","tmp","aLength","bLength","rows","j","upRow","currentRow","smallestCell","cost","currentCell","doubleDiagonalCell","strLength","print","ast","printDocASTReducer","op","varDefs","wrap","argsLine","isBlockString","addDescription","hasMultilineItems","cb","maybeArray","separator","maybeString","isMultiline","some","invariant","valueFromASTUntyped","valueNode","variables","parseInt","parseFloat","field","isType","isScalarType","isObjectType","isInterfaceType","isUnionType","isEnumType","isInputObjectType","isListType","isNonNullType","GraphQLScalarType","GraphQLObjectType","GraphQLInterfaceType","GraphQLUnionType","GraphQLEnumType","GraphQLInputObjectType","GraphQLList","GraphQLNonNull","isInputType","isWrappingType","ofType","isOutputType","isLeafType","isCompositeType","isAbstractType","isNullableType","getNullableType","isNamedType","getNamedType","unwrappedType","resolveThunk","thunk","undefineIfEmpty","arr","config","parseValue","specifiedByUrl","serialize","parseLiteral","astNode","extensionASTNodes","toConfig","isTypeOf","_fields","defineFieldMap","bind","_interfaces","defineInterfaces","getFields","getInterfaces","fieldsToFieldsConfig","fieldMap","isPlainObj","fieldConfig","fieldName","resolve","argsConfig","argName","argConfig","deprecationReason","subscribe","argsToArgsConfig","arg","isRequiredArgument","resolveType","_types","defineTypes","getTypes","typeName","valueMap","_values","valueName","valueConfig","_valueLookup","Map","enumValue","_nameLookup","getValues","getValue","outputValue","inputValue","valueStr","didYouMeanEnumValue","_variables","enumType","unknownValueStr","defineInputFieldMap","isRequiredInputField","isEqualType","typeA","typeB","isTypeSubTypeOf","schema","maybeSubType","superType","isSubType","doTypesOverlap","getPossibleTypes","MAX_INT","MIN_INT","GraphQLInt","coercedValue","serializeObject","num","Number","isInteger","GraphQLFloat","isFinite","valueOf","valueOfResult","GraphQLString","GraphQLBoolean","GraphQLID","specifiedScalarTypes","isSpecifiedScalarType","astFromValue","astValue","itemType","iterator","isCollection","valuesNodes","from","itemNode","fieldNodes","fieldValue","serialized","stringNum","integerStringRegExp","test","TypeError","__Schema","__Type","getTypeMap","queryType","getQueryType","mutationType","getMutationType","subscriptionType","getSubscriptionType","__Directive","getDirectives","directive","isRepeatable","__DirectiveLocation","__InputValue","__TypeKind","TypeKind","NON_NULL","__Field","includeDeprecated","possibleTypes","_args","_context","enumValues","__EnumValue","inputFields","isDeprecated","valueAST","SchemaMetaFieldDef","TypeMetaFieldDef","getType","TypeNameMetaFieldDef","parentType","introspectionTypes","isIntrospectionType","isDirective","GraphQLDirective","GraphQLIncludeDirective","if","GraphQLSkipDirective","DEFAULT_DEPRECATION_REASON","GraphQLDeprecatedDirective","reason","GraphQLSpecifiedByDirective","url","specifiedDirectives","assertSchema","GraphQLSchema","isSchema","__validationErrors","assumeValid","_queryType","query","_mutationType","mutation","_subscriptionType","subscription","_directives","allReferencedTypes","Set","delete","collectReferencedTypes","_typeMap","_subTypeMap","_implementationsMap","namedType","iface","implementations","objects","abstractType","getImplementations","interfaceType","getDirective","find","typeSet","has","add","memberType","validateSchema","context","SchemaValidationContext","reportError","getOperationTypeNode","validateRootTypes","validateName","getDeprecatedDirectiveNode","validateDirectives","validateInputObjectCircularRefs","visitedTypes","fieldPath","fieldPathIndexByTypeName","detectCycleRecursive","inputObj","fieldType","cycleIndex","cyclePath","pathStr","fieldObj","createInputObjectCircularRefsValidator","typeMap","validateFields","validateInterfaces","validateUnionMembers","validateEnumValues","validateInputFields","validateTypes","errors","getErrors","_errors","addError","operationNodes","getAllSubNodes","rawOriginalError","locatedError","getAllNodes","ifaceTypeNames","getAllImplementsInterfaceNodes","validateTypeImplementsAncestors","validateTypeImplementsInterface","typeFieldMap","ifaceField","typeField","ifaceArg","typeArg","ifaceInterfaces","transitive","union","memberTypes","includedTypeNames","getUnionMemberTypeNodes","concat","getter","subNodes","typeNode","ifaceNode","unionNode","definitionNode","typeFromAST","innerType","TypeInfo","getFieldDefFn","initialType","_schema","_typeStack","_parentTypeStack","_inputTypeStack","_fieldDefStack","_defaultValueStack","_directive","_argument","_enumValue","_getFieldDef","getFieldDef","getParentType","getInputType","getParentInputType","getDefaultValue","getArgument","getEnumValue","fieldDef","typeConditionAST","outputType","inputType","argDef","argType","fieldOrDirective","listType","objectType","inputFieldType","inputField","fieldNode","visitWithTypeInfo","typeInfo","isExecutableDefinitionNode","isTypeDefinitionNode","isTypeExtensionNode","KnownTypeNamesRule","getSchema","existingTypesMap","definedTypes","def","getDocument","typeNames","_1","_2","isSDL","isTypeSystemDefinitionNode","isTypeSystemExtensionNode","standardTypeNames","isStandardTypeName","suggestedTypes","NoUnusedFragmentsRule","operationDefs","fragmentDefs","fragmentNameUsed","fragment","getRecursivelyReferencedFragments","fragmentDef","fragName","KnownDirectivesRule","locationsMap","definedDirectives","astDefinitions","_key","_parent","_path","candidateLocation","appliedTo","getDirectiveLocationForOperation","getDirectiveLocationForASTPath","UniqueDirectivesPerLocationRule","uniqueDirectiveMap","schemaDirectives","typeDirectivesMap","seenDirectives","directiveName","KnownArgumentNamesOnDirectivesRule","directiveArgs","argsNodes","directiveNode","knownArgs","argNode","UniqueArgumentNamesRule","knownArgNames","isValidValueNode","locationType","typeStr","ProvidedRequiredArgumentsOnDirectivesRule","requiredArgsMap","argNodes","isRequiredArgumentNode","requiredArgs","argNodeMap","argTypeStr","allowedVariableUsage","varType","varDefaultValue","locationDefaultValue","hasLocationDefaultValue","reasonMessage","responseName","subReason","collectConflictsBetweenFieldsAndFragment","conflicts","cachedFieldsAndFragmentNames","comparedFragmentPairs","areMutuallyExclusive","fragmentName","getFragment","fieldMap2","fragmentNames2","getReferencedFieldsAndFragmentNames","collectConflictsBetween","collectConflictsBetweenFragments","fragmentName1","fragmentName2","fragment1","fragment2","fieldMap1","fragmentNames1","parentFieldsAreMutuallyExclusive","fields2","fields1","conflict","findConflict","field1","field2","parentType1","node1","def1","parentType2","node2","def2","name1","name2","arguments1","arguments2","every","argument1","argument2","argument","value1","value2","sameArguments","type1","type2","doTypesConflict","selectionSet1","selectionSet2","allFields","subfieldConflicts","getFieldsAndFragmentNames","findConflictsBetweenSubSelectionSets","cached","nodeAndDefs","fragmentNames","_collectFieldsAndFragmentNames","set","fragmentType","selection","inlineFragmentType","PairSet","_data","first","_pairSetAdd","UniqueInputFieldNamesRule","knownNameStack","knownNames","hasField","defKindToExtKind","specifiedRules","definition","defName","knownOperationNames","operationName","operationCount","variableName","suggestion","usageCount","possibleType","possibleInterface","usageCountDiff","getSuggestedTypeNames","getSuggestedFieldNames","knownFragmentNames","fragType","parentTypeStr","fragTypeStr","frag","getFragmentType","visitedFrags","spreadPath","spreadPathIndexByName","spreadNodes","getFragmentSpreads","spreadNode","spreadName","spreadFragment","viaPath","s","knownVariableNames","variableNameDefined","usages","getRecursiveVariableUsages","varName","variableDefs","variableNameUsed","variableDef","fieldNodeMap","varDefMap","varDef","varTypeStr","collectConflictsWithin","findConflictsWithinSelectionSet","reasonMsg","specifiedSDLRules","oldSchema","alreadyDefined","schemaDefinitionsCount","definedOperationTypes","existingOperationTypes","checkOperationTypes","operationTypesNodes","operationType","alreadyDefinedOperationType","knownTypeNames","checkTypeName","existingTypeMap","knownValueNames","checkValueUniqueness","valueNodes","valueNames","valueDef","existingType","knownFieldNames","checkFieldUniqueness","fieldNames","knownDirectiveNames","checkExtension","defNode","expectedKind","typeToExtKind","kindStr","extensionKindToTypeName","allTypeNames","ASTValidationContext","onError","_ast","_fragments","_fragmentSpreads","_recursivelyReferencedFragments","_onError","fragments","frags","statement","spreads","setsToVisit","collectedNames","nodesToVisit","spread","SDLValidationContext","ValidationContext","_typeInfo","_variableUsages","_recursiveVariableUsages","getVariableUsages","newUsages","validate","documentAST","rules","maxErrors","assertValidSchema","abortObj","rule","e","validateSDL","schemaToExtend","valueFromAST","variableValue","coercedValues","isMissingVariable","itemValue","coercedObj","_error","getDirectiveValues","directiveDef","variableValues","argumentNode","isNull","prop","hasOwnProperty","getArgumentValues","buildClientSchema","introspection","__schema","schemaIntrospection","typeIntrospection","scalarIntrospection","objectIntrospection","buildImplementationsList","buildFieldDefMap","interfaceIntrospection","unionIntrospection","unionIntrospectionStr","getObjectType","buildUnionDef","enumIntrospection","enumIntrospectionStr","valueIntrospection","buildEnumDef","inputObjectIntrospection","inputObjectIntrospectionStr","buildInputValueDefMap","buildInputObjectDef","buildType","stdType","directiveIntrospection","directiveIntrospectionStr","typeRef","itemRef","nullableRef","nullableType","assertNullableType","assertObjectType","getInterfaceType","assertInterfaceType","implementingIntrospection","implementingIntrospectionStr","fieldIntrospection","buildField","fieldIntrospectionStr","inputValueIntrospections","buildInputValue","inputValueIntrospection","parser","extendSchemaImpl","schemaConfig","typeDefs","typeExtensionsMap","directiveDefs","schemaDef","schemaExtensions","extendedTypeName","existingTypeExtensions","extendNamedType","stdTypeMap","replaceNamedType","getOperationTypes","extendArg","buildArgumentMap","replaceType","extensionNode","getSpecifiedByUrl","extendScalarType","buildInterfaces","extendField","buildFieldMap","extendObjectType","extendInterfaceType","buildUnionTypes","extendUnionType","buildEnumValueMap","extendEnumType","buildInputFieldMap","extendInputObjectType","opTypes","getWrappedType","fieldConfigMap","nodeFields","getDeprecationReason","argConfigMap","inputFieldMap","fieldsNodes","enumValueMap","interfacesNodes","typeNodes","extensionNodes","allNodes","buildASTSchema","assumeValidSDL","assertValidSDL","stdDirective","printSchema","directiveFilter","typeFilter","printSchemaDefinition","printDescription","printArgs","printDirective","scalar","urlAST","printSpecifiedByUrl","printScalar","printImplementedInterfaces","printFields","printObject","printInterface","printUnion","printDeprecated","printBlock","printEnum","f","printInputValue","printInputObject","printType","printFilteredSchema","n","isDefinedType","isSchemaOfCommonNames","defaultAST","argDecl","reasonAST","firstInBlock","specifiedRulesToBeRemoved","defaultValidationRules","includes","GraphQLSchemaValidationError","validationErrors","isMetaFieldName","startsWith","isNotNullOrUndefined","valueFromValueNode","filePathForNode","compileToIR","document","fragmentNodeMap","operations","fragmentMap","referencedTypes","compileOperation","fragmentNode","compileFragment","operationDefinition","filePath","rootType","getOperationRootType","compileSelectionSet","fragmentDefinition","selectionSetNode","visitedFragments","selectionNode","unwrappedFieldType","argDefType","compileSelection","introspectionResult","payload","data","documents","doc","concatAST"],"mappings":"mDAIe,SAASA,EAAaC,GACnC,MAAuB,iBAATA,GAA+B,OAAVA,ECG9B,SAASC,EAAYC,EAAQC,GAClC,MAAMC,EAAa,eACnB,IAEIC,EAFAC,EAAO,EACPC,EAASJ,EAAW,EAGxB,MAAQE,EAAQD,EAAWI,KAAKN,EAAOO,QAAUJ,EAAMK,MAAQP,GAC7DG,GAAQ,EACRC,EAASJ,EAAW,GAAKE,EAAMK,MAAQL,EAAM,GAAGM,QAGlD,MAAO,CACLL,KAAAA,EACAC,OAAAA,GChBG,SAASK,EAAcC,GAC5B,OAAOC,EAAoBD,EAASX,OAAQD,EAAYY,EAASX,OAAQW,EAASE,QAM7E,SAASD,EAAoBZ,EAAQc,GAC1C,MAAMC,EAAwBf,EAAOgB,eAAeX,OAAS,EACvDE,EAAOU,EAAWF,GAAyBf,EAAOO,KAClDW,EAAYJ,EAAeV,KAAO,EAClCe,EAAanB,EAAOgB,eAAeZ,KAAO,EAC1CgB,EAAUN,EAAeV,KAAOe,EAChCE,EAAu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AAMhnB,EAASsd,GAAkByJ,GAIjC,OAFA9K,GAAkBjc,GAEXA,gCAGyB3mB,GAChC,MAAMqsC,EAAW/7B,EAAMtQ,aLlBMqsC,GAC7B,MAAM1c,EAASqT,GAAYqJ,GAC3B,GAAsB,IAAlB1c,EAAOlvB,OACT,MAAM,IAAIorC,6BAA6Blc,GKiBzC8Z,CAAe4C,GAEf,MAAM1lB,EAAS4iB,GAAe8C,EAAU,CAAE7C,gBAAgB,IAI1D,OAFA5G,GAAkBjc,GAEXA,6BAWsBinB,GAC7B,OC/DK,SAAmBA,GACxB,IAAI38B,EAAc,GAElB,IAAK,MAAM48B,KAAOD,EAChB38B,EAAcA,EAAYkgB,OAAO0c,EAAI58B,aAGvC,MAAO,CACLjI,KAAM,WACNiI,YAAAA,GDsDK68B,CAAUF,6BALW5tC,GAC5B,OAAOsQ,EAAMtQ,gCALkB2mB,GAC/B,OAAOgjB,GAAYhjB,gCAYnBA,EACA0lB,GAEA,OAAO7J,GAAS7b,EAAQ0lB,EAAUV"} \ No newline at end of file diff --git a/Sources/ApolloCodegenLib/URLDownloader.swift b/Sources/ApolloCodegenLib/URLDownloader.swift new file mode 100644 index 0000000000..f0b351e2b5 --- /dev/null +++ b/Sources/ApolloCodegenLib/URLDownloader.swift @@ -0,0 +1,121 @@ +import Foundation + +/// A protocol to abstract the underlying network provider. +protocol NetworkSession { + + /// Load data via the abstracted network provider + /// + /// - Parameters: + /// - urlRequest: A URL request object that provides the URL, cache policy, request type, body data or body stream, and so on. + /// - completionHandler: The completion handler to call when the load request is complete. + /// - Returns: The new session data task. This task will already have been started with a call to `resume`. + @discardableResult func loadData(with urlRequest: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask? +} + +extension URLSession: NetworkSession { + func loadData(with urlRequest: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask? { + let task = dataTask(with: urlRequest) { (data, response, error) in + completionHandler(data, response, error) + } + task.resume() + + return task + } +} + +/// A class to help download things from a given remote URL to a given local file URL +class URLDownloader { + let session: NetworkSession + + enum DownloadError: Error, LocalizedError { + case badResponse(code: Int, response: String?) + case emptyDataReceived + case noDataReceived + case downloadTimedOut(after: Double) + case responseNotHTTPResponse + + var errorDescription: String? { + switch self { + case .badResponse(let code, let response): + return "Received bad response from server (code \(code)): \(String(describing: response))" + case .emptyDataReceived: + return "Empty data was received from the server." + case .noDataReceived: + return "No data was received from the server." + case .downloadTimedOut(let seconds): + return "Download timed out after \(seconds) seconds." + case .responseNotHTTPResponse: + return "The response was not an HTTP Response, something's gone very wonky." + } + } + } + + /// Designated initializer. + /// + /// - Parameters: + /// - session: The NetworkSession conforming instance used for downloads, defaults to the shared URLSession singleton object. + init(session: NetworkSession = URLSession.shared) { + self.session = session + } + + /// Downloads the contents of a given URL synchronously to the given output URL + /// - Parameters: + /// - urlRequest: A URL request object that provides the URL, cache policy, request type, body data or body stream, and so on. + /// - outputURL: The file URL where the result will be written to. + /// - timeout: The timeout value for the download request duration. + /// - Throws: Any error which occurs during the download. + func downloadSynchronously(with urlRequest: URLRequest, to outputURL: URL, timeout: Double) throws { + let semaphore = DispatchSemaphore(value: 0) + var errorToThrow: Error? = DownloadError.downloadTimedOut(after: timeout) + + session.loadData(with: urlRequest) { data, response, error in + func finished(with finalError: Error?) { + errorToThrow = finalError + semaphore.signal() + } + + if let error = error { + finished(with: error) + return + } + + guard let httpResponse = response as? HTTPURLResponse else { + finished(with: DownloadError.responseNotHTTPResponse) + return + } + + guard httpResponse.statusCode == 200 else { + let dataAsString = String(bytes: data ?? Data(), encoding: .utf8) + finished(with: DownloadError.badResponse(code: httpResponse.statusCode, response: dataAsString)) + return + } + + guard let data = data else { + finished(with: DownloadError.noDataReceived) + return + } + + guard !data.isEmpty else { + finished(with: DownloadError.emptyDataReceived) + return + } + + do { + try FileManager.default.apollo.createContainingFolderIfNeeded(for: outputURL) + try data.write(to: outputURL) + } catch (let writeError) { + finished(with: writeError) + return + } + + // If we got here, it all worked and it's good to go! + finished(with: nil) + } + + _ = semaphore.wait(timeout: .now() + timeout) + + if let throwMe = errorToThrow { + throw throwMe + } // else, success! + } +} diff --git a/Sources/ApolloCodegenLib/UntypedGraphQLRequestBodyCreator.swift b/Sources/ApolloCodegenLib/UntypedGraphQLRequestBodyCreator.swift new file mode 100644 index 0000000000..7c1de2a8af --- /dev/null +++ b/Sources/ApolloCodegenLib/UntypedGraphQLRequestBodyCreator.swift @@ -0,0 +1,53 @@ +import Foundation + +class UntypedGraphQLRequestBodyCreator { + + /// A non-type-safe request creator to facilitate sending requests not using code generation. + /// + /// - Parameters: + /// - operationDocument: The query/mutation/subscription document, as a string + /// - variables: [optional] Any variables to send with the operation + /// - operationName: The name of the operation being sent + /// - sendQueryDocument: If the query document should be sent - defaults to true. + /// - sendOperationIdentifiers: If operation identifers should be sent. Defaults to false + /// - operationIdentifier: [Optional] The operation identifier to use, defaults to nil + /// - autoPersistQuery: Whether the query should be auto-persisted, defaults to false. + /// - Returns: The body for the given request, ready to be added as the `httpBody`. + static func requestBody(for operationDocument: String, + variables: [String: Any]?, + operationName: String, + sendQueryDocument: Bool = true, + sendOperationIdentifiers: Bool = false, + operationIdentifier: String? = nil, + autoPersistQuery: Bool = false) -> [String: Any?] { + + var body: [String: Any?] = [ + "variables": variables, + "operationName": operationName, + ] + + if sendOperationIdentifiers { + guard let operationIdentifier = operationIdentifier else { + preconditionFailure("To send operation identifiers, Apollo types must be generated with operationIdentifiers") + } + + body["id"] = operationIdentifier + } + + if sendQueryDocument { + body["query"] = operationDocument + } + + if autoPersistQuery { + guard let operationIdentifier = operationIdentifier else { + preconditionFailure("To enable `autoPersistQueries`, Apollo types must be generated with operationIdentifiers") + } + + body["extensions"] = [ + "persistedQuery" : ["sha256Hash": operationIdentifier, "version": 1] + ] + } + + return body + } +} diff --git a/Sources/ApolloCodegenTestSupport/CodegenTestHelper.swift b/Sources/ApolloCodegenTestSupport/CodegenTestHelper.swift index 6fab3453cc..2247705fef 100644 --- a/Sources/ApolloCodegenTestSupport/CodegenTestHelper.swift +++ b/Sources/ApolloCodegenTestSupport/CodegenTestHelper.swift @@ -97,6 +97,14 @@ public struct CodegenTestHelper { .appendingPathComponent("Output") } + public static func schemaFolderURL() -> URL { + let sourceRoot = self.sourceRootURL() + return sourceRoot + .appendingPathComponent("Tests") + .appendingPathComponent("ApolloCodegenTests") + .appendingPathComponent("Schema") + } + public static func deleteExistingOutputFolder(file: StaticString = #filePath, line: UInt = #line) { do { @@ -113,7 +121,7 @@ public struct CodegenTestHelper { line: UInt = #line) { do { let cliFolderURL = self.cliFolderURL() - try CLIDownloader.downloadIfNeeded(cliFolderURL: cliFolderURL, timeout: CodegenTestHelper.timeout) + try CLIDownloader.downloadIfNeeded(to: cliFolderURL, timeout: CodegenTestHelper.timeout) } catch { XCTFail("Error downloading CLI if needed: \(error)", file: file, diff --git a/Sources/ApolloCodegenTestSupport/MockNetworkSession.swift b/Sources/ApolloCodegenTestSupport/MockNetworkSession.swift new file mode 100644 index 0000000000..bb9fb48b36 --- /dev/null +++ b/Sources/ApolloCodegenTestSupport/MockNetworkSession.swift @@ -0,0 +1,24 @@ +@testable import ApolloCodegenLib + +public final class MockNetworkSession: NetworkSession { + let statusCode: Int + let data: Data? + let error: Error? + let abandon: Bool + + public init(statusCode: Int, data: Data? = nil, error: Error? = nil, abandon: Bool = false) { + self.statusCode = statusCode + self.data = data + self.error = error + self.abandon = abandon + } + + public func loadData(with urlRequest: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask? { + guard !abandon else { return nil } + + let response = HTTPURLResponse(url: urlRequest.url!, statusCode: statusCode, httpVersion: nil, headerFields: nil) + completionHandler(data, response, error) + + return nil + } +} diff --git a/SwiftScripts/Sources/SchemaDownload/main.swift b/SwiftScripts/Sources/SchemaDownload/main.swift index d72627cada..89ec5170a1 100644 --- a/SwiftScripts/Sources/SchemaDownload/main.swift +++ b/SwiftScripts/Sources/SchemaDownload/main.swift @@ -10,10 +10,6 @@ let sourceRootURL = parentFolderOfScriptFile .deletingLastPathComponent() // SwiftScripts .deletingLastPathComponent() // apollo-ios -let cliFolderURL = sourceRootURL - .appendingPathComponent("SwiftScripts") - .appendingPathComponent("ApolloCLI") - let endpoint = URL(string: "http://localhost:4000/")! let output = sourceRootURL @@ -21,22 +17,19 @@ let output = sourceRootURL .appendingPathComponent("UploadAPI") // Introspection download: -let options = ApolloSchemaOptions(schemaFileName: "schema", - downloadMethod: .introspection(endpointURL: endpoint), - outputFolderURL: output) +let configuration = ApolloSchemaDownloadConfiguration(using: .introspection(endpointURL: endpoint), + outputFolderURL: output, + schemaFilename: "schema") // Registry download: -//let registrySettings = ApolloSchemaOptions.DownloadMethod.RegistrySettings(apiKey: <#Replace Me For Testing#>, -// graphID: "Apollo-Fullstack-8zo5jl") +//let registrySettings = ApolloSchemaDownloadConfiguration.DownloadMethod.RegistrySettings(apiKey: <#Replace Me For Testing#>, +// graphID: "Apollo-Fullstack-8zo5jl") // -//let options = ApolloSchemaOptions(schemaFileName: "schema", -// schemaFileType: .schemaDefinitionLanguage, -// downloadMethod: .registry(registrySettings), -// outputFolderURL: output) +//let configuration = ApolloSchemaDownloadConfiguration(using: .registry(registrySettings), +// outputFolderURL: output) do { - try ApolloSchemaDownloader.run(with: cliFolderURL, - options: options) + try ApolloSchemaDownloader.fetch(with: configuration) } catch { exit(1) } diff --git a/Tests/ApolloCodegenTests/ApolloSchemaTests.swift b/Tests/ApolloCodegenTests/ApolloSchemaTests.swift index 23678a9871..7fac755591 100644 --- a/Tests/ApolloCodegenTests/ApolloSchemaTests.swift +++ b/Tests/ApolloCodegenTests/ApolloSchemaTests.swift @@ -1,92 +1,79 @@ -// -// ApolloSchemaTests.swift -// ApolloCodegenTests -// -// Created by Ellen Shapiro on 10/7/19. -// Copyright © 2019 Apollo GraphQL. All rights reserved. -// - import XCTest import ApolloTestSupport import ApolloCodegenTestSupport @testable import ApolloCodegenLib class ApolloSchemaTests: XCTestCase { - - func testCreatingIntrospectionOptionsWithDefaultParameters() throws { - let sourceRoot = CodegenTestHelper.sourceRootURL() - - let options = ApolloSchemaOptions(downloadMethod: .introspection(endpointURL: TestURL.mockPort8080.url), - outputFolderURL: sourceRoot) - - let expectedOutputURL = sourceRoot.appendingPathComponent("schema.json") - - XCTAssertEqual(options.downloadMethod, .introspection(endpointURL: TestURL.mockPort8080.url)) - XCTAssertEqual(options.outputURL, expectedOutputURL) - XCTAssertTrue(options.headers.isEmpty) - - XCTAssertEqual(options.arguments, [ - "client:download-schema", - "--endpoint=http://localhost:8080/graphql", - "'\(expectedOutputURL.path)'" - ]) + private var defaultOutputURL: URL { + return CodegenTestHelper.outputFolderURL() + .appendingPathComponent("schema.graphqls") } - func testCreatingRegistryOptionsWithDefaultParameters() throws { - let sourceRoot = CodegenTestHelper.sourceRootURL() - let apiKey = "Fake_API_Key" - let graphID = "Fake_Graph_ID" - - let settings = ApolloSchemaOptions.DownloadMethod.RegistrySettings(apiKey: apiKey, graphID: graphID) - - let options = ApolloSchemaOptions(downloadMethod: .registry(settings), - outputFolderURL: sourceRoot) - - let expectedOutputURL = sourceRoot.appendingPathComponent("schema.json") - - XCTAssertEqual(options.downloadMethod, .registry(settings)) - XCTAssertEqual(options.outputURL, expectedOutputURL) - XCTAssertTrue(options.headers.isEmpty) - - XCTAssertEqual(options.arguments, [ - "client:download-schema", - "--key=\(apiKey)", - "--graph=\(graphID)", - "'\(expectedOutputURL.path)'" - ]) + func testCreatingSchemaDownloadConfiguration_forIntrospectionDownload_usingDefaultParameters() throws { + let configuration = ApolloSchemaDownloadConfiguration(using: .introspection(endpointURL: TestURL.mockPort8080.url), + outputFolderURL: CodegenTestHelper.outputFolderURL()) + + XCTAssertEqual(configuration.downloadMethod, .introspection(endpointURL: TestURL.mockPort8080.url)) + XCTAssertEqual(configuration.outputURL, self.defaultOutputURL) + XCTAssertTrue(configuration.headers.isEmpty) } - func testCreatingRegistryOptionsWithAllParameters() throws { + func testCreatingSchemaDownloadConfiguration_forRegistryDownload_usingDefaultParameters() throws { + let settings = ApolloSchemaDownloadConfiguration.DownloadMethod.ApolloRegistrySettings(apiKey: "Fake_API_Key", + graphID: "Fake_Graph_ID") + let configuration = ApolloSchemaDownloadConfiguration(using: .apolloRegistry(settings), + outputFolderURL: CodegenTestHelper.outputFolderURL()) + + XCTAssertEqual(configuration.downloadMethod, .apolloRegistry(settings)) + XCTAssertEqual(configuration.outputURL, self.defaultOutputURL) + XCTAssertTrue(configuration.headers.isEmpty) + } + + func testCreatingSchemaDownloadConfiguration_forRegistryDownload_usingAllParameters() throws { let sourceRoot = CodegenTestHelper.sourceRootURL() - let apiKey = "Fake_API_Key" - let graphID = "Fake_Graph_ID" - let variant = "Fake_Variant" - let firstHeader = "Authorization: Bearer tokenGoesHere" - let secondHeader = "Custom-Header: Custom_Customer" - let headers = [firstHeader, secondHeader] - - let settings = ApolloSchemaOptions.DownloadMethod.RegistrySettings(apiKey: apiKey, - graphID: graphID, variant: variant) - - let options = ApolloSchemaOptions(schemaFileName: "different_name", - schemaFileType: .schemaDefinitionLanguage, - downloadMethod: .registry(settings), - headers: headers, - outputFolderURL: sourceRoot) - XCTAssertEqual(options.downloadMethod, .registry(settings)) - XCTAssertEqual(options.headers, headers) - - let expectedOutputURL = sourceRoot.appendingPathComponent("different_name.graphql") - XCTAssertEqual(options.outputURL, expectedOutputURL) - - XCTAssertEqual(options.arguments, [ - "client:download-schema", - "--key=\(apiKey)", - "--graph=\(graphID)", - "--variant=\(variant)", - "'\(expectedOutputURL.path)'", - "--header='\(firstHeader)'", - "--header='\(secondHeader)'" - ]) + let settings = ApolloSchemaDownloadConfiguration.DownloadMethod.ApolloRegistrySettings(apiKey: "Fake_API_Key", + graphID: "Fake_Graph_ID", + variant: "Fake_Variant") + let headers = [ + ApolloSchemaDownloadConfiguration.HTTPHeader(key: "Authorization", value: "Bearer tokenGoesHere"), + ApolloSchemaDownloadConfiguration.HTTPHeader(key: "Custom-Header", value: "Custom_Customer") + ] + + let schemaFileName = "different_name" + let configuration = ApolloSchemaDownloadConfiguration(using: .apolloRegistry(settings), + headers: headers, + outputFolderURL: sourceRoot, + schemaFilename: schemaFileName) + + XCTAssertEqual(configuration.downloadMethod, .apolloRegistry(settings)) + XCTAssertEqual(configuration.headers, headers) + + let expectedOutputURL = sourceRoot.appendingPathComponent("\(schemaFileName).graphqls") + XCTAssertEqual(configuration.outputURL, expectedOutputURL) + } + + func testFormatConversion_givenIntrospectionJSON_shouldOutputValidSDL() throws { + let bundle = Bundle(for: type(of: self)) + guard let jsonURL = bundle.url(forResource: "introspection_response", withExtension: "json") else { + throw XCTFailure("Missing resource file!", file: #file, line: #line) + } + + try FileManager.default.apollo.createFolderIfNeeded(at: CodegenTestHelper.outputFolderURL()) + let configuration = ApolloSchemaDownloadConfiguration(using: .introspection(endpointURL: TestURL.mockPort8080.url), + outputFolderURL: CodegenTestHelper.outputFolderURL()) + + try ApolloSchemaDownloader.convertFromIntrospectionJSONToSDLFile(jsonFileURL: jsonURL, configuration: configuration) + XCTAssertTrue(FileManager.default.apollo.fileExists(at: configuration.outputURL)) + + let frontend = try ApolloCodegenFrontend() + let source = try frontend.makeSource(from: configuration.outputURL) + let schema = try frontend.loadSchemaFromSDL(source) + + let authorType = try schema.getType(named: "Author") + XCTAssertEqual(authorType?.name, "Author") + + let postType = try schema.getType(named: "Post") + XCTAssertEqual(postType?.name, "Post") } } + diff --git a/Tests/ApolloCodegenTests/CLIDownloaderTests.swift b/Tests/ApolloCodegenTests/CLIDownloaderTests.swift index 9c98f2a24a..51949ed3a4 100644 --- a/Tests/ApolloCodegenTests/CLIDownloaderTests.swift +++ b/Tests/ApolloCodegenTests/CLIDownloaderTests.swift @@ -1,56 +1,44 @@ -// -// CLIDownloaderTests.swift -// Apollo -// -// Created by Ellen Shapiro on 10/22/19. -// Copyright © 2019 Apollo GraphQL. All rights reserved. -// - @testable import ApolloCodegenLib import ApolloCodegenTestSupport import XCTest class CLIDownloaderTests: XCTestCase { - - func testRedownloading() throws { + func testForceRedownloading_withExistingFile_shouldOverwriteWithExpectedChecksum() throws { let scriptsURL = CodegenTestHelper.cliFolderURL() - - try CLIDownloader.forceRedownload(cliFolderURL: scriptsURL, timeout: CodegenTestHelper.timeout) - let zipFileURL = ApolloFilePathHelper.zipFileURL(fromCLIFolder: scriptsURL) - XCTAssertTrue(FileManager.default.apollo.fileExists(at: zipFileURL)) + + try "Dummy file".data(using: .utf8)?.write(to: zipFileURL) + XCTAssertTrue(FileManager.default.apollo.fileExists(at: zipFileURL), "Created dummy file to be overwritten") + + try CLIDownloader.forceRedownload(to: scriptsURL, timeout: CodegenTestHelper.timeout) + XCTAssertTrue(FileManager.default.apollo.fileExists(at: zipFileURL), "Downloaded Apollo CLI") XCTAssertEqual(try FileManager.default.apollo.shasum(at: zipFileURL), CLIExtractor.expectedSHASUM) } - func testDownloadingToFolderThatDoesntAlreadyExistWorks() throws { + func testDownloading_toFolderThatDoesNotExist_shouldCreateFolder() throws { let scriptsURL = CodegenTestHelper.cliFolderURL() try FileManager.default.apollo.deleteFolder(at: scriptsURL) - XCTAssertFalse(FileManager.default.apollo.folderExists(at: scriptsURL)) - - try CLIDownloader.downloadIfNeeded(cliFolderURL: scriptsURL, timeout: 90.0) - + + try CLIDownloader.downloadIfNeeded(to: scriptsURL, timeout: 90.0) XCTAssertTrue(FileManager.default.apollo.folderExists(at: scriptsURL)) } - func testTimeoutThrowsCorrectError() throws { + func testTimeout_shouldThrowCorrectError() throws { let scriptsURL = CodegenTestHelper.cliFolderURL() - // This file is big enough that unless both you and the server have a terabyte connection, 2 seconds won't be enough time to download it. do { - try CLIDownloader.forceRedownload(cliFolderURL: scriptsURL, timeout: 2.0) + try CLIDownloader.forceRedownload(to: scriptsURL, timeout: 0.5) } catch { - guard let downloaderError = error as? CLIDownloader.CLIDownloaderError else { + guard + let DownloadError = error as? URLDownloader.DownloadError, + case .downloadTimedOut(let seconds) = DownloadError + else { XCTFail("Wrong type of error") return } - - switch downloaderError { - case .downloadTimedOut(let seconds): - XCTAssertEqual(seconds, 2.0, accuracy: 0.0001) - default: - XCTFail("Wrong type of error") - } + + XCTAssertEqual(seconds, 0.5, accuracy: 0.0001) } } } diff --git a/Tests/ApolloCodegenTests/Resources/introspection_response.json b/Tests/ApolloCodegenTests/Resources/introspection_response.json new file mode 100644 index 0000000000..a860f3deb2 --- /dev/null +++ b/Tests/ApolloCodegenTests/Resources/introspection_response.json @@ -0,0 +1 @@ +{"data":{"__schema":{"queryType":{"name":"Query"},"mutationType":{"name":"Mutation"},"subscriptionType":null,"types":[{"kind":"OBJECT","name":"Query","description":"the schema allows the following query:","fields":[{"name":"posts","description":"","args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"Post","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"author","description":"","args":[{"name":"id","description":"","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Int","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"Author","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Post","description":"","fields":[{"name":"id","description":"","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Int","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"title","description":"","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"author","description":"","args":[],"type":{"kind":"OBJECT","name":"Author","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"votes","description":"","args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Int","description":"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"String","description":"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Author","description":"","fields":[{"name":"id","description":"","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Int","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"firstName","description":"","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"lastName","description":"","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"posts","description":"","args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"Post","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Mutation","description":"this schema allows the following mutation:","fields":[{"name":"upvotePost","description":"","args":[{"name":"postId","description":"","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Int","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"Post","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Schema","description":"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.","fields":[{"name":"types","description":"A list of all types supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"queryType","description":"The type that query operations will be rooted at.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"mutationType","description":"If this server supports mutation, the type that mutation operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"subscriptionType","description":"If this server support subscription, the type that subscription operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"directives","description":"A list of all directives supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Directive","ofType":null}}}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Type","description":"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.","fields":[{"name":"kind","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__TypeKind","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"name","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"fields","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false"}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Field","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"interfaces","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"possibleTypes","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"enumValues","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false"}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__EnumValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"inputFields","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"ofType","description":null,"args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"ENUM","name":"__TypeKind","description":"An enum describing what kind of type a given `__Type` is.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"SCALAR","description":"Indicates this type is a scalar.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Indicates this type is an object. `fields` and `interfaces` are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Indicates this type is a union. `possibleTypes` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Indicates this type is an enum. `enumValues` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Indicates this type is an input object. `inputFields` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"LIST","description":"Indicates this type is a list. `ofType` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"NON_NULL","description":"Indicates this type is a non-null. `ofType` is a valid field.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null},{"kind":"SCALAR","name":"Boolean","description":"The `Boolean` scalar type represents `true` or `false`.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Field","description":"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__InputValue","description":"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"defaultValue","description":"A GraphQL-formatted string representing the default value for this input value.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__EnumValue","description":"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Directive","description":"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"locations","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__DirectiveLocation","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"onOperation","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use `locations`."},{"name":"onFragment","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use `locations`."},{"name":"onField","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use `locations`."}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"ENUM","name":"__DirectiveLocation","description":"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"QUERY","description":"Location adjacent to a query operation.","isDeprecated":false,"deprecationReason":null},{"name":"MUTATION","description":"Location adjacent to a mutation operation.","isDeprecated":false,"deprecationReason":null},{"name":"SUBSCRIPTION","description":"Location adjacent to a subscription operation.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD","description":"Location adjacent to a field.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_DEFINITION","description":"Location adjacent to a fragment definition.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_SPREAD","description":"Location adjacent to a fragment spread.","isDeprecated":false,"deprecationReason":null},{"name":"INLINE_FRAGMENT","description":"Location adjacent to an inline fragment.","isDeprecated":false,"deprecationReason":null},{"name":"SCHEMA","description":"Location adjacent to a schema definition.","isDeprecated":false,"deprecationReason":null},{"name":"SCALAR","description":"Location adjacent to a scalar definition.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Location adjacent to an object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD_DEFINITION","description":"Location adjacent to a field definition.","isDeprecated":false,"deprecationReason":null},{"name":"ARGUMENT_DEFINITION","description":"Location adjacent to an argument definition.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Location adjacent to an interface definition.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Location adjacent to a union definition.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Location adjacent to an enum definition.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM_VALUE","description":"Location adjacent to an enum value definition.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Location adjacent to an input object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_FIELD_DEFINITION","description":"Location adjacent to an input object field definition.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null}],"directives":[{"name":"skip","description":"Directs the executor to skip this field or fragment when the `if` argument is true.","locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Skipped when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null}]},{"name":"include","description":"Directs the executor to include this field or fragment only when the `if` argument is true.","locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Included when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null}]},{"name":"deprecated","description":"Marks an element of a GraphQL schema as no longer supported.","locations":["FIELD_DEFINITION","ENUM_VALUE"],"args":[{"name":"reason","description":"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":"\"No longer supported\""}]}]}}} diff --git a/Tests/ApolloCodegenTests/URLDownloaderTests.swift b/Tests/ApolloCodegenTests/URLDownloaderTests.swift new file mode 100644 index 0000000000..3ec8d280cc --- /dev/null +++ b/Tests/ApolloCodegenTests/URLDownloaderTests.swift @@ -0,0 +1,139 @@ +@testable import ApolloCodegenLib +import ApolloTestSupport +import ApolloCodegenTestSupport +import XCTest + +fileprivate class FailingNetworkSession: NetworkSession { + func loadData(with urlRequest: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask? { + XCTFail("You must call setRequestHandler before using downloader!") + + return nil + } +} + +class URLDownloaderTests: XCTestCase { + let urlRequest = URLRequest(url: TestURL.mockServer.url) + let downloadURL = URL(string: "file://anywhere/nowhere/somewhere")! + let defaultTimeout = 0.5 + var downloader: URLDownloader! + var session: NetworkSession! + + override func setUp() { + downloader = URLDownloader(session: FailingNetworkSession()) + session = nil + } + + override func tearDown() { + downloader = nil + session = nil + } + + private func setRequestHandler(statusCode: Int, data: Data? = nil, error: Error? = nil, abandon: Bool = false) { + session = MockNetworkSession(statusCode: statusCode, data: data, error: error, abandon: abandon) + downloader = URLDownloader(session: session) + } + + func testDownloadError_withCustomError_shouldThrow() throws { + let statusCode = 400 + let domain = "ApolloCodegenTests" + let error = NSError(domain: domain, code: NSURLErrorNotConnectedToInternet, userInfo: nil) + + setRequestHandler(statusCode: statusCode, error: error) + + do { + try downloader.downloadSynchronously(with: urlRequest, to: downloadURL, timeout: defaultTimeout) + } catch (let error as NSError) { + XCTAssertEqual(error.domain, domain) + XCTAssertEqual(error.code, NSURLErrorNotConnectedToInternet) + } + } + + func testDownloadError_withBadResponse_shouldThrow() throws { + let statusCode = 500 + let responseString = "Internal Error" + + setRequestHandler(statusCode: statusCode, data: responseString.data(using: .utf8)) + + do { + try downloader.downloadSynchronously(with: urlRequest, to: downloadURL, timeout: defaultTimeout) + } catch URLDownloader.DownloadError.badResponse(let code, let response) { + XCTAssertEqual(code, statusCode) + XCTAssertEqual(response, responseString) + } catch { + XCTFail("Unexpected error received: \(error)") + } + } + + func testDownloadError_withEmptyResponseData_shouldThrow() throws { + setRequestHandler(statusCode: 200, data: Data()) + + do { + try downloader.downloadSynchronously(with: urlRequest, to: downloadURL, timeout: defaultTimeout) + } catch URLDownloader.DownloadError.emptyDataReceived { + // Expected response + } catch { + XCTFail("Unexpected error received: \(error)") + } + } + + func testDownloadError_withNoResponseData_shouldThrow() throws { + setRequestHandler(statusCode: 200) + + do { + try downloader.downloadSynchronously(with: urlRequest, to: downloadURL, timeout: defaultTimeout) + } catch URLDownloader.DownloadError.noDataReceived { + // Expected response + } catch { + XCTFail("Unexpected error received: \(error)") + } + } + + func testDownloadError_whenExceedingTimeout_shouldThrow() throws { + setRequestHandler(statusCode: 200, abandon: true) + + do { + try downloader.downloadSynchronously(with: urlRequest, to: downloadURL, timeout: defaultTimeout) + } catch URLDownloader.DownloadError.downloadTimedOut(let timeout) { + XCTAssertEqual(timeout, defaultTimeout) + } catch { + XCTFail("Unexpected error received: \(error)") + } + } + + func testDownloadError_withIncorrectResponseType_shouldThrow() throws { + class CustomNetworkSession: NetworkSession { + func loadData(with urlRequest: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask? { + completionHandler(nil, URLResponse(), nil) + + return nil + } + } + + let downloader = URLDownloader(session: CustomNetworkSession()) + + do { + try downloader.downloadSynchronously(with: urlRequest, to: downloadURL, timeout: defaultTimeout) + } catch URLDownloader.DownloadError.responseNotHTTPResponse { + // Expected response + } catch { + XCTFail("Unexpected error received: \(error)") + } + } + + func testDownloader_withCorrectResponse_shouldNotThrow() { + let statusCode = 200 + let responseString = "Success!" + let downloadURL = CodegenTestHelper.outputFolderURL().appendingPathComponent("urldownloader.txt") + + setRequestHandler(statusCode: statusCode, data: responseString.data(using: .utf8)) + + do { + try downloader.downloadSynchronously(with: urlRequest, to: downloadURL, timeout: defaultTimeout) + } catch { + XCTFail("Unexpected error received: \(error)") + } + + let output = try? String(contentsOf: downloadURL) + XCTAssertEqual(output, responseString) + } +} diff --git a/Tests/ApolloPerformanceTests/Responses/IssuesAndCommentsForRepository.json b/Tests/ApolloPerformanceTests/Responses/IssuesAndCommentsForRepository.json index 42d54f38a0..1d4ee36aeb 100644 --- a/Tests/ApolloPerformanceTests/Responses/IssuesAndCommentsForRepository.json +++ b/Tests/ApolloPerformanceTests/Responses/IssuesAndCommentsForRepository.json @@ -1 +1 @@ -{"data":{"repository":{"__typename":"Repository","name":"apollo-ios","issues":{"__typename":"IssueConnection","nodes":[{"__typename":"Issue","title":"Xcode 12 Beta Archive issue ","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"},"body":"I failed to archive app with 12.0 beta 2 and I found that other libraries have similar issues.\r\n\r\n- https://github.com/airbnb/lottie-ios/issues/1214\r\n- https://github.com/Alamofire/Alamofire/issues/3240\r\n\r\n# Error message\r\n\r\n```\r\nUndefined symbols for architecture armv7:\r\n \"type metadata for Swift._StringObject.Variant\", referenced from:\r\n outlined init with take of Swift._StringObject.Variant in ApolloStore.o\r\nld: symbol(s) not found for architecture armv7\r\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\r\n```\r\n\r\n# Environment\r\nApollo version: 0.28.0\r\nXcode version: 12.0 beta 2 (12A6163b)\r\nSwift version: 5.3 (swiftlang-1200.0.16.13 clang-1200.0.22.25)\r\nPlatform(s) running Apollo: iOS\r\nmacOS version running Xcode: 10.15.5","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Weird! I'm literally testing the new beta right now, and I was just able to build and test `0.29.1` with Xcode 12 b2 without any problem. Have you cleaned your build folder and/or done the [derived data dance](http://derivedata.dance) recently? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":">Have you cleaned your build folder and/or done the derived data dance recently?\r\n\r\nI've tried it but it hasn't helped...\r\n\r\nCould you try setting the build configuration to release? ~~It seems that the optimization level is related.~~ Or try archive.","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"}},{"__typename":"IssueComment","body":"Can't really do archive on a framework, but can confirm this is showing up if I switch the Run action to build for release. \r\n\r\nIt looks like the issue is [some kind of bug with substrings in the beta](https://developer.apple.com/forums/thread/649918?answerId=614735022#614735022). Unfortunately because we support older versions of iOS, disabling armv7 support in the library isn't really a good option for us. \r\n\r\nIt also looks like the workaround for our library isn't as simple as [Lottie's](https://github.com/airbnb/lottie-ios/pull/1215) - we're not using `prefix` and `suffix` methods on `String` anywhere in the main `Apollo` lib, and I'm getting an error on compilation in release mode with a totally different file than you are (`GraphQLResultNormalizer.o`) that's not doing any super-obvious string manipulation. \r\n\r\nIf you have some time to dig around, I'd encourage you to. At this point I've got enough on my plate that something clearly acknowledged by Apple as a bug and which only affects release builds on a beta Xcode is not going to be something I prioritize digging into on my own. Will definitely check back in on this with subsequent beta releases though. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"https://github.com/zhangao0086/DKImagePickerController/issues/669","author":{"__typename":"User","login":"OmarJalil","id":"MDQ6VXNlcjI1NTIwMDE1","name":"Jalil"}},{"__typename":"IssueComment","body":"@designatednerd Thank you for your research. I want to wait for this bug to be fixed in a future Xcode version.","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"}},{"__typename":"IssueComment","body":"I am experiencing this issue as well, which prevented Carthage from building Apollo. I mentioned the issue in the Xcode 12 thread: https://github.com/apollographql/apollo-ios/pull/1280\r\n\r\nI fixed the issue here: https://github.com/danl3v/apollo-ios/tree/0.29.1-xcode12 and it works fine. Feel free to cherry-pick the latest commit to another version of apollo as required. Hopefully Apple will fix its substring issue","author":{"__typename":"User","login":"danl3v","id":"MDQ6VXNlcjg4MzE4OA==","name":"Daniel Levy"}},{"__typename":"IssueComment","body":"Xcode 12 beta 3 just came out, and I am now no longer able to reproduce this by switching the run action to build for release. \r\n\r\n@danl3v @nkmrh Can you please confirm that this is no longer an issue on the `betas/xcode-12` branch for you? Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Will do early next week","author":{"__typename":"User","login":"danl3v","id":"MDQ6VXNlcjg4MzE4OA==","name":"Daniel Levy"}},{"__typename":"IssueComment","body":"@designatednerd @danl3v I confirmed the issue on the `betas/xcode-12 ` branch with Xcode 12.0 beta 3. Unfortunately the one reproduced :(","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"}},{"__typename":"IssueComment","body":"@nkmrh Weird! Did you do `Clean Build Folder` before trying to archive? I double-checked that I'd done that before trying to do the run action as build for release and it still worked. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I checked the betas/xcode-12 branch again and the build was successful but when I add it to a simple project with cocoapods, it still fails to build... (archive is still failing)","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"}},{"__typename":"IssueComment","body":"Interesting....I'll poke at that today. Thanks!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I tried it with Xcode 12 beta 4, it solved!","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"}},{"__typename":"IssueComment","body":"Excellent! I'm going to close this issue out then - if anyone has issues archiving on Beta 4 or after, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Beta 4 works for us!","author":{"__typename":"User","login":"danl3v","id":"MDQ6VXNlcjg4MzE4OA==","name":"Daniel Levy"}}]}},{"__typename":"Issue","title":"[Web] - Installation panel doesn't expand content","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"},"body":"![image](https://user-images.githubusercontent.com/7384288/86875928-2ad0f500-c116-11ea-8d1f-804f25c74d0f.png)\r\n\r\nClicking the Installation panel doesn't show the content.\r\n\r\nChrome 83.0.4103.116 64-bit","comments":{"__typename":"IssueCommentConnection","nodes":[]}},{"__typename":"Issue","title":"[Web] - Installation panel doesn't expand content","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"},"body":"![image](https://user-images.githubusercontent.com/7384288/86875928-2ad0f500-c116-11ea-8d1f-804f25c74d0f.png)\r\n\r\nClicking the Installation panel doesn't show the content.\r\n\r\nChrome 83.0.4103.116 64-bit","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Oops! I'll let our docs team know, thank you for the heads up!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Fixed by https://github.com/apollographql/apollo-ios/pull/1306\r\n\r\nCheck it out here: https://www.apollographql.com/docs/ios/installation/","author":{"__typename":"User","login":"trevorblades","id":"MDQ6VXNlcjEyMTY5MTc=","name":"Trevor Blades"}},{"__typename":"IssueComment","body":"Thanks @trevorblades, you rock!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"通过 CocoaPods 导入 Apollo 丢失 WebSocket","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null},"body":"通过 CocoaPods 导入 Apollo 丢失 WebSocket\r\nPodfile 文件中添加 pod 'Apollo', '~> 0.29.0' 执行pod install 完成后 在工程 Pods 中 只有 Apollo/Core 文件 无法找到 Apollo/WebSocket \r\n引用 import ApolloWebSocket 报错 \" No such module 'ApolloWebSocket' \"\r\n\r\n如下图:\r\nPodfile文件:\r\n\"WeChatf75880a9f15d2f78d3d97ec0cd4bc4d9\"\r\n\r\npod search Apollo\r\n\"pod_search_apollo\"\r\n\r\npod install 完成后\r\n\"pod_install\"\r\n\r\n使用代码\r\n\"code\"\r\n\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Google translated:\r\n\r\n> Importing Apollo via CocoaPods loses WebSocket\r\n> Add pod'Apollo' in the Podfile file,'~> 0.29.0' After executing pod install, only Apollo/Core files cannot be found in the project Pods.\r\n> Quoting import ApolloWebSocket reports error \"No such module'ApolloWebSocket'\"\r\n>\r\n> As shown below:\r\n> Podfile\r\n\r\nYou need to add the `Apollo/WebSocket` subspec in order to access the WebSocket library - it is not included by default, only the core libraries are included by default. So your podfile should look like this if you want to use the web socket library: \r\n\r\n```\r\npod 'Apollo', '~>0.29.0'\r\npod 'Apollo/WebSocket', '~>0.29.0'\r\n```","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"ok","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null}}]}},{"__typename":"Issue","title":"Figure out how to test cache key generation with JSON objects","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"},"body":"#1281 addresses an issue where cache keys were being unstably generated when one of the items was a JSON array. I haven't been able to find an API that takes JSON arrays, so we need to find an alternate method of testing key generation for this. Don't want to hold up an actual fix for the issue until I can figure this out, so making this issue to come back to it.","comments":{"__typename":"IssueCommentConnection","nodes":[]}},{"__typename":"Issue","title":"Fatal error (\"Optional is only JSONEncodable if Wrapped is\") when trying to update SqlNormalizedCache manually after a successful mutation operation","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"},"body":"While using Apollo iOS 0.29.1, I appear to be running into an issue similar to the one reported [here](https://github.com/apollographql/apollo-ios/issues/1271). I asked for help with this issue in [Spectrum](https://spectrum.chat/apollo/apollo-ios/updating-cache-after-insert-mutation~71008cf0-6ccf-4474-95bb-ac22c83e9616), and @designatednerd asked me to create a new issue.\r\n\r\nI'm trying to update the SqlNormalizedCache (which is setup and working properly) using the result of a successful mutation operation:\r\n\r\n```\r\napollo.perform(mutation: InsertTaskResponseMutation(taskId: 1, response: \"\")) { result in\r\n guard\r\n let resultData = try? result.get().data,\r\n let taskResponseDetails = resultData.insertTaskResponses?.returning.first?.fragments.taskResponseDetails\r\n else {\r\n return\r\n }\r\n\r\n apollo.store.withinReadWriteTransaction({ transaction in\r\n try! transaction.write(object: taskResponseDetails, withKey: \"task_responses-\\(taskResponseDetails.id)\")\r\n })\r\n}\r\n```\r\n\r\nThis is throwing a fatal error in \"JSONStandardTypeConversions.swift\" at line 109:\r\n\r\n\"Screen\r\n\r\nPrinting the description of `self`:\r\n\r\n```\r\nPrinting description of self:\r\n▿ Optional\r\n - some : 07/08/2020\r\n```\r\n\r\nIn this case, `self` is a property on the `response` property, which is a custom `jsonb` type. Here's the type alias:\r\n\r\n```\r\npublic typealias jsonb = [String : Any?]\r\n\r\nextension Dictionary: JSONDecodable {\r\n public init(jsonValue value: JSONValue) throws {\r\n guard let dictionary = value as? Dictionary else {\r\n throw JSONDecodingError.couldNotConvert(value: value, to: Dictionary.self)\r\n }\r\n \r\n self = dictionary\r\n }\r\n}\r\n```\r\n\r\nAnd here's the query:\r\n\r\n```\r\nquery ChallengeTaskResponse($taskResponseId: Int) {\r\n challenge_responses(where: {id: {_eq: $taskResponseId}}) {\r\n ...ChallengeTaskResponseDetails\r\n }\r\n}\r\n```\r\n\r\nThe mutation:\r\n\r\n```\r\nmutation InsertTaskResponse($response: jsonb) {\r\n insert_task_responses(objects: {response: $response}) {\r\n returning {\r\n ...TaskResponseDetails\r\n }\r\n }\r\n}\r\n```\r\n\r\nAnd, finally, the fragment that's used by both the query and the mutation:\r\n\r\n```\r\nfragment TaskResponseDetails on task_responses {\r\n id\r\n response // The 'jsonb' custom data type\r\n}\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"The problem definitely seems to be in the fact that the value type in the dictionary is `Optional`, and that's what it's trying to use to create a key. \r\n\r\nDoes it work to typealias it to `[String: JSONDecodable?]` instead?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'll test that here shortly and report back.","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"@nateirwin Were you ever able to get this tested out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd: I started to dive into this, ran into a minor issue (that's project-specific and I just need to push through), then got pulled into another issue altogether. This is still critical for our project and it's next on my list, so I'll get to it soon.\r\n\r\nI'm happy to close this and re-open when I've had the chance to test, if that's helpful.","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Nah, leave it open for now, I'll keep annoying you about it from time to time 😇","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Ok, reporting back :-)\r\n\r\nSwitching the typealias to `public typealias jsonb = [String : JSONDecodable?]` throws an error when loading a query that has a `jsonb` property on it:\r\n\r\n```\r\nPrinting description of error:\r\n▿ GraphQLResultError\r\n ▿ path : communities.0.organization_community_memberships.1.organization.paper_maps.0.paper_map.status\r\n ▿ head : Optional\r\n ▿ some : \r\n ▿ underlying : JSONDecodingError\r\n ▿ couldNotConvert : 2 elements\r\n ▿ value : 24 elements\r\n ▿ 0 : 2 elements\r\n - key : status\r\n - value : Uploading tiles complete\r\n ▿ 1 : 2 elements\r\n - key : min_zoom\r\n - value : 9\r\n ▿ 2 : 2 elements\r\n - key : extent_max_lon\r\n - value : -100.1\r\n ▿ 3 : 2 elements\r\n - key : extent_min_lat\r\n - value : 37.1\r\n ▿ 4 : 2 elements\r\n - key : tileset\r\n - value : tileset_548\r\n ▿ 5 : 2 elements\r\n - key : pdfPath\r\n - value : https://test.xyz/test.pdf\r\n ▿ 6 : 2 elements\r\n - key : updated_at\r\n - value : 2019-07-29T15:04:09.623Z\r\n ▿ 7 : 2 elements\r\n - key : extent_max_lat\r\n - value : 34.1\r\n ▿ 8 : 2 elements\r\n - key : localTilesPath\r\n - value : https://test.xyz/tiles/\r\n ▿ 9 : 2 elements\r\n - key : geotiff_path\r\n - value : /image_georef.tif\r\n ▿ 10 : 2 elements\r\n - key : geotiff_3857_path\r\n - value : /image_georef_3857.tif\r\n ▿ 11 : 2 elements\r\n - key : name\r\n - value : Name Here\r\n ▿ 12 : 2 elements\r\n - key : max_zoom\r\n - value : 15\r\n ▿ 13 : 2 elements\r\n - key : id\r\n - value : 548\r\n ▿ 14 : 2 elements\r\n - key : temp_georefTilesPath\r\n - value : \r\n - super : NSObject\r\n ▿ 15 : 2 elements\r\n - key : ground_control_points\r\n - value : [[1071.640625,2925.1640625,-122.104733996093,37.714753539402],[1355.44921875,2053.29296875,-122.09752430208,37.7391649876836],[1192.0390625,1299.8125,-122.105021746829,37.7592430319794],[669.765625,594.1796875,-122.124813348055,37.7770496273366]]\r\n ▿ 16 : 2 elements\r\n - key : png_path\r\n - value : /final.png\r\n ▿ 17 : 2 elements\r\n - key : page_number\r\n - value : { ... }\r\n ▿ 18 : 2 elements\r\n - key : image_width\r\n - value : 2550\r\n ▿ 19 : 2 elements\r\n - key : created_at\r\n - value : 2019-07-29T14:57:07.796Z\r\n ▿ 20 : 2 elements\r\n - key : georefTilesPath\r\n - value : https://test.xyz/tiles_georef\r\n ▿ 21 : 2 elements\r\n - key : image_height\r\n - value : 3300\r\n ▿ 22 : 2 elements\r\n - key : extent_min_lon\r\n - value : -115.1\r\n ▿ 23 : 2 elements\r\n - key : file_type\r\n - value : pdf\r\n - to : Swift.Dictionary>\r\n```\r\n\r\nI'm guessing maybe it's bonking on the `null` values? Honestly, we've run into so many issues with this custom `jsonb` scalar type that I'm considering trying to back out of using it altogether.","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Hm, shouldn't be bonking on nulls, we've got something that [theoretically should be handling that](https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/JSONStandardTypeConversions.swift#L89). From the underlying error it looks like it's freaking out about the `status` key which is just a String. \r\n\r\nI think a bigger question this brings up is why this data needs to be returned as an arbitrary JSON blob in the first place - why isn't this data returned as something typed? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Well, `status` is the name of the `jsonb` property, which (I think) should be of type `[String: JSONDecodable?]` because of the type alias:\r\n\r\n```\r\npublic typealias jsonb = [String : JSONDecodable?]\r\n\r\nextension Dictionary: JSONDecodable {\r\n public init(jsonValue value: JSONValue) throws {\r\n guard let dictionary = value as? Dictionary else {\r\n throw JSONDecodingError.couldNotConvert(value: value, to: Dictionary.self)\r\n }\r\n \r\n self = dictionary\r\n }\r\n}\r\n```\r\n\r\nThat's why I'm scratching my head about this. Maybe my next step is setting some more breakpoints in JSONStandardTypeConversions.swift?","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Looking at the JSON, `status` seems to be a key and value of the dictionary which isn't getting deserialized - can you throw in a breakpoint and print out the raw JSON string (or use a proxying tool to see it) that's coming through? That might help.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Sure, here you go (sorry about the delay):\r\n\r\n```\r\n{\r\n \"data\": {\r\n \"communities\": [\r\n {\r\n \"organization_community_memberships\": [\r\n {\r\n \"id\": 467,\r\n \"organization\": {\r\n \"paper_maps\": [\r\n {\r\n \"id\": 557,\r\n \"paper_map\": {\r\n \"description\": \"null\",\r\n \"id\": 322,\r\n \"name\": \"Name Here\",\r\n \"status\": {\r\n \"id\": 548,\r\n \"name\": \"Name Here\",\r\n \"status\": \"Uploading tiles complete\",\r\n \"pdfPath\": \"https://test.xyz/test.pdf\",\r\n \"max_zoom\": 15,\r\n \"min_zoom\": 9,\r\n \"png_path\": \"/final.png\",\r\n \"file_type\": \"pdf\",\r\n \"created_at\": \"2019-07-29T14:57:07.796Z\",\r\n \"updated_at\": \"2019-07-29T15:04:09.623Z\",\r\n \"image_width\": 2550,\r\n \"page_number\": null,\r\n \"geotiff_path\": \"/image_georef.tif\",\r\n \"image_height\": 3300,\r\n \"extent_max_lat\": \"34.1\",\r\n \"extent_max_lon\": \"-100.1\",\r\n \"extent_min_lat\": \"37.1\",\r\n \"extent_min_lon\": \"-115.1\",\r\n \"localTilesPath\": \"https://test.xyz/tiles/\",\r\n \"mapbox_tileset\": \"trailheadlabs.paper_map_548\",\r\n \"georefTilesPath\": \"https://test.xyz/tiles_georef\",\r\n \"geotiff_3857_path\": \"/image_georef_3857.tif\",\r\n \"temp_georefTilesPath\": null,\r\n \"ground_control_points\": \"[[1071.640625,2925.1640625,-122.104733996093,37.714753539402],[1355.44921875,2053.29296875,-122.09752430208,37.7391649876836],[1192.0390625,1299.8125,-122.105021746829,37.7592430319794],[669.765625,594.1796875,-122.124813348055,37.7770496273366]]\"\r\n }\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n }\r\n ]\r\n }\r\n}\r\n```","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Ah, ok, `status` is _also_ the name of the property of the dictionary, not just one of the things in the dictionary. \r\n\r\nOne thing it didn't occur to me to ask: Is your `Dictionary` initializer getting hit at all? I wonder if it may need to be constrained to the key and value types you're using","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"It is getting hit, and it's throwing when that same `status` property that holds the dictionary.","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Here's a thought - have you got an extension that implements `JSONEncodable`? It looks like you're only implementing `JSONDecodable` above","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hmm, this is what I get when I start to implement `JSONEncodable`:\r\n\r\n\"Screen","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Aha, [that is indeed implemented in the library](https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/JSONStandardTypeConversions.swift#L114). \r\n\r\nOK, I'll mess around with this some to try and figure out what's going on here. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks for your help!","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"@nateirwin please try pulling the branch #1317 is opened from and seeing if that fixes your issue. You can put the `typealias` back to `[String: Any?]`. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yep, that fixes the issue!!!","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"This has shipped with `0.30.0` - ready to go for SPM and Carthage, in the process of pushing to trunk on Cocoapods. 🎉","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"More generalized types","author":{"__typename":"User","login":"TimBroddin","id":"MDQ6VXNlcjUyODI4Nw==","name":"Tim Broddin"},"body":"Hi,\r\n\r\nI'm kinda new to Apollo iOS, so sorry if my question is kinda stupid. I'm passing a lot of data around in my (SwiftUI) app and the typing kinda drives me crazy. Right now I'm accepting arguments with types like `LetterPartsQuery.Data.ArtistsSplittedInLetterPart.Artist` & `HomePageQuery.Data.Post.Artist` and it's becoming harder and harder to manage this. \r\n\r\nWhat's the quickest way to having easier types to juggle arround (like just `Artist` in my example above).\r\n\r\nThanks a lot!","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I'm a firm believer in \"There's no such thing as a stupid question, only an asshole answer.\" 😇 That said, this is definitely NOT a stupid question. \r\n\r\nOne thing that helps explain the way we generate this code is that for each operation, we only want to make available those properties and types that you've actually requested, rather than all possible properties and types. This means we have some fairly nested structures like the ones you're seeing. \r\n\r\nOne work around for this is to use [GraphQL fragments](https://graphql.org/learn/queries/#fragments). Our codegen will take anyplace that uses a fragment and generate a fragment type that can be reused across multiple operations. \r\n\r\nThey're still more annoying to use than I'd like (this is something I'm working on in Swift Codegen, but that's slightly blocked at the moment), but they are at least the same reusable type. \r\n\r\nDoes that help? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks a lot! This will make my code readable again 😄 ","author":{"__typename":"User","login":"TimBroddin","id":"MDQ6VXNlcjUyODI4Nw==","name":"Tim Broddin"}}]}},{"__typename":"Issue","title":"Serialize or recreate mutation","author":{"__typename":"User","login":"pggawlowski","id":"MDQ6VXNlcjY0OTY2OTU2","name":null},"body":"What I am trying to achieve is mutation archivization. \r\nMy first try was NSKeyedArchiver.archivedData, however currently it is impossible. \r\nSo I decided to try to serialize and store jsonObject and/or variables and later, when back online, recreate mutation query.\r\n\r\n```\r\nlet object = mutation.variables?.jsonObject ?? [:]\r\ndo {\r\n let recreatedMutation = try TestMutation.Data(jsonObject: object, variables: nil)\r\n} catch {\r\n print(error)\r\n}\r\n```\r\n\r\nHowever it results in `Apollo.JSONDecodingError.missingValue`\r\n\r\nAny suggestions how to serialize and store mutations/queries or recreate them from stored data.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It'd probably help for me to understand the use case - why do you need to persist the mutation itself?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"We have to deal with cache sync. So one concept is to introduce some kind of mutations persistency. Currently we are successfully mutating cache but we also have to push it away when connection is restored.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"I think I'm a bit confused - are you talking about persisting the **result** of a mutation, or the mutation itself? \r\n\r\nWhat I think is happening is that you're trying to persist the mutation itself so you can push changes you've made locally up to a server. Is that correct? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Exactly! :) ","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"So part of the problem is that you're trying to use the nested `TestMutation.Data` type - that type is used for recreating the **result** of the mutation, not the mutation itself. \r\n\r\nYou basically have to create the mutation the same way you would have if you weren't making it locally. So if your generated initializer is `TestMutation(parameter: String)`, then you want to persist the value of `parameter` and then send that mutation again. \r\n\r\nWhat you're trying to do is persist the variables JSON object, but there isn't an initializer for queries that takes that JSON object that you can pass what you're saving directly to. You could probably make a throwing initializer (in another file so it doesn't get overwritten by codegen) for the mutation that pulls that JSON back out, then tries to make the appropriate query from the JSON. \r\n\r\nYou'd have to have some notion of what query the JSON was for, though - it might be better to have some custom `Codable` types that can persist information about both the query type and the parameter values you need to persist. \r\n\r\nThere is definitely not a built-in way to do this, though. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@pgawlowski Anything else I can help with here? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"It's fine. Thank you very much! ","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"Cool - I'm going to close this issue out then. Thanks!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"How Can I set authorisation header for Apollo Client?","author":{"__typename":"User","login":"Prathap-iOS","id":"MDQ6VXNlcjU4Mzk2NTI2","name":"Prathap Reddy"},"body":"I am using Apollo Client. I got the access token after login. I have set the access token as authorisation header like this.\r\n\r\nfunc setApolloClient(accessToken: String) {\r\n self.apolloClient = {\r\n let authPayloads = [\"Authorization\": \"Bearer \\(accessToken)\"]\r\n let configuration = URLSessionConfiguration.default\r\n configuration.httpAdditionalHeaders = authPayloads\r\n configuration.requestCachePolicy = .reloadIgnoringLocalCacheData\r\n let endpointURL = URL(string: graphEndpoint)!\r\n return ApolloClient(networkTransport: HTTPNetworkTransport(url: endpointURL))\r\n }()\r\n }\r\n\r\nI am sending this authorisation header to a query to get the user details. It return success. But, I have no idea where it went wrong. I am not getting user details. I am getting Try again later. @designatednerd Is there any other way to set authorisation header?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I suspect \r\n\r\n```swift\r\nlet authPayloads = [\"Authorization\": \"Bearer (accessToken)\"]\r\n``` \r\n\r\nshould be \r\n\r\n```swift\r\nlet authPayloads = [\"Authorization\": \"Bearer \\(accessToken)\"]`\r\n```\r\n\r\nOtherwise you're sending the literal string `(accessToken)` as your access token rather than using string interpolation, which looks like what you want to do. \r\n\r\nIf that's not the issue, let me know and I can dig deeper - other than that your setup seems pretty straightforward. \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I used let authPayloads = [\"Authorization\": \"Bearer \\ (accessToken)\"]. But this one also not working.","author":{"__typename":"User","login":"Prathap-iOS","id":"MDQ6VXNlcjU4Mzk2NTI2","name":"Prathap Reddy"}},{"__typename":"IssueComment","body":"You still need the `\\` before the first paren in `(accessToken)`, otherwise it'll be sent as a string literal. \r\n\r\nAre you able to use a proxy tool like [Charles](https://www.charlesproxy.com/) or [MiTM Proxy](https://mitmproxy.org/) to see what the final headers going out over the network are? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yeah I used \\ before (accessToken). But There is no proper result. I am not using any proxies.","author":{"__typename":"User","login":"Prathap-iOS","id":"MDQ6VXNlcjU4Mzk2NTI2","name":"Prathap Reddy"}},{"__typename":"IssueComment","body":"I was asking if you could try using a proxy to see if you can see what the final headers are - that way you can see exactly what's going over the network. \r\n\r\nI would also double check with your backend that they take the token as a `Bearer` token - that's standard practice, but I've definitely seen a lot of backends that don't adhere to that.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd my backend team is following the same standard. They taken token as **Bearer** token.","author":{"__typename":"User","login":"Prathap-iOS","id":"MDQ6VXNlcjU4Mzk2NTI2","name":"Prathap Reddy"}},{"__typename":"IssueComment","body":"OK I was double checking what you're doing, and I missed the most obvious thing: The `URLSessionConfiguration` is not being passed into anything, so the configuration you're correctly setting up is not being given to anything to be used. Instead of this at the very end: \r\n\r\n```swift\r\nreturn ApolloClient(networkTransport: HTTPNetworkTransport(url: endpointURL))\r\n```\r\n\r\ntry this: \r\n\r\n```swift\r\nlet client = URLSessionClient(sessionConfiguration: configuration)\r\nreturn ApolloClient(networkTransport: HTTPNetworkTransport(url: endpointURL), client: client)\r\n```","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd Thanks. It's working fine. \r\n\r\nHere is my working code for setting up authorization header.\r\n\r\n`func getApolloClient(headerRequired:Bool = true) -> ApolloClient {\r\n let tokenValue = SessionManager.shared.getToken().TokenValue\r\n let authPayloads = [\"Authorization\": \"Bearer \\(tokenValue)\"]\r\n let configuration = URLSessionConfiguration.default\r\n configuration.httpAdditionalHeaders = authPayloads\r\n configuration.requestCachePolicy = .reloadIgnoringLocalCacheData\r\n let client = URLSessionClient(sessionConfiguration: configuration)\r\n let endpointURL = URL(string: graphEndpoint)!\r\n return ApolloClient(networkTransport: HTTPNetworkTransport(url: endpointURL, client: client))\r\n }`","author":{"__typename":"User","login":"Prathap-iOS","id":"MDQ6VXNlcjU4Mzk2NTI2","name":"Prathap Reddy"}},{"__typename":"IssueComment","body":"@Prathap-iOS great! Mind if we close this out?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since @Prathap-iOS has noted that solution works, I'm going to go ahead and close this out. If you're having a similar problem, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"How to use the --passthrough-custom-scalar flag","author":{"__typename":"User","login":"ijl0322","id":"MDQ6VXNlcjE1OTAxNTMx","name":"Isabel Lee"},"body":"Hi, \r\n\r\nI'm trying to use the --passthrough-custom-scalar flag:\r\n\r\n`\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --passthrough-custom-scalar --localSchemaFile=\"schema.json\" API.swift`\r\n\r\nAnd getting this error `Error: Unexpected argument: API.swift`\r\n\r\nI'm using Apollo 0.29.1 and Xcode 11.5. Any help would be appreciated, Thanks!\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It's `--passthroughCustomScalars`, Pascal case instead of kebab case and plural instead of singular. I think that may be causing the parsing to fail.\r\n\r\nIf fixing that doesn't fix it, I'd switch it to after `--localSchemaFile` - that might be looking for multiple arguments but I can't remember off the top of my head. \r\n\r\nLet me know which one (or both) works!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"The Pascal case works !! Thank you so much for your help! ","author":{"__typename":"User","login":"ijl0322","id":"MDQ6VXNlcjE1OTAxNTMx","name":"Isabel Lee"}}]}},{"__typename":"Issue","title":" Getting 'No operations found to generate` error when trying to use `ID` in query","author":{"__typename":"User","login":"dpatel-git","id":"MDQ6VXNlcjY4NDM2NTk1","name":null},"body":"I am working on an iOS application to communicate with our GraphQL backend using Apollo's GraphQL library. With the query below, I am able to generate Swift code that I can use to query backend.\r\n\r\n`query mobileApp {\r\n app(id: \"content/mobileApp\") {\r\n title\r\n } \r\n}`\r\n\r\nI am using the following commands to generate Swift code\r\n\r\n`../../Pods/Apollo/scripts/apollo/bin/run client:codegen --target=swift --includes ../app.graphql --localSchemaFile=./downloaded_schema.json API.swift`\r\n\r\nHowever, if I replace the string literal passed into the app(...) with ID like this\r\n\r\n`query mobileApp {\r\n app(id: ID!) {\r\n title\r\n } \r\n}`\r\n\r\nrunning the same codegen command fails with the following error.\r\n\r\n`Generating query files with 'swift' target\r\n → No operations or fragments found to generate code for.\r\nError: No operations or fragments found to generate code for.\r\n at write (~/Downloads/ios-app/Pods/Apollo/scripts/apollo/lib/commands/client/codegen.js:65:39)\r\n at Task.task (~/Downloads/ios-app/Pods/Apollo/scripts/apollo/lib/commands/client/codegen.js:90:46)`\r\n\r\nIt seems that the script is not able to find a declaration of ID. Hoping that someone can point me in the right direction, thanks","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I'm not sure why it's saying there are no operations rather than there's an error in your declaration, but there's an error in your declaration. \r\n\r\nTo pass in a parameter, you need to declare that parameter in the query's declaration, then pass it into the query itself: \r\n\r\n```graphql\r\nquery mobileApp($id: ID!) { \r\n app(id: $id) {\r\n title\r\n }\r\n}\r\n```\r\n\r\nHope that gets you going!\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I think codegen script could be defaulting to `No Operations ...` error if it's able to come to a conclusion. \r\n\r\nAnyways, making the changes you suggested fixed the error.\r\n\r\nSuper thanks.","author":{"__typename":"User","login":"dpatel-git","id":"MDQ6VXNlcjY4NDM2NTk1","name":null}}]}},{"__typename":"Issue","title":"Fragments imported into multiple graphql queries","author":{"__typename":"User","login":"piv199","id":"MDQ6VXNlcjgyOTMxOTE=","name":"Olexii Pyvovarov"},"body":"Hi, quite new to graphql and trying to establish best practices in the project.\r\n\r\nHave found an article about fragments: https://www.apollographql.com/docs/ios/fragments/\r\n\r\nI wonder whether there is an ability to import Fragment.graphql (which defines fragment only) into another graphql file with query that uses that fragment?\r\n\r\n```\r\nFragment.graphql\r\nfragment A { }\r\n```\r\n\r\n```\r\nQuery.grapqhl\r\nquery {\r\n property {\r\n ...A\r\n }\r\n}\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Yep, as long as they're in the same module you should be able to do that!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"(you won't need to import fragment.graphql, the codegen should be able to see all fragments defined in the module)","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd Thanks! Sorry for opening the issue... I did all right but the problem was in fragment naming - it was the same as model entity thus I had segmentation fault and not found errors... Thanks for help!\r\n","author":{"__typename":"User","login":"piv199","id":"MDQ6VXNlcjgyOTMxOTE=","name":"Olexii Pyvovarov"}}]}},{"__typename":"Issue","title":"Keys with nil values are removed","author":{"__typename":"User","login":"docallag","id":"MDQ6VXNlcjM1MzIzMQ==","name":"David O'Callaghan"},"body":"Hi,\r\nI'm just wondering why keys with nil values are removed on queries/mutations? \r\n\r\nSpecifically the **withNilValuesRemoved** extension method in **GraphQLInputValue.swift**\r\n\r\nThanks,\r\nDave","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Good question! So you can see a little bit of why in [this test](https://github.com/apollographql/apollo-ios/blob/main/Tests/ApolloTests/InputValueEncodingTests.swift#L74) and [this test](https://github.com/apollographql/apollo-ios/blob/main/Tests/ApolloTests/InputValueEncodingTests.swift#L80). \r\n\r\nFor input values, passing `nil` and passing `.some(nil)` have different meanings. Passing `nil` means \"I am not providing a value here.\" Passing `.some(nil)` means \"I am providing a value, and it is explicitly nil.\" The `nil`s are filtered out, the `.some(nil)`s are not.\r\n\r\nThis has effects on the server side: If you send `null` to the server, it will overwrite whatever was already in your server-side database with `null`. If you don't send anything to the server, anything which was already there and isn't explicitly being changed will remain untouched. \r\n\r\nIn the swift Codegen stuff I'm working on there's going to be a [`GraphQLOptional`](https://github.com/apollographql/apollo-ios/blob/main/Sources/ApolloCore/GraphQLOptional.swift#L3) type that should capture this a bit more clearly than the current codegen, but unfortunately that's still a ways out (😭). \r\n\r\nDoes that make more sense? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Oh that's perfect! I can use `.some(nil)` to stop it being filtered out.\r\n\r\nThanks so much for the quick reply 🤩","author":{"__typename":"User","login":"docallag","id":"MDQ6VXNlcjM1MzIzMQ==","name":"David O'Callaghan"}}]}},{"__typename":"Issue","title":"Does every table need an \"id\" or \"","author":{"__typename":"User","login":"joshuarobs","id":"MDQ6VXNlcjUyOTQ2ODgx","name":null},"body":"","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"(closing this in favor of #1326)","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Does every table need an \"id\" or \"_id\" field for its data to be cached properly?","author":{"__typename":"User","login":"joshuarobs","id":"MDQ6VXNlcjUyOTQ2ODgx","name":null},"body":"According to Apollo Client React here: https://www.apollographql.com/docs/react/caching/cache-configuration/#generating-unique-identifiers the way data is identified and if any changes have been made is as described:\r\n\r\n````\r\nTo do so, it combines the object's __typename with its id or _id field (whichever is defined).\r\nThese two values are separated by a colon (:).\r\n````\r\n\r\nThere seems to be an option for React where a different field other than `id` can be used, especially if there is another field set as the primary key on the db.\r\n\r\nIs there a way to do this for Apollo iOS? If not, does that mean we have to make all tables in our database have some sort of `id` or `_id` field?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! This is handled rather differently on iOS at the moment. Here's [a detailed doc about our caching on iOS](https://www.apollographql.com/docs/ios/caching/). \r\n\r\nThe short answer of how to set a custom key is to take a look at the [Controlling Normalization section](https://www.apollographql.com/docs/ios/caching/#controlling-normalization), where you can find information about the `cacheKeyForObject` function you can use to set custom cache keys on iOS. \r\n\r\nDoes that answer your question? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes it does, thanks!","author":{"__typename":"User","login":"joshuarobs","id":"MDQ6VXNlcjUyOTQ2ODgx","name":null}},{"__typename":"IssueComment","body":"@designatednerd Also, forgot to ask one more quick question: is `cacheKeyForObject` set only once throughout the whole Apollo object? That is, if we set it to `id`, does that mean every table that ever gets queried needs to have an `id` field? What about if we have most tables with a unique `id` but some tables don't have it and use other primary keys?","author":{"__typename":"User","login":"joshuarobs","id":"MDQ6VXNlcjUyOTQ2ODgx","name":null}},{"__typename":"IssueComment","body":"There is only one closure per store (set through the client), but you can do some stuff by extracting the value of `__typename` from the JSON you get in order to have it work differently for different things. \r\n\r\nYou also can just return `nil` if `id` is nil, and a default cache key based on the path of the request will be generated. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Inline GQL","author":{"__typename":"User","login":"ericlewis","id":"MDQ6VXNlcjY3NDUwMw==","name":"Eric Lewis"},"body":"This might be old hat and I know it’s not a great issue but need to write down somewhere:\r\n\r\nYou should be able to describe fragments or query’s with inline strings as opposed to colocating with graphql files. \r\n\r\nIt probs seems minor but from a DX perspective the whole co-locating things a big deal. \r\n\r\nCreating more folder structure to organize is less good than just having the query in a used component. This is probably more true of SwiftUI than anything, and I have some SwiftUI stuff to contribute if folks want it. ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! There's definitely some significant obstacles to this at the moment, particularly around how things are ingested for code generation. Right now, we only ingest from `.graphql` files rather than from any arbitrary file, and without having to worry about what is a Swift `String` that contains a GraphQL query or anything like that. \r\n\r\nThis is definitely an enhancement to consider for the long term, but I'll be honest, we've got way bigger problems to solve first. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"don't see this happening to be fair, more likely would be some kind of DSL","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"Thats' an interesting idea - I think the main issues I see with it are a) How would we ensure that queries are valid? and b) How would we generate the classes necessary for parsing the result? \r\n\r\nDefinitely going to think on that when I get back to this issue though. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Swift scripting codegen error: \"Error: Cannot find module './errors/pretty-print'\"","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"},"body":"macOS 10.15.6\r\nXcode 11.6\r\n\r\nWe're using Swift scripting for Codegen in our project. It was working fine until recently. The only change that occurred (that I can think of) is macOS and Xcode updated. I'm getting the following error:\r\n\r\n```\r\n[DEBUG - ApolloCodegenLib:CLIDownloader.swift:43] - Zip file with the CLI is already downloaded!\r\nSHASUM of downloaded file: c2b1215eb8e82ec9d777f4b1590ed0f60960a23badadd889e4d129eb08866f14\r\n[DEBUG - ApolloCodegenLib:CLIExtractor.swift:57] - Binary already extracted!\r\n[ERROR - ApolloCodegenLib:Basher.swift:62] - internal/modules/cjs/loader.js:638\r\n throw err;\r\n ^\r\n\r\nError: Cannot find module './errors/pretty-print'\r\n at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)\r\n at Function.Module._load (internal/modules/cjs/loader.js:562:25)\r\n at Module.require (internal/modules/cjs/loader.js:692:17)\r\n at require (internal/modules/cjs/helpers.js:25:18)\r\n at Object. (/Users/nateirwin/Development/trailheadlabs/outerspatial-ios/Codegen/ApolloCLI/apollo/node_modules/@oclif/errors/lib/handle.js:6:24)\r\n at Module._compile (internal/modules/cjs/loader.js:778:30)\r\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)\r\n at Module.load (internal/modules/cjs/loader.js:653:32)\r\n at tryModuleLoad (internal/modules/cjs/loader.js:593:12)\r\n at Function.Module._load (internal/modules/cjs/loader.js:585:3)\r\n\r\nProgram ended with exit code: 1\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"That's very odd, that shouldn't have changed anything in the path - I did not have any migration issues when I migrated my machine to those versions. \r\n\r\nWhat I'd suggest is deleting the extracted files from the `tar.gz` file and letting it re-extract. I have no idea what could have changed in there, but re-extracting from the zip file is a good way to make sure you've got everything. Let me know if this works.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"That worked, thanks!","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}}]}},{"__typename":"Issue","title":"Apollo 0.29.0 - 0.30.0 failed to build in Travis","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"},"body":"Hi, i have an issue in Travis when build my apps using apollo.\r\n\"Screen\r\nIt's said there is no module `ApolloCore`, but when i run in xcode and archive it using xcode, it went well. No issue arises when using Xcode.\r\n\r\nI tried to downgrade to version `0.28.0` and it works well in Travis. No error occured.\r\nIs there any configuration for Travis to build `Apollo` pod?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! I'm not sure what your build looks like in Travis, but the issue is around a macro that's used by CocoaPods. CocoaPods pulls every sub-spec into a single big library, so we had to add [this macro](https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/Bundle%2BHelpers.swift#L2) to tell the compiler not to try to import the `ApolloCore` module when using CocoaPods. It sounds like that macro is getting properly populated when you build/archive locally. \r\n\r\nWhat's the command you're using to build on Travis? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"This is command from my Travis :\r\n\r\n```\r\nlanguage: swift\r\nosx_image: xcode11.5\r\nxcode_project: Project.xcworkspace\r\n\r\ncache:\r\n - bundler\r\n - cocoapods\r\n\r\nbefore_install:\r\n - gem install bundler\r\n - bundle install\r\n - pod install\r\n\r\njobs:\r\n allow_failures:\r\n - env: code-coverage\r\n include:\r\n - stage: deploy\r\n before_script: curl -sL firebase.tools | upgrade=true bash\r\n script: bundle exec fastlane deploy\r\n after_success: bundle exec fastlane archive\r\n```\r\n\r\nAnd for my fastlane I'm using `Gym` :\r\n```\r\nprivate_lane :ios_build do |options|\r\n scheme = options[:scheme]\r\n export_method = options[:export_method]\r\n output_name = options[:output_name]\r\n key_name = options[:development]\r\n\r\n gym(\r\n workspace: \"Project.xcworkspace\",\r\n scheme: scheme,\r\n configuration: scheme,\r\n silent: true,\r\n clean: true,\r\n suppress_xcode_output: false,\r\n export_method: export_method,\r\n output_name: output_name,\r\n xcargs: \"ARCHIVE=YES\",\r\n skip_profile_detection: true,\r\n codesigning_identity: key_name,\r\n analyze_build_time: true\r\n )\r\n end\r\n```","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"}},{"__typename":"IssueComment","body":"I would maybe look at adding `COCOAPODS=YES` to your `xcargs` via `gym` if nothing else works - i would also check that the configuration that you're passing in to `gym` has that variable set. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I've add `COCOAPOD=YES` to `gym` and it's still fail to build in Travis.\r\n```\r\ngym(\r\n workspace: \"Project.xcworkspace\",\r\n scheme: scheme,\r\n configuration: scheme,\r\n silent: true,\r\n clean: true,\r\n suppress_xcode_output: false,\r\n export_method: export_method,\r\n output_name: output_name,\r\n xcargs: \"ARCHIVE=YES COCOAPODS=YES\",\r\n skip_profile_detection: true,\r\n codesigning_identity: key_name,\r\n analyze_build_time: true\r\n )\r\n```\r\n\r\n","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"}},{"__typename":"IssueComment","body":"IIRC it needs a comma and not a space - what about looking at the configuration you're using - does that have `COCOAPODS=YES` (or 1) set up? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Already add comma in gym `xcargs: \"ARCHIVE=YES, COCOAPODS=YES\"` and in my configuration there is already an argument `COCOAPODS=1`. But it's still give me the same error in travis.\r\n\"Screen\r\n","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"}},{"__typename":"IssueComment","body":"It looks like in the Release scheme there's a space before `COCOAPODS=1` - what happens if you delete that space?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi, we already add several condition in `xcargs` regarding this issue using `COCOAPODS=0`, `COCOAPODS=1` and `COCOAPODS=YES`. but still no luck. any clue @designatednerd ?","author":{"__typename":"User","login":"budioktaviyan","id":"MDQ6VXNlcjIwMzE0OTM=","name":"Budi Oktaviyan"}},{"__typename":"IssueComment","body":"> It looks like in the Release scheme there's a space before `COCOAPODS=1` - what happens if you delete that space?\r\n\r\nThat's not a space, maybe because it's have another config in first line so it's appear like a space.\r\n\"Screen\r\nAnyway for travis build, we use schema `alpha & beta`. And still no luck ","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"}},{"__typename":"IssueComment","body":"Hmmm...I wonder if there's an issue because `$(inherited)` is in there twice. \r\n\r\nHonestly, I'm not sure what to tell you - it's clear that the `#if !COCOAPODS` compile gate isn't working on Travis, but I'm really not sure why. \r\n\r\nIf you run the fastlane script locally, do you see the same errors? That could start to point you in the right direction. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@budioktaviyan @hendyevan Were y'all ever able to figure out what was going on here, or at least get the fastlane script to run locally? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi @designatednerd , I ever run it locally using `fastlane` and got same issue. So basically, we use `gym` action on fastlane to bundle our app. Apart from that, we also trying to build + archive using xcode, and it works!\r\n\r\nIDK why, is it a `fastlane` problem or something else ?","author":{"__typename":"User","login":"budioktaviyan","id":"MDQ6VXNlcjIwMzE0OTM=","name":"Budi Oktaviyan"}},{"__typename":"IssueComment","body":"That indicates there's likely some kind of configuration issue that's being hit by fastlane - the good news is it's a lot easier to debug that when it can be reproduced locally. I would try using some of the tips from [Fastlane's troubleshooting guide](https://docs.fastlane.tools/codesigning/troubleshooting/), particularly the use of the `--verbose` flag that might give you a better indicator of what's going wrong. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@hendyevan Were you able to get the verbose output and see what might be happening? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi @designatednerd, so the issue actually come from fastlane ? What did you expect from `verbose` build ? did you have any clue ?","author":{"__typename":"User","login":"budioktaviyan","id":"MDQ6VXNlcjIwMzE0OTM=","name":"Budi Oktaviyan"}},{"__typename":"IssueComment","body":"Hi, sorry, I was on vacation last week!\r\n\r\nIt seems like Fastlane is using a build configuration that isn't picking up the `COCOAPODS` setting, I was hoping that the `verbose` build would give you more information about what configuration you're using and what settings are set in that configuration. That might help you figure out more info about what you need to pass into Fastlane to get it to use a build configuration that _does_ use the `COCOAPODS` setting. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Were you ever able to figure out what was happening? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi @designatednerd , sorry for slow response. We are still in the middle of project and the deadline is very tight. We will inform you later as soon as possible after we try it in local and using `verbose` as you suggest.","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"}},{"__typename":"IssueComment","body":"Hi @designatednerd,\r\n\r\nSorry for late response. So, we're just running like this ?\r\n```bundle exec fastlane lane --verbose```\r\n\r\nisn't it ?","author":{"__typename":"User","login":"budioktaviyan","id":"MDQ6VXNlcjIwMzE0OTM=","name":"Budi Oktaviyan"}},{"__typename":"IssueComment","body":"I believe so - there's instructions in the troubleshooting guide I linked earlier that are going to be more accurate than anything I can give you. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey all - I'm going to close this out since I haven't heard back in a few weeks. My best recommendation would be to get things building locally with Fastlane since you can get feedback much more easily than you can from Travis itself. I've generally found in the past that once something is building locally with Fastlane, it's much more likely to succeed on any CI platform if you're building using fastlane on that platform. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Adjusting the reconnection behaviour of `WebSocketTransport`","author":{"__typename":"User","login":"ketenshi","id":"MDQ6VXNlcjY4MDY2OTc=","name":"Eugene Kwong"},"body":"Hello!\r\n\r\nI have a similar setup to https://github.com/apollographql/apollo-ios/pull/1224 but with the caveat of requiring the user to login again in some cases. With an invalid `connectingPayload` the server closes the connection immediately, and `WebSocketTransport` will keep retrying. The `connectingPayload` can be updated with the new authentication token after the user logs in again.\r\n\r\nI would like to add in the ability to either prevent `WebSocketTransport` from reconnecting or be able to pause the websocket. \r\n\r\nIf we go the route of adjusting the reconnection behaviour I was thinking of adding something similar to `HTTPNetworkTransportRetryDelegate` but that kind of goes against the idea of passing `reconnect` as part of the initialization. So maybe having a getter/setter might be best.\r\n\r\nHope that I can get some guidance/feedback on this. Thanks!","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Does `closeConnection` on `WebSocketTransport` do what you need it to? That explicitly sets `reconnect.value` to false. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'd like to keep existing `subscriptions` so unfortunately `closeConnection` isn't viable.","author":{"__typename":"User","login":"ketenshi","id":"MDQ6VXNlcjY4MDY2OTc=","name":"Eugene Kwong"}},{"__typename":"IssueComment","body":"So you're thinking more like this: \r\n\r\n```swift\r\n public func pauseWebSocketConnection() {\r\n self.reconnect.value = false\r\n self.websocket.disconnect()\r\n }\r\n \r\n public func resumeWebSocketConnection(autoReconnect: Bool = true) {\r\n self.reconnect.value = autoReconnect\r\n self.websocket.connect()\r\n }\r\n```\r\n\r\nI think that could work with a sufficient documentation warning that if you call `pause` you have to manually call `resume`. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes that's essentially what I want. Thanks for the suggestion, I'll have something in the next few days.","author":{"__typename":"User","login":"ketenshi","id":"MDQ6VXNlcjY4MDY2OTc=","name":"Eugene Kwong"}},{"__typename":"IssueComment","body":"Eh, if that's all you need i'll just do it and throw in a test 😇","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Ok, thank you so much!","author":{"__typename":"User","login":"ketenshi","id":"MDQ6VXNlcjY4MDY2OTc=","name":"Eugene Kwong"}},{"__typename":"IssueComment","body":"> 好的,非常感谢你!\r\n\r\n你好 我想问下 如果 在 APP 进入后台时,手动断开长连接. APP 重新唤起时连接长连接呢","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null}},{"__typename":"IssueComment","body":"This has shipped with `0.31.0`. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Apollo Codegen generates different Operation IDs than Apollo Server","author":{"__typename":"User","login":"Nickersoft","id":"MDQ6VXNlcjIxMDQxMjk=","name":"Tyler Nickerson"},"body":"Hey all,\r\n\r\nTonight I noticed that the operation ID Apollo Codegen creates when generating Swift code for your schema is slightly different than what the Apollo Server expects, causing APQs to fail and throw a `provided sha does not match query` error. \r\n\r\nBasically the SHA that Apollo Codegen creates adds line breaks between each GraphQL operation before it calculates the SHA of the string (seen [here](https://github.com/apollographql/apollo-tooling/blob/8e78c50a21c17a071f7b6890de446b4582e8d04a/packages/apollo-codegen-core/src/compiler/visitors/generateOperationId.ts#L26)). However, when Apollo iOS sends queries to the server, it does so without any line breaks using Swift's `.appending()` method. Then when the server calculates the SHA, due to the lack of line breaks, the operation ID is different and the error is thrown. Strangely enough, however, I noticed the StarWars API actually [manually adds line breaks](https://github.com/apollographql/apollo-ios/blob/06c357b7e98fb7abcddc02ca8aeb96cc8475d263/Sources/StarWarsAPI/API.swift#L1051) in its generated code, which mine doesn't. \r\n\r\nI believe I'm using the latest version of Apollo Codegen and Apollo iOS. I'm happy to patch a fix – it's just a matter of what needs to be changed. I'm afraid touching `apollo-tooling` would affect more repos that might depend on it, so I thought it'd be safer to open an issue here and propose adding the line breaks to the generated Swift.\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Closing, as it looks like the `apollo-tooling` upstream does add a line break during Swift Codegen, but the CLI on my system may be out of date. Will reopen if cannot find a resolution.","author":{"__typename":"User","login":"Nickersoft","id":"MDQ6VXNlcjIxMDQxMjk=","name":"Tyler Nickerson"}},{"__typename":"IssueComment","body":"@Nickersoft I would strongly recommend using the version the SDK downloads - it's set up to make sure you don't have to fight with node and mess with \"which version of the CLI works with which version of the SDK?\". You can check out the most recent version of our [installation docs](https://www.apollographql.com/docs/ios/installation/) or our new [Swift scripting docs](https://www.apollographql.com/docs/ios/swift-scripting/) to see how to set this up. \r\n\r\nI'd also recommend using version `0.29.x` of the iOS SDK - this includes some fixes that ensure the hash that you get from your iOS operation matches what's generated by the CLI, even with Fragments.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd Hey, thanks for the comment despite me opening an issue a little prematurely haha – I didn't realize the Apollo version set in the Codegen `Package.swift` affects the version of the CLI it downloads, and sure enough, I was on 0.28.x when the newline fix was pushed on 0.30.x. Updating it to download the new CLI fixed the problem :) ","author":{"__typename":"User","login":"Nickersoft","id":"MDQ6VXNlcjIxMDQxMjk=","name":"Tyler Nickerson"}},{"__typename":"IssueComment","body":"Yeah you bet - thought it would be helpful for anyone who stumbles across this via google :P","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Cache: Transaction write object results in no change.","author":{"__typename":"User","login":"pggawlowski","id":"MDQ6VXNlcjY0OTY2OTU2","name":null},"body":"```\r\n do {\r\n var response = try transaction.readObject(ofType: Package.self, withKey: packageId)\r\n response.status = entry.status\r\n \r\n try transaction.write(object: response, withKey: packageId) \r\n let confirmChange = try transaction.readObject(ofType: Package.self, withKey: packageId)\r\n print(confirmChange)\r\n } catch {\r\n print(error)\r\n }\r\n\r\n```\r\n\r\nI digged down until ApolloStore -> `func mergePromise(records: RecordSet)`.\r\nResult is giving me succes `fulfill(cacheKey)` with cacheKey \"123.status\" which is correct packageId and correct field I was trying to manipulate. \r\n\r\nHowever confirmChange object has unchanged status. My `cacheKeyForObject` for both store and client are set. \r\nIs it sth I am doing wrong or writeObject is not working the way I think?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"The issue is that the transactions aren't guaranteed to be synchronous, so `transaction.write` may not have finished before `transaction.read` is called. \r\n\r\nYou'd need to use [`withinWriteTransaction`](https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/ApolloStore.swift#L149) in order to validate the change. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Actual problem was: invalid cacheKeys. Sorry for wasting Tour time.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"No worries - thanks for following up with what actually happened! I'm gonna go ahead and close this issue out. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"长连接手动断开和重连","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null},"body":"你好\r\n如何在 APP 进入后台时,手动断开长连接,从新打卡 APP 时再重新连接长连接?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Via Google Translate since I don't speak Chinese: \r\n\r\n> Hello there\r\n> How to manually disconnect the long connection when the APP enters the background, and then reconnect the long connection when the APP is newly clocked in?\r\n\r\nAre you asking about subscriptions or some other kind of long connection? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"你好.订阅消息. WebSocketTransport\r\n\"WeChat67a3558698ad0ab1125ec3110a335a58\"\r\n如果使用方法.我想在 APP 进入后台时,断开.在 APP重新打开的时候重新连接?\r\n初学者请多见谅!\r\n","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null}},{"__typename":"IssueComment","body":"> Hello. Subscribe to news. WebSocketTransport\r\n\r\n[Here's Apple's documentation on handling lifecycle changes](https://developer.apple.com/documentation/uikit/app_and_environment/managing_your_app_s_life_cycle) - The short answer is that you will probably want to call `closeConnection` on the `webSocketTransport` in your App Delegate's `applicationWillResignActive` method and restart the susbcription in `applicationDidBecomeActive`. \r\n\r\nNote that names are different in the Scene delegate if you're using that, but I don't think you are since you're using a singleton rather than per-scene instances of `Network`. \r\n\r\nLet me know if that helps!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"是的,这个地方使用的是单例.多个订阅消息在这里接受,然后进行分发处理.\r\n需要在 UIApplicationWillResignActiveNotification 时,断开订阅连接\r\n UIApplicationDidBecomeActiveNotification 重新连接订阅\r\n\r\n是通过 self.webSocketTransport.closeConnection() 断开订阅么","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null}},{"__typename":"IssueComment","body":"你好.我通过 调用 self.webSocketTransport.closeConnection() ,已经可以断开连接了. 在 UIApplicationDidBecomeActiveNotification 的时候怎么重新建立连接呢?\r\n![image](https://user-images.githubusercontent.com/10558372/89000672-86b02780-d32a-11ea-8df8-59fee24addf6.png)\r\n","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null}},{"__typename":"IssueComment","body":"Google translated: \r\n\r\n> Hello. I can disconnect by calling self.webSocketTransport.closeConnection(). How to re-establish the connection when UIApplicationDidBecomeActiveNotification?\r\n\r\nAh, because `addSubscribe` won't work if the web socket isn't connected, and right now there's not a way to tell the websocket to reconnect non-automatically. \r\n\r\nThe good news is #1335 will add the ability to reconnect more easily. Until then you'll probably need to hack it by using either `updateHeaderValues` or `updateConnectingPayload` to force a reconnection. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"#1335 is merged to `main` if you want to use it immediately, it'll come out probably sometime later this week in an official release. I'm going to close this out. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"RFC: Networking Updates","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"},"body":"This is the technical outline of a proposal to make major changes to our primary networking interface from the current `HTTPNetworkTransport` to a `RequestChainNetworkTransport` which uses a chain of interceptor objects to set up and process the results of network requests.\r\n\r\nNote that this is going to be a **🎉 Spectacularly 🎉** breaking change - while very surface level APIs will remain basically the same, if you're doing anything remotely advanced, this will necessitate some changes, but the idea is to break it now so we don't have to break it way worse later.\r\n\r\nI would **REALLY** love feedback on this before I start working towards making this the default option. You can see the code changes in-place in [this PR](https://github.com/apollographql/apollo-ios/pull/1341). I will be updating this RFC with feedback as it is received. \r\n\r\n## Why The Change?\r\n\r\n`HTTPNetworkTransport` allows you to hook into various delegates to accomplish various things. There are several limitations to this approach: \r\n\r\n- Users can only do things that are specifically supported by delegates.\r\n- Asynchronous use of delegates without callbacks is basically impossible.\r\n- Any time we want to add a new feature, we need to add a new delegate method and handle it, creating additional complexity.\r\n- There is no flexibility in terms of order of operations, particularly around whether data should be returned to the UI before being written to the cache.\r\n\r\nThe other major issue driving this update is that the current networking stack is *deeply* tied to the current cache architecture. This isn't ideal for many reasons, the biggest of which is that the cache likely to change in relation to the [Swift Codegen Rewrite](https://github.com/apollographql/apollo-ios/issues/939). \r\n\r\n## What is proposed? \r\n\r\nThe proposed new architecture uses the Interceptor pattern to create a customizable request chain. This means users can hook into the system at any point during the request creation or data processing process. \r\n\r\nThis also means that the pieces which will need to be swapped out for the Swift Codegen Rewrite are more clearly defined, and less tied to the actual parsing operation. \r\n\r\nFinally, this also opens the opportunity for different patterns than we already support, such as writing to the cache *after* returning data to the UI instead of before, or creating an array of interceptors which hit the network first, then hit the cache if nothing was returned. \r\n\r\n### New Protocols\r\n\r\n- **`FlexibleDecoder`**: This is mostly going to be helpful for the `Codable` implementation down the line, but this will allow anything conforming to `Decoder` to be used to decode data.\r\n- **`Parseable`**: This is a wrapper that allows us to continue to support non-`Codable` parsing alongside `Codable` parsing, while keeping us able to constrain and construct things generically. A default implementation for `Codable` will be provided.\r\n- **`ApolloInterceptor`**: This is an interface which allows you to add an asynchronous handler to perform any necessary work, such as fetching credentials and reading or writing from the cache, asynchronously. \r\n \r\n ```swift\r\n public protocol ApolloInterceptor: class {\r\n \r\n /// Called when this interceptor should do its work.\r\n ///\r\n /// - Parameters:\r\n /// - chain: The chain the interceptor is a part of.\r\n /// - request: The request, as far as it has been constructed\r\n /// - response: [optional] The response, if received\r\n /// - completion: The completion block to fire when data needs to be returned to the UI.\r\n func interceptAsync(\r\n chain: RequestChain,\r\n request: HTTPRequest,\r\n response: HTTPResponse?,\r\n completion: @escaping (Result, Error>) -> Void)\r\n }\r\n ```\r\n \r\n Default implementations of `ApolloInterceptor` for both Legacy (ie, non Swift Codegen) networking and Swift Codegen networking will be provided.\r\n- **`InterceptorProvider`** This protocol will be used to quickly create a new array of interceptors for a given request:\r\n\r\n ```swift\r\n public protocol InterceptorProvider {\r\n \r\n /// Creates a new array of interceptors when called\r\n ///\r\n /// - Parameter operation: The operation to provide interceptors for\r\n func interceptors(for operation: Operation) -> [ApolloInterceptor]\r\n }\r\n ```\r\n This design allows for both flexibility (you can return different interceptors for different types of requests, for instance) and isolation (each request will have its own unique set of interceptors, reducing the possibility of different requests stomping on each other). \r\n \r\n Two default interceptor providers are set up: \r\n - **`LegacyInterceptorProvider`** will provide interceptors mimicking the current stack \r\n - **`CodableInterceptorProvider`** will provide interceptors for the forthcoming Swift Codegen Rewrite's network stack. \r\n- **`ApolloErrorInterceptor`** will allow you to have additional checks whenever an error is about to be returned. This will be optional to implement, and no default implementation is provided.\r\n\r\n ```swift\r\n /// Asynchronously handles the receipt of an error at any point in the chain.\r\n ///\r\n /// - Parameters:\r\n /// - error: The received error\r\n /// - chain: The chain the error was received on\r\n /// - request: The request, as far as it was constructed\r\n /// - response: [optional] The response, if received\r\n /// - completion: The completion closure to fire when the operation has completed. Note that if you call `retry` on the chain, you will not want to call the completion block in this method.\r\n func handleErrorAsync(\r\n error: Error,\r\n chain: RequestChain,\r\n request: HTTPRequest,\r\n response: HTTPResponse?,\r\n completion: @escaping (Result, Error>) -> Void)\r\n ```\r\n \r\n### New Classes\r\n\r\n- **`HTTPRequest`** This object will hold all the information related to a request before it hits the network, with the `toURLRequest()` method creating an actual `URLRequest` based on all the information in the request. This is subclass-able (and will mostly be using subclasses). \r\n\r\n ```swift\r\n open class HTTPRequest {\r\n\r\n open var graphQLEndpoint: URL\r\n open var operation: Operation\r\n open var contentType: String\r\n open var additionalHeaders: [String: String]\r\n open var clientName: String? = nil\r\n open var clientVersion: String? = nil\r\n open var retryCount: Int = 0\r\n public let cachePolicy: CachePolicy\r\n\r\n public init(graphQLEndpoint: URL,\r\n operation: Operation,\r\n contentType: String,\r\n additionalHeaders: [String: String],\r\n cachePolicy: CachePolicy = .default)\r\n \r\n open func toURLRequest() throws -> URLRequest\r\n\r\n open func addHeader(name: String, value: String)\r\n }\r\n ```\r\n \r\n - **`JSONRequest`** subclass of `HTTPRequest` will handle creating requests with JSON, which will be the vast majority of requests with operations. This is where handling of auto-persisted queries is also layered in: \r\n\r\n ```swift\r\n public class JSONRequest: HTTPRequest {\r\n \r\n public let requestCreator: RequestCreator\r\n \r\n public let autoPersistQueries: Bool\r\n public let useGETForQueries: Bool\r\n public let useGETForPersistedQueryRetry: Bool\r\n public var isPersistedQueryRetry = false\r\n \r\n public let serializationFormat = JSONSerializationFormat.self\r\n\r\n public init(operation: Operation,\r\n graphQLEndpoint: URL,\r\n additionalHeaders: [String: String] = [:],\r\n cachePolicy: CachePolicy = .default,\r\n autoPersistQueries: Bool = false,\r\n useGETForQueries: Bool = false,\r\n useGETForPersistedQueryRetry: Bool = false,\r\n requestCreator: RequestCreator = ApolloRequestCreator())\r\n }\r\n ```\r\n \r\n - **`UploadRequest`** subclass of `HTTPRequest` will handle multipart file uploads:\r\n\r\n ```swift\r\n public class UploadRequest: HTTPRequest {\r\n \r\n public let requestCreator: RequestCreator\r\n public let files: [GraphQLFile]\r\n public let manualBoundary: String? \r\n public let serializationFormat = JSONSerializationFormat.self\r\n \r\n public init(graphQLEndpoint: URL,\r\n operation: Operation,\r\n additionalHeaders: [String: String] = [:],\r\n files: [GraphQLFile],\r\n manualBoundary: String? = nil,\r\n requestCreator: RequestCreator = ApolloRequestCreator()) \r\n }\r\n ```\r\n\r\n- **`HTTPResponse`** will represent the objects returned and/or parsed from the server:\r\n\r\n ```swift\r\n /// Designated initializer\r\n ///\r\n /// - Parameters:\r\n /// - response: The `HTTPURLResponse` received from the server.\r\n /// - rawData: The raw, unparsed data received from the server.\r\n /// - parsedResponse: [optional] The response parsed into the `ParsedValue` type. Will be nil if not yet parsed, or if parsing failed.\r\n public class HTTPResponse {\r\n public var httpResponse: HTTPURLResponse\r\n public var rawData: Data\r\n public var parsedResponse: GraphQLResult?\r\n }\r\n ```\r\n\r\n- **‌`RequestChain`** will handle the interaction with the network for a single operation. \r\n\r\n ```swift\r\n public class RequestChain: Cancellable {\r\n\r\n /// Creates a chain with the given interceptor array\r\n public init(interceptors: [ApolloInterceptor])\r\n \r\n /// Kicks off the request from the beginning of the interceptor array.\r\n ///\r\n /// - Parameters:\r\n /// - request: The request to send.\r\n /// - completion: The completion closure to call when the request has completed.\r\n public func kickoff(\r\n request: HTTPRequest, \r\n completion: @escaping (Result) -> Void)\r\n \r\n /// Proceeds to the next interceptor in the array.\r\n /// \r\n /// - Parameters:\r\n /// - request: The in-progress request object\r\n /// - response: [optional] The in-progress response object, if received yet\r\n /// - completion: The completion closure to call when data has been processed and should be returned to the UI.\r\n public func proceedAsync(\r\n request: HTTPRequest, \r\n response: HTTPResponse?,\r\n completion: @escaping (Result) -> Void)\r\n \r\n /// Cancels the entire chain of interceptors.\r\n public func cancel()\r\n \r\n /// Restarts the request starting from the first inteceptor.\r\n ///\r\n /// - Parameters:\r\n /// - request: The request to retry\r\n /// - completion: The completion closure to call when the request has completed.\r\n public func retry(\r\n request: HTTPRequest,\r\n completion: @escaping (Result) -> Void)\r\n }\r\n ```\r\n- **`RequestChainNetworkTransport`** provides an implementation of `NetworkTransport` which uses an `InterceptorProvider` to create a request chain for each request. \r\n ```swift\r\n public class RequestChainNetworkTransport: NetworkTransport {\r\n \r\n public init(interceptorProvider: InterceptorProvider,\r\n endpointURL: URL,\r\n additionalHeaders: [String: String] = [:],\r\n autoPersistQueries: Bool = false,\r\n cachePolicy: CachePolicy = .default,\r\n requestCreator: RequestCreator = ApolloRequestCreator(),\r\n useGETForQueries: Bool = false,\r\n useGETForPersistedQueryRetry: Bool = false)\r\n }\r\n ```\r\n\r\n### Changes to existing Protocols and Classes\r\n\r\n- **`ApolloStore`** will no longer require a `GraphQLQuery` explicitly for fetching data from the store. It will instead return an error if the `GraphQLOperationType` is not `.query`. This change is necessary to avoid going down an enormous rabbit hole with generics since `GraphQLOperation` has an associated type. \r\n- The **`NetworkTransport`** protocol will get a new method to be implemented: \r\n\r\n ```swift\r\n func sendForResult(operation: Operation,\r\n completionHandler: @escaping (Result, Error>) -> Void) -> Cancellable\r\n ```\r\n \r\n This will avoid the double-wrapping of `GraphQLResponse` around the `GraphQLResult` so that only the `GraphQLResult` is actually returned. The `send` method will eventually be deprecated and removed. \r\n- **`ApolloClient`** will get a new `sendForResult` method which calls into the `sendForResult` method added to `NetworkTransport`.\r\n\r\n## How will this work in practice? \r\n\r\nInstantiating a new legacy client manually will look like this: \r\n\r\n```swift\r\nlazy var legacyClient: ApolloClient = {\r\n let url = URL(string: \"http://localhost:8080/graphql\")!\r\n \r\n let store = ApolloStore(cache: InMemoryNormalizedCache())\r\n let provider = LegacyInterceptorProvider(store: store)\r\n let transport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: url)\r\n \r\n return ApolloClient(networkTransport: transport)\r\n}()\r\n```\r\n\r\nIdeally I'll be able to transparently swap out the existing `HTTPNetworkTransport` for this so that this would be the under-the-hood setup on `ApolloClient`, but this may involve a transition period. \r\n\r\nCalls to the client will look like this: \r\n\r\n```swift\r\nlegacyClient.fetchForResult(query: HeroNameQuery()) { result in\r\n switch result {\r\n case .success(let graphQLResult):\r\n print(graphQLResult.data?.hero?.name ?? \"Name not found\")\r\n case .failure(let error):\r\n print(\"Unexpected error: \\(error)\")\r\n }\r\n}\r\n```\r\n\r\nNote that this is VERY similar to how they look on the surface at the moment, which is intentional. \r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Overall this looks great. I only have 2 small questions: \r\n- Do you think it is possible to add an `ErrorType: Error` generic type to the signature of `handleErrorAsync` in the `ApolloErrorInterceptor`? I would love to be able to return typed errors, and this generic parameter could simply default to `Error` itself if not specified.\r\n- Do you have any plan to add an official `ApolloCombine` module?","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"1. I'll have to mess around with this and see how it works - my recollection is that it would cause much more complex typing issues, but I'll see what we can do. \r\n2. Eventually, but it's going to be after all the codegen rewrites. There is a [community Combine package](https://github.com/joel-perry/ApolloCombine) if you're looking for something immediately","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> Instantiating a **new legacy** client\r\n\r\nHeh, this was kinda funny to me.\r\n\r\n---\r\n\r\n> `public let requestCreator: RequestCreator`\r\n\r\nShould the request creator live on _all_ requests? Said another way, what's the rationale behind only allowing `JSONRequests` to have this property?\r\n\r\n> Do you think it is possible to add an `ErrorType: Error` generic type to the signature of` handleErrorAsync`\r\n\r\n+1 to this, but definitely not critical for the context of this RFC. I feel like typed errors could be it's own whole RFC/PR too!\r\n\r\n\r\n> **ApolloStore will no longer require a GraphQLQuery explicitly for fetching data from the store**. It will instead return an error if the GraphQLOperationType is not .query. This change is necessary to avoid going down an enormous rabbit hole with generics since GraphQLOperation has an associated type.\r\n\r\nI'm a little bit fuzzy on what this change is. If not a `GraphQLQuery`, what will the input for data fetching from the store be? Can you clarify for me?\r\n\r\n---\r\n\r\nAll told, this seems solid! One of our big use cases in the GitHub app for the current delegate implementation of this is to logout on HTTP 401 status codes, so it seems like that should make this a little simpler (just need an interceptor to throw an error when those responses come back).\r\n\r\nHoller if you want some feedback directly on https://github.com/apollographql/apollo-ios/pull/1341 as well!","author":{"__typename":"User","login":"eliperkins","id":"MDQ6VXNlcjEwNTE0NTM=","name":"Eli Perkins"}},{"__typename":"IssueComment","body":">> Instantiating a new legacy client\r\n\r\n> Heh, this was kinda funny to me.\r\n\r\nHa, that's what I get for working on this doc for so long, I completely glossed that over 🙃\r\n\r\n>> public let requestCreator: RequestCreator\r\n\r\n> Should the request creator live on all requests? Said another way, what's the rationale behind only allowing JSONRequests to have this property?\r\n\r\nMy thought that was only `HTTPRequest` subclasses that actually need to use it should have access to it - `JSONRequest` and a forthcoming `UploadRequest` would be the places I'm thinking. At this point both of those subclasses would need it, but I don't know that it makes sense to tie that to the base class at this time. Would be interesting to hear your thoughts on that.\r\n\r\n>> ApolloStore will no longer require a GraphQLQuery explicitly for fetching data from the store. It will instead return an error if the GraphQLOperationType is not .query. This change is necessary to avoid going down an enormous rabbit hole with generics since GraphQLOperation has an associated type.\r\n\r\n> I'm a little bit fuzzy on what this change is. If not a GraphQLQuery, what will the input for data fetching from the store be? Can you clarify for me?\r\n\r\nBasically, we have the `GraphQLOperation` protocol, with an associated type of `Data`, and its three sub-protocols, `GraphQLQuery`, `GraphQLMutation`, and `GraphQLSubscription`. Previously, we were limiting what operations could read from the cache to `GraphQLQuery`, since in theory that's the only place getting something from the cache would matter. \r\n\r\n`HTTPRequest` only requires a specification of `GraphQLOperation`, but when making a call into the cache, we can't use the `Blah is GraphQLQuery` method of figuring out whether a `GraphQLOperation` is a query because of the `associatedType` on `GraphQLOperation`. \r\n\r\nI tried about 15 different workarounds for this and this is the only one that wasn't monstrously over-complicated - everything else involved some mild-to-completely bizarre type erasure strategies. I'm not totally against those, but I think in this case the benefits of going that way were vastly outweighed just changing the gating of this a bit.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"and if you have specific feedback on #1341 I'd love to hear it - just be aware that there's definitely a lot that's WIP (thus the TODOs)","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"OK, I've done some poking around on the request for a typed error parameter, and I don't think it's going to be doable at the interceptor level.\r\n\r\nWhen I tried to add this in, any existing `Error` I tried to return would cause a \"Cannot convert value\" build failure: \r\n\"Screen\r\n\"Screen\r\n\r\nIt'd make the interceptors a lot harder to keep independent if they all had to have exactly the same type of error. It also wouldn't be possible for me to have default implementations return errors without having `TypedError` conform to some other protocol that allows me to return an underlying arbitrary error. Ultimately, I think that adds too much complexity for general use cases.\r\n\r\nI think if you want to write your own typed wrapper that takes whatever's returned and feeds it into something with an `underlying` error that's easier to switch on, that could work. But I think requiring everything have to be the same type at a protocol level is going to lead to a hell of a lot more confusion than it solves. \r\n\r\nWould love to hear feedback on this finding.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"One of the things that's nice about the `ApolloLink` abstraction used for the web version of Apollo Client is that the link chain is more like a linked list, rather than an array, with each link deciding how to forward the request on to the rest of the chain (and how to process the response), without needing an overarching `RequestChain` to manage the list of links.\r\n\r\nConcretely, this kind of approach would probably mean the `InterceptorProvider` would return a single `ApolloInterceptor` (analogous to `ApolloLink`), representing the head of the linked list, rather than a `[ApolloInterceptor]` array. The last interceptor in the chain (the tail of the list) would be responsible for performing the actual HTTP request, in most cases—but not always!\r\n\r\nSometimes you want to terminate the chain with something that makes an HTTP request, but other times the terminal link might provide its own data (for example, mock data during tests). Sometimes you might want to split a request between multiple downstream links, or choose among several servers that can handle different kinds of requests (or load-balance the same type of request between multiple servers, entirely on the client). It's hard to represent branching structures like that as an array, because it's no longer really a list, but a dynamic tree. But if each interceptor gets to make its own decisions about how it passes requests to the rest of the chain (and how it handles the responses), the branching can be hidden as an implementation detail, with each interceptor abstracting over everything downstream from it.\r\n\r\nI don't know enough Swift to anticipate specific ways in which this approach might be tricky, but it seems like it should be possible to give the interceptor chain more of a recursive, potentially tree-like structure. That's worked pretty well on the web, in the sense that I haven't had to worry very much about the `ApolloLink` system, even as I've changed large portions of the rest of the library.\r\n\r\nFor reference, here's an overview of `ApolloLink` concepts that I've found useful in the past: https://www.apollographql.com/docs/link/overview/","author":{"__typename":"User","login":"benjamn","id":"MDQ6VXNlcjU3NTA=","name":"Ben Newman"}},{"__typename":"IssueComment","body":"I think one huge, huge difference is that things like cancellation, retry, and thread management can be handled through javascript's `Observable` reactive system. \r\n\r\nThat just isn't doable without either using Combine (which would require dropping everything below iOS 12, and is unfortunately a non-starter with a number of our larger users) or adding some kind of Reactive library as a dependency (which I am loathe to do because of the *massive* number of dependency conflicts it could introduce). \r\n\r\nHowever, I think you're right that splitting out methods for request setup vs response handling is a good idea - this could at least help reduce the number of things that need to be optional on `HTTPResponse`. \r\n\r\nWill futz with this tomorrow. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I'm glad you brought that up!\r\n\r\nWhile I agree that `Observable`s are an easier pill to swallow in JavaScript, and they do figure prominently in the `ApolloLink` API, I specifically do not think it's necessary to replicate their behavior here.\r\n\r\nI should also mention that `Observable` is not implemented natively in JS, so you still need some sort of library, and (if I'm being honest) the API doesn't fully deliver on any of those benefits you mentioned, so I think it's fair to say the acceptance of `Observable` in JS (compared to the resistance to Combine in iOS) is a matter of culture/taste/evangelism.\r\n\r\nOn the topic of cancellation, one approach that does work is to pass some sort of context object explicitly down through the chain (and back up), so that each link/interceptor can check whether the request has been cancelled at points where aborting would be safe. `Observable`s don't provide any useful notion of context, even if you wanted it, but you can design a pipeline/interceptor/chain system like this to provide a strongly typed context object everywhere it's needed, I believe.\r\n\r\nOn the topic of retrying, the [`RetryLink`](https://github.com/apollographql/apollo-client/blob/master/src/link/retry/retryLink.ts) subclass of `ApolloLink` has been successful in part because the retry logic can be hidden behind the same abstraction that any other `ApolloLink` provides. From the perspective of links earlier in the chain, a request that succeeded after several retries looks exactly like one that succeeded on the first try, except that it might have taken a bit longer. If retrying was something you could implement in a perfectly generic way for all interceptors, it might make sense to hoist it to a higher layer of the system (maybe into `RequestChain`), but in practice retrying tends to be sensitive to application concerns (different logic for different queries, even), so I think it makes sense to push it down into a part of the system that can be customized by application developers.\r\n\r\nI think we can agree it's important for interceptors to be able to perform any kind of async work as an implementation detail, which requires a uniformly asynchronous API. Both `Observable` and Combine provide that kind of API, but they are both probably overkill, or at the very least they would need to earn their way into a system like this. I believe you that Combine is not worth it for iOS, but then again I'm not sure `Observable` is totally defensible for JS applications, either.","author":{"__typename":"User","login":"benjamn","id":"MDQ6VXNlcjU3NTA=","name":"Ben Newman"}},{"__typename":"IssueComment","body":"> When I tried to add this in, any existing `Error` I tried to return would cause a \"Cannot convert value\" build failure:\r\n\r\nfrom this error it looks like you changed the signature of `handleErrorAsync` to:\r\n```swift\r\nfunc handleErrorAsync(\r\n error: TypedError,\r\n chain: RequestChain,\r\n request: HTTPRequest,\r\n response: HTTPResponse,\r\n completion: @escaping (Result) -> Void)\r\n```\r\n\r\nwhile I was thinking something like: \r\n```swift\r\nfunc handleErrorAsync(\r\n error: Error, // keep this one untyped so that you can pass anything you need\r\n chain: RequestChain,\r\n request: HTTPRequest,\r\n response: HTTPResponse,\r\n completion: @escaping (Result) -> Void) // but allow users to wrap the internal errors in their own custom types\r\n```\r\nso that you can give a default implementation that does not wrap the error type: \r\n```swift \r\nextension ApolloErrorInterceptor where TypedError == Error {\r\n// default interceptor with a untyped completionHandler\r\n```\r\n\r\nsorry I wasn't clear with the previous message. Thank you for fiddling with this!\r\n\r\n> +1 to this, but definitely not critical for the context of this RFC. I feel like typed errors could be it's own whole RFC/PR too!\r\n\r\n@designatednerd would you prefer to move this conversation in a separate issue?","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"@TizianoCoroneo Yeah if I left it with `Error` as the incoming error, I got that same `Cannot convert value` problem in the method in question - I'll take a look at your suggestion later today though","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@benjamn I think one thing that's helpful context to understand is that the basis for this architecture is the [`ApolloInterceptor` type in Android](https://github.com/apollographql/apollo-android/tree/master/apollo-runtime/src/main/java/com/apollographql/apollo/interceptor). This itself is based on [`OkHttp` library's `Interceptor` type](https://square.github.io/okhttp/interceptors/) that's used very widely throughout the Android ecosystem for networking.\r\n\r\nIn `OkHttp`, there's a chain that takes an array of interceptors. Each interceptor in the array needs to call `proceed` before it can keep going, and then each one calls `intercept` to handle the result. There's a few issues with that architecture as-is (mostly around things being implicitly asynchronous instead of explicitly asynchronous), which are generally dealt with by `ApolloInterceptor`'s changes to the architecture.\r\n\r\nStill futzing around, but I thought that'd be useful context.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@TizianoCoroneo I've pushed some stuff to a branch ominously named `nope/typed-errors` if you want to take a look - basically, what you're looking for is not possible without associated types which sends this wholllllllllle mess down a huge rabbit hole. This is a huge piece of why the generic constraint is on the function rather than set up as an `associatedType` in the first place. If you see a better way please definitely feel free to open a PR to that branch!\r\n\r\nAll: I did make some improvements that make it easier to reason about what data's coming back through (basically: Got rid of the need for `Parseable` and moved to `GraphQLResult` as the type being returned in the completion closure), I'll update the RFC tomorrow or Monday to match the updated implementation details. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I tried to play around with it, and I confirm that the ominous name of the branch is accurate. I found no way to avoid having the `TypedError` bubble up to the `RequestChain`, and from there going everywhere else.\r\nThanks for trying this anyway 😄 ","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"Still looking at some of the stuff @benjamn and I were talking about, but I've updated the issue to match what's in the code at the moment.\r\n\r\nTL;DR - I was able to simplify by constraining to `Operation.Data` on `GraphQLOperation` instead of to the more generic `Parseable`. In the end, the result of a GraphQL operation is actually what we handle, so making it even more generic didn't really anything (and in fact made it harder to real with errors that are within `GraphQLResult`, which is part of what a lot of folks want to be able to do. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"More updates:\r\n- Moved `HTTPResponse` to being optional on the interceptor and related methods rather than having its properties be optional. This makes it way clearer whether a response has been received from the network or not. \r\n- Moved error declaration within each individual interceptor for clarity\r\n\r\n@benjamn: While I think the linked-list idea is more flexible, I don't know the additional flexibility it provides gets you much more than what we have in \"This interceptor can be async and take as long as it pleases to do stuff, so you can fire off a bunch of additional network requests and wait for them to call `proceed` if you feel like it.\" \r\n\r\nI think the overwhelming majority of interceptors are not going to do that, and I think the simplicity, especially from a retry standpoint, of \"Here's a list of interceptors in the order they should be executed, GO!\" is a lot better fit for the way this is used on iOS than a linked list would be. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"More updates are up - I don't think any fundamentally change anything already in here, but I do have a couple questions: \r\n\r\n1. Is there anyone using the `context: UnsafeMutableRawPointer?` on the various send/fetch methods for `ApolloClient` _in a way that could not be replaced by this change_? I took it out for now but I figured It's worth asking.\r\n2. I'm extremely tempted to rip out the current `HTTPNetworkTransport` that `RequestChainNetworkTransport` is replacing altogether, largely because I would need to keep a whole bunch of knotted code in `ApolloClient` around that facilitates caching longer than I'd like to. However, I'd like to hear y'all's thoughts about ripping the band-aid in a single release (with a migration guide) vs. doing a bridge release that still has `HTTPNetworkTransport` and its associated ick with a bunch of deprecation warnings. \r\n\r\n For what it's worth I've updated all the tests that aren't specifically _for_ the `HTTPNetworkTransport` to use either a `RequestChainNetworkTransport`, or a `MockNetworkTransport` which inherits from it, and everything is back to passing. I don't think that fully captures the extent to which this would create work for developers using the more advanced delegate features, but I do think for people using less advanced features it shows that everything *should* work the same. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> 1. Is there anyone using the `context: UnsafeMutableRawPointer?` on the various send/fetch methods for ApolloClient in a way that could not be replaced by this change? I took it out for now but I figured It's worth asking.\r\n\r\nNot using it here 🤷‍♂️ feels like a pretty cumbersome API to use effectively right now, so removing it seems alright, as long as we don't think others are using it.\r\n\r\n> I'm extremely tempted to rip out the current ` that RequestChainNetworkTransport is replacing altogether, largely because I would need to keep a whole bunch of knotted code in ApolloClient around that facilitates caching longer than I'd like to. However, I'd like to hear y'all's thoughts about ripping the band-aid in a single release (with a migration guide) vs. doing a bridge release that still has HTTPNetworkTransport and its associated ick with a bunch of deprecation warnings.\r\n\r\nI think it's alright to remove this in favor of `RequestChainNetworkTransport`. Is there a way to deprecate it, and replace it's impl with `RequestChainNetworkTransport`? If it feels like more overhead to maintain, API-wise, I think it's fine to force consumers over to use `RequestChainNetworkTransport` instead, since it solves the same problems that supplying a custom `HTTPNetworkTransport` was doing.","author":{"__typename":"User","login":"eliperkins","id":"MDQ6VXNlcjEwNTE0NTM=","name":"Eli Perkins"}},{"__typename":"IssueComment","body":"> feels like a pretty cumbersome API to use effectively right now,\r\n\r\nWholeheartedly agreed, I want to come up with something way better (and that does not involve the word `Unsafe`)\r\n\r\n> replace it's impl with`RequestChainNetworkTransport`\r\n\r\nI don't think it's a great idea because there's a bunch of stuff with delegates that would be a bit of a hot mess to handle. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm going to close out this RFC as I'm getting ready to beta off of #1341 - I just updated the [client initialization documentation](https://deploy-preview-1341--apollo-ios-docs.netlify.app/docs/ios/initialization/), which hopefully will give a good idea of how this should all be working.\r\n\r\nIn terms of differences from what's outlined in the RFC, at this time the main difference is that I moved retry counting off the `HTTPRequest` itself and onto the `MaxRetryInterceptor`. \r\n\r\nFurther comments should be left on #1341 - thank you all for the feedback!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"getting \"The network connection was lost\" sometimes, while Calling API's","author":{"__typename":"User","login":"guru-mtech","id":"MDQ6VXNlcjY0NjU4ODQw","name":null},"body":"I cannot get the grapgql responces sometimes and getting following messages in console. Though My Internet connection completely normal and and speed is about 10MBps, I am getting follwing error sometimes!!\r\n\r\n\r\n2020-08-02 01:07:00.435742+0530 Dwell[16526:884485] Task <080DA3DA-F4E7-4F5C-9DE3-D2B77A55F81B>.<8> HTTP load failed, 159275/0 bytes (error code: -1005 [4:-4])\r\n2020-08-02 01:07:00.461811+0530 Dwell[16526:884303] Task <080DA3DA-F4E7-4F5C-9DE3-D2B77A55F81B>.<8> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 \"The network connection was lost.\" UserInfo={_kCFStreamErrorCodeKey=-4, NSUnderlyingError=0x6000014c4300 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 \"(null)\" UserInfo={NSErrorPeerAddressKey={length = 16, capacity = 16, bytes = 0x10021f9b12da60e20000000000000000}, _kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <080DA3DA-F4E7-4F5C-9DE3-D2B77A55F81B>.<8>, _NSURLErrorRelatedURLSessionTaskErrorKey=(\r\n \"LocalDataTask <080DA3DA-F4E7-4F5C-9DE3-D2B77A55F81B>.<8>\"\r\n), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://localhost:8091/graphql, NSErrorFailingURLKey=https://localhost:8091/graphql, _kCFStreamErrorDomainKey=4}\r\nThe operation couldn’t be completed. (Apollo.URLSessionClient.URLSessionClientError error 2.)\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! That error is coming from Apple's URL loading system, not from Apollo. I've got no idea why that would be happening with `localhost` - that shouldn't even be going out of your local network. \r\n\r\nI don't _think_ it's `http` vs `https` since that would theoretically be a different error, but it might be worth giving it a shot since most of the time `localhost` doesn't have SSL set up. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since I haven't heard anything back here in a couple weeks, I'm going to close this issue out. @guru-mtech if you're still having problems, feel free to reopen. Anyone else having similar problems, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Error \"Variable \"$id\" is never used\" not fail build process","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"},"body":"when generate API.swift with graphql file that has unuse variables.\r\nan error `Variable \"xxx\" is never used in operation \"xxx\"` is log but build process is success and run an app normally\r\n```\r\nquery Repo($id: ID!) {\r\n currentuser {\r\n id\r\n }\r\n}\r\n\r\n```\r\n\r\n\r\nbut on other error, the build process will fail \r\n\r\nEx. generate API.swift with below graphql result an error \r\n\r\n`error: Cannot query field \"something\" on type \"Query\". Did you mean \"setting\"?` \r\n\r\nand build process is fail\r\n```\r\nquery Repo {\r\n currentuser {\r\n id\r\n }\r\n something\r\n}\r\n```\r\n\r\nPS: Apollo version 0.27.1","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I would first recommend updating to a more recent version of the SDK - IIRC this was a bug in the underlying CLI that has since been addressed. If that doesn't help, let me know. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"update to Apollo 0.30.0 doesn't help. ","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"```\r\nVariable \"$id\" is never used in operation \"Repo\".\r\n\r\nCommand PhaseScriptExecution emitted errors but did not return a nonzero exit code to indicate failure\r\n```\r\n\r\n\r\nError from log when build with\r\n\r\n```\r\nquery Repo($id: ID!) {\r\n currentuser {\r\n id\r\n }\r\n}\r\n```","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"OK - are you using the shell script or the Swift Scripting method to run your codegen? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm not sure about that.\r\n\r\nI add a run script phase on Build Phase that has script below with shell = sh \r\n```\r\nPATH=$PATH:/usr/local/opt/node@8/bin\r\nSCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\n\r\nif [ -z \"${XCS_BOT_NAME}\" ]; then\r\n\r\ncd \"${SRCROOT}/${TARGET_NAME}\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./GraphQL/**/*.graphql --localSchemaFile=\"GraphQL/Generated/schema.json\" GraphQL/Generated/API.swift --customScalarsPrefix=GraphQL\r\nfi\r\n\r\n```","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"Yep that's the shell script method. Can you confirm that in your schema `currentuser` requires a non-optional `id`, meaning an `ID!`? If it only requires an `ID` (without the exclamation point) then that might be the source of the issue. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"`currentuser ` does not require any variables.`$id: ID!` is just unuse variable that i forgot to remove. it can change to any variable Ex. `Repo($abcd: String!)` or ` Repo($test: Int!)`\r\n\r\nif RepoQuery never called or called with given variable Ex. `RepoQuery(abcd: \"a\")` it'll build success with error that mention before but will throw an `Variable $abcd is never used in operation \"Repo\"` from the server","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"> `currentuser` does not require any variable\r\n\r\nI'm almost positive this is why it's not exiting, then. When the error is more of a \"Hey, you forgot to remove this, but there are no real consequences to not using this\" rather than a \"Nope, this is not a valid query\", we don't want to fail the entire build. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I understand that it's not a fatal error for an entire app. but if the query is sent to graphql server it'll always fail due to graphql default validation rule(if I understand it correctly). \r\nSo, I think it's not different from invalid query because the query always fails if sends to server","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"Hm...what server are you using? I think that might be a server implementation detail, but I could be wrong. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"`apollo-server-express` from https://github.com/apollographql/apollo-server/tree/main/packages/apollo-server-express\r\n","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"`GraphQL operation is only valid if all variables defined by an operation are used `\r\nfrom graphql-js [line](https://github.com/graphql/graphql-js/blob/80471134f1152c69da2cc27518a127991cc801b9/src/validation/rules/NoUnusedVariablesRule.d.ts#L7\r\n)\r\n\r\nI'm not sure that the server can choose to enable/disable this rule but I think it enable by default.","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"Ahhh got it. OK, will talk to some tooling folks on this.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"(FYI that team is super backed up, so it may take some time)","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"So our tooling folks are working on a new Rust-based parsing and validation of schema + queries, it will have to land with that. \r\n\r\nI believe the reason it's not in there right now is because it would cause errors when people were using it in watch mode (mostly useful for JS) and it got disabled for that. However, I'm going to be working to make sure there's at least a mode that can be selected in new Rust stuff to bomb out on errors like this. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Crashlytics reported: \"Crashed: com.apollographql.DataLoader\"","author":{"__typename":"User","login":"Kharauzov","id":"MDQ6VXNlcjE4MjQzNTI1","name":"Serhii Kharauzov"},"body":"Hi 👋, We have a version of iOS Apollo SDK: 0.27.0\r\n\r\nWe've got many crashes:\r\n\r\nURLSessionClient.swift line 85\r\nURLSessionClient.sendRequest(_:rawTaskCompletionHandler:completion:)\r\n\r\nCrashed: com.apollographql.DataLoader\r\nEXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000\r\n\r\nWill be thankful for any suggestion or help 🙏🏼\r\n\r\nIt happened for different iOS versions and different devices.\r\nHere is a stack trace:\r\n```\r\nApollo\r\nURLSessionClient.swift - Line 85\r\nURLSessionClient.sendRequest(_:rawTaskCompletionHandler:completion:) + 85\r\n2\r\nApollo\r\nHTTPNetworkTransport.swift - Line 159\r\nHTTPNetworkTransport.send(operation:isPersistedQueryRetry:files:completionHandler:) + 159\r\n3\r\nApollo\r\nApolloClient.swift - Line 70\r\nApolloClient.send(operation:shouldPublishResultToStore:context:resultHandler:) + 70\r\n4\r\nApollo\r\nApolloClient.swift - Line 287\r\nFetchQueryOperation.fetchFromNetwork() + 287\r\n5\r\nApollo\r\nApolloClient.swift - Line 282\r\nclosure #1 in FetchQueryOperation.start() + 282\r\n6\r\nApollo\r\nApolloStore.swift - Line 193\r\nclosure #2 in ApolloStore.load(query:resultHandler:) + 193\r\n7\r\nApollo\r\nPromise.swift - Line 142\r\nclosure #1 in closure #1 in Promise.catch(_:) + 142\r\n8\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n9\r\nApollo\r\n - Line 4351234200\r\nclosure #1 in Promise.resolve(_:) + 4351234200\r\n10\r\nApollo\r\n - Line 4351232104\r\nPromise.resolve(_:) + 4351232104\r\n11\r\nApollo\r\nPromise.swift - Line 213\r\nPromise.reject(_:) + 213\r\n12\r\nApollo\r\nPromise.swift - Line 122\r\nclosure #1 in closure #1 in Promise.andThen(_:) + 122\r\n13\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n14\r\nApollo\r\n - Line 4351234200\r\nclosure #1 in Promise.resolve(_:) + 4351234200\r\n15\r\nApollo\r\n - Line 4351232104\r\nPromise.resolve(_:) + 4351232104\r\n16\r\nApollo\r\nPromise.swift - Line 213\r\nPromise.reject(_:) + 213\r\n17\r\nApollo\r\nPromise.swift - Line 165\r\nclosure #1 in closure #1 in Promise.map(_:) + 165\r\n18\r\nApollo\r\npartial apply for closure #1 in closure #1 in Promise.map(_:) + 4351241932\r\n19\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n20\r\nApollo\r\n - Line 4351234200\r\nclosure #1 in Promise.resolve(_:) + 4351234200\r\n21\r\nApollo\r\n - Line 4351232104\r\nPromise.resolve(_:) + 4351232104\r\n22\r\nApollo\r\nPromise.swift - Line 213\r\nPromise.reject(_:) + 213\r\n23\r\nApollo\r\nPromise.swift - Line 142\r\nclosure #1 in closure #1 in Promise.catch(_:) + 142\r\n24\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n25\r\nApollo\r\n - Line 4351234200\r\nclosure #1 in Promise.resolve(_:) + 4351234200\r\n26\r\nApollo\r\n - Line 4351232104\r\nPromise.resolve(_:) + 4351232104\r\n27\r\nApollo\r\nPromise.swift - Line 213\r\nPromise.reject(_:) + 213\r\n28\r\nApollo\r\nPromise.swift - Line 122\r\nclosure #1 in closure #1 in Promise.andThen(_:) + 122\r\n29\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n30\r\nApollo\r\n - Line 4351234200\r\nclosure #1 in Promise.resolve(_:) + 4351234200\r\n31\r\nApollo\r\n - Line 4351232104\r\nPromise.resolve(_:) + 4351232104\r\n32\r\nApollo\r\nPromise.swift - Line 213\r\nPromise.reject(_:) + 213\r\n33\r\nApollo\r\nPromise.swift - Line 142\r\nclosure #1 in closure #1 in Promise.catch(_:) + 142\r\n34\r\nApollo\r\nPromise.swift - Line 238\r\nclosure #1 in Promise.whenResolved(_:) + 238\r\n35\r\nApollo\r\nPromise.swift - Line 4351205536\r\nPromise.whenResolved(_:) + 4351205536\r\n36\r\nApollo\r\nPromise.swift - Line 136\r\npartial apply for closure #1 in Promise.catch(_:) + 136\r\n37\r\nApollo\r\nPromise.swift - Line 68\r\nPromise.init(_:) + 68\r\n38\r\nApollo\r\nPromise.swift - Line 135\r\nclosure #1 in closure #1 in Promise.flatMap(_:) + 135\r\n39\r\nApollo\r\npartial apply for closure #1 in closure #1 in Promise.map(_:) + 4351241932\r\n40\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n41\r\nApollo\r\nspecialized closure #1 in Promise.resolve(_:) + 4351233008\r\n42\r\nApollo\r\nspecialized Promise.fulfill(_:) + 4350994784\r\n43\r\nApollo\r\n - Line 4350998216\r\npartial apply for specialized Promise.fulfill(_:) + 4350998216\r\n44\r\nApollo\r\nPromise.swift - Line 163\r\nspecialized closure #1 in closure #1 in Promise.map(_:) + 163\r\n45\r\nApollo\r\npartial apply for specialized closure #1 in closure #1 in Promise.map(_:) + 4351244372\r\n46\r\nApollo\r\n - Line 4351244132\r\npartial apply for specialized thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351244132\r\n47\r\nApollo\r\n - Line 4351232400\r\nspecialized closure #1 in Promise.resolve(_:) + 4351232400\r\n48\r\nApollo\r\nPromise.swift - Line 4350994980\r\nspecialized Promise.fulfill(_:) + 4350994980\r\n49\r\nApollo\r\n - Line 4351012708\r\npartial apply for specialized thunk for @escaping @callee_guaranteed (@in_guaranteed B) -> () + 4351012708\r\n50\r\nApollo\r\nDataLoader.swift - Line 53\r\nspecialized closure #3 in closure #1 in DataLoader.dispatch() + 53\r\n51\r\nApollo\r\n - Line 4351012380\r\npartial apply for specialized thunk for @escaping @callee_guaranteed (@guaranteed [B]) -> (@error @owned Error) + 4351012380\r\n52\r\nApollo\r\nPromise.swift - Line 122\r\nspecialized closure #1 in Promise.andThen(_:) + 122\r\n53\r\nApollo\r\nDataLoader.swift - Line 4351009748\r\nspecialized closure #1 in DataLoader.dispatch() + 4351009748\r\n54\r\nApollo\r\n - Line 4350967396\r\nthunk for @escaping @callee_guaranteed () -> () + 4350967396\r\n```\r\n\r\n\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hello, this was addressed in [0.27.1](https://github.com/apollographql/apollo-ios/blob/main/CHANGELOG.md#v0271), I recommend updating your client. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd , hello👋 Roger that. We've already updated to the latest version 0.30.0. \r\nWe'll see soon if it solves the issue.\r\nThanks.","author":{"__typename":"User","login":"Kharauzov","id":"MDQ6VXNlcjE4MjQzNTI1","name":"Serhii Kharauzov"}},{"__typename":"IssueComment","body":"OK great - I'm going to close this since it was a known issue with 0.27.0. If you're still seeing problems with this on 0.30.0, please open a new issue and we'll figure it out. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Getting \"The request timed out.\" sometimes while calling query and mutation.","author":{"__typename":"User","login":"DiwakarThapa","id":"MDQ6VXNlcjI5OTE3Nzk5","name":"diwakar thapa"},"body":"Hello!!! \r\nSometimes when I open the app I cannot get the **response of the first query** it requests rather I get the following **timeout error message** on Xcode debug console. I tried every possible solution found on StackOverflow but could find any effective solution and also could not figure out why **\"The request timed out.\"** has occurred in the first place. Our Android team is also experiencing similar issues. On the **server-side**, the timeout interval is **65 seconds**. so, I set request timeout interval **65 seconds** but it didn't work. \r\n\r\n**Console Error**\r\n```\r\nError Domain=NSURLErrorDomain Code=-1001 \"The request timed out.\" UserInfo={_kCFStreamErrorCodeKey=-2103, NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <1874F8BE-FA0F-45E1-8A51-96F290D85883>.<2>, NSURLErrorRelatedURLSessionTaskErrorKey=(\r\n \"LocalDataTask <1874F8BE-FA0F-45E1-8A51-96F290D85883>.<2>\"\r\n), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=https://example.graphql, NSErrorFailingURLKey=https://example.graphql, _kCFStreamErrorDomainKey=4}\r\n```\r\n**Is this apollo-ios terminating the request itself or server-side error?** ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"This is an error from Apple's URL loading system, the timeout is happening there. Are you saying that the timeout is happening before the 65 seconds that you set it to? Or just that it's still happening? The fact that your Android app is also having a similar problem points pretty squarely at your server.\r\n\r\nAlso am I correct in assuming that the url string here `https://example.graphql` is a placeholder for your real URL? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd `https://example.graphql` is a placeholder for our real URL? timeout is happening at 65 seconds.","author":{"__typename":"User","login":"DiwakarThapa","id":"MDQ6VXNlcjI5OTE3Nzk5","name":"diwakar thapa"}},{"__typename":"IssueComment","body":"Yeah that sounds like the request timeout is working as expected and the issue is that the request is, in fact, timing out, and that the issue is most likely going to be on your server side. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"thank you @designatednerd ","author":{"__typename":"User","login":"DiwakarThapa","id":"MDQ6VXNlcjI5OTE3Nzk5","name":"diwakar thapa"}},{"__typename":"IssueComment","body":"@designatednerd I forget to mention one thing, on **graphql playground** if we request the same query or mutation multiple times the response arrives without \"The request timed out. \" error but on the app side sometimes \"The request timed out. \" error appears. why is that?","author":{"__typename":"User","login":"DiwakarThapa","id":"MDQ6VXNlcjI5OTE3Nzk5","name":"diwakar thapa"}},{"__typename":"IssueComment","body":"GraphQL playground generally runs on your the same server as your endpoint, so in theory it's just making local calls. It's also possible that there's some kind of credential that is available through the web that's not going through to mobile. I wish I could narrow it down for you but unfortunately there are about a zillion things that could go wrong here. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@DiwakarThapa did you find a solution for your Problem? In our application, we have the same behaviour. Sometimes we run into a timeout, but the GraphQL Playground is always working.","author":{"__typename":"User","login":"DaTebe","id":"MDQ6VXNlcjEyOTY3MzA1","name":"DaTebe"}}]}},{"__typename":"Issue","title":"extensions property on GraphQLResult","author":{"__typename":"User","login":"paulkite","id":"MDQ6VXNlcjQwOTMwMDc=","name":"Paul Kite"},"body":"Hello! Curious if there are any plans to implement the `extensions` hash map support on `GraphQLResult`. I see the Android implementation has this and would love to be able to have the same ability to use this as well.\r\n\r\nThanks!","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"This [is implemented on `GraphQLError`](https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/GraphQLError.swift#L33) on our end. Are you using it in a non-error capacity? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes. Our team sends non-error information through `extensions`.","author":{"__typename":"User","login":"paulkite","id":"MDQ6VXNlcjQwOTMwMDc=","name":"Paul Kite"}},{"__typename":"IssueComment","body":"OK - looking at [the spec](https://spec.graphql.org/June2018/#sec-Response-Format) it does appear `extensions` is allowed at the root of the response. \r\n\r\nI'm somewhat swamped at the moment - if you want to make a PR you're more than welcome to (just make sure to add tests!) but I'll try to get to it as I can if not. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thank you so much for the response!","author":{"__typename":"User","login":"paulkite","id":"MDQ6VXNlcjQwOTMwMDc=","name":"Paul Kite"}},{"__typename":"IssueComment","body":"@designatednerd Just curious, what's the usual turnaround on PRs from the community to getting into a release?","author":{"__typename":"User","login":"paulkite","id":"MDQ6VXNlcjQwOTMwMDc=","name":"Paul Kite"}},{"__typename":"IssueComment","body":"Usually fairly quick if they're small. It'd almost certainly be faster than waiting for me to have bandwidth 😛 ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"This shipped as part of 0.32.0!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"GraphQLQueryWatcher - fetch and watch flow.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null},"body":"Let's discuss watchers, cache and their flow.\r\n\r\nCold start of application - no cache at all. \r\n**Here are my debug logs:**\r\n```\r\nisReachable true //Reachability change\r\nUser: nil //No user logged in \r\napollo.watch(query: SyncManagerQuery(), cachePolicy: .returnCacheDataDontFetch) \r\nWatch SyncManagerQuery // We are interested ONLY in cached data.\r\nWatch SyncManagerQuery error //Error cache is empty. It's ok\r\nMissing value //Error description - missing value. Because cache is empty. \r\n\r\n```\r\n\r\nHere everything seems to be fine. We are starting application for the first time. Cache is empty. Query watcher is being triggered and is returning error because of lack of data in cache.\r\n\r\nNow let's move forward and log in.\r\n\r\n```\r\nOptional() //Now we've got user\r\nfetch. apollo.fetch(query: SyncManagerQuery(), cachePolicy: .fetchIgnoringCacheData) \r\nFetch Sync FETCH //Ignoring cache data is still creating cache am I right?\r\nSync Fetch success //Fetch is successful \r\nBUT NOTHING IS HAPPENING :(\r\n```\r\n\r\n**Question 1:** Why watcher is not reacting? It is being stored in a parent object. \r\n`private var syncWatcher: GraphQLQueryWatcher?`\r\nand is initialized before fetch trigger.\r\n\r\nOk let's start over again. Close the application and start again with already existing cache. \r\n\r\n```\r\nisReachable true //We've got internet\r\nOptional() //We've got user\r\nFetch Sync FETCH //Above conditions are triggering FETCH\r\nWatch SyncManagerQuery //Hmm watch is also starting? Not that scary ok, it is just executing for the first time?\r\nWatch SyncManagerQuery success //Success - because we already have cache so it's ok\r\nSync Fetch success //In the meantime FETCH just finished\r\nWatch SyncManagerQuery // **1*** So it is triggering watch. Not sure why.\r\nWatch SyncManagerQuery error //Error :(The operation couldn’t be completed. (Apollo.URLSessionClient.URLSessionClientError error 2.) **2**\r\nWatch SyncManagerQuery // But hey it is trying once again \r\nWatch SyncManagerQuery success // And this time we've got a success.\r\n```\r\n\r\n**Question 2:** - Fetch result had no changes at all. It was exactly the same. Is watcher reacting to just cache update or is it verifying actual changes?\r\n**Question 3:** - Why it fails? And the retry is normal behavior after failure or is it a side effect of sth else?\r\n\r\n\r\nOk let's start over again. Exactly same conditions. We already have cache.\r\n```\r\n\r\nisReachable true //We've got internet\r\nOptional() //We've got user\r\nFetch Sync FETCH //Starting fetch\r\nWatch SyncManagerQuery \r\nWatch SyncManagerQuery success //Watching cache successful\r\nSync Fetch success //Fetching data successful, cache is being refreshed\r\nWatch SyncManagerQuery //And this is probably triggering watch \r\nWatch SyncManagerQuery success //Watch is successful\r\nWatch SyncManagerQuery //**1** But what is happening? Why it is triggering once again?\r\nWatch SyncManagerQuery success\r\n\r\n```\r\n**Question 4:** - why my watch query seems to be triggering twice after fetch? ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! I renumbered your questions so it would be clearer which one i'm responding to once I get more information here. Some things that would be helpful to understand: \r\n\r\n- Are you using the SQLite cache or the in-memory cache? \r\n- In the second code block (just before question 1), you are still running the watcher which was started in the first code block, and that's what you're expecting to get hit when you've added \"But nothing is happening\", correct?\r\n- After Question 1, you say \"close the application and start again\" - do you mean that you just exit the application then go back into it, or that you force-quit the application? \r\n- For the 3rd and 4th sets of logs, are you specifying a cache policy or using the default `.returnCacheDataElseFetch`? \r\n- Where in the application lifecycle are you setting up your watcher? Is it possible that the watcher could be getting set up multiple times? \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"1. SQLite cache\r\n2. That is the same app session. So yeah watcher is still up and running.\r\n3. Reset the application. New session. SQLite cache already exists. Just wanted to check how watcher is going to act with existing cache and initializing once again.\r\n4. Watch is always using returnCacheDataDontFetch, fetch is alwasy using fetchIgnoringCacheData\r\n5. Not possible in that case. My AppDelegate is starting the whole FlowControlAgent which is Singleton here.\r\n\r\nAll problems seems to be similar to \"cold start\" problem described here \r\nhttps://github.com/apollographql/apollo-ios/issues/99 \r\n","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"Yeah, this from @martijnwalraven in #99 definitely seems to explain why your first watcher isn't called:\r\n\r\n> Because your watch uses `.returnCacheDataDontFetch`, and the cache is initially empty, it will never get a valid response in that case.\r\n\r\nIs there a chance you could send me a small repro project? I should at least be able to try to figure out why the `watch` is getting called twice, but it'd be pretty hard to do without something to debug. You can email it to ellen at apollographql dot com. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'll do my best to prepare some sample however now I'm out of time. Hopefully will send you sth around weekend. \r\nRight now, well, I can live with double watcher :) ","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"@pgawlowski Were you ever able to get a sample together? If not, do you mind if we close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey @designatednerd \r\n\r\nSorry for not providing my sample code. It's still on my personal ToDo however I am totally sucked into other work. Let's close this issue right now. Hope I will provide some sample that will be helpful to validate this issue in some time - maybe during my vacations :) \r\n\r\nThanks for everything!","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}}]}},{"__typename":"Issue","title":"Cache and queries, unable to fetch record by ID.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null},"body":"So let's start with sth like this. Fetch and cache using SQLite normalized cache.\r\n```\r\nquery Sync {\r\n\tviewer {\r\n\t\tthings {\r\n\t\t\tnodes {\r\n\t\t\t\tid\r\n }\r\n }\r\n }\r\n}\r\n\r\n```\r\nHere is our cacheKeyForObject\r\n\r\n ```\r\n client.cacheKeyForObject = { (object) in\r\n if\r\n let id = object[\"id\"] as? String,\r\n let type = object[\"__typename\"] as? String {\r\n return [id, type]\r\n }\r\n // No id or typename, don't do caching\r\n return nil\r\n } \r\n\r\n```\r\nI also tried the basic one \r\n`client.cacheKeyForObject = { $0[\"id\"] }`\r\n\r\nWe've got (or at least out backend claims that we've got) unique ID's.\r\nNext I want to perform query with cachePolicy: `.returnCacheDataDontFetch`.\r\n\r\n```\r\nquery ThingActionConnection($thingId: ID!) {\r\n thing: node(id: $thingId) {\r\n ...on Thing {\r\n id\r\n }\r\n }\r\n} \r\n```\r\n\r\nResult is `GraphQLResultError(path: thing, underlying: Apollo.JSONDecodingError.missingValue)`\r\nThe more I dig down into apollo and caching the less I know how exactly this supposed to work. \r\n\r\nNetwork call is giving us correct results. What is more I checked local sqliteDB and there is a results with this particular `$thingId`. \r\n\r\nAndroid developer is getting results with ease. On our side, JSONDecodingError. \r\nI am nearly 100% sure that the problem is with cacheKeyForObject or ios apollo is unable to handle nodes here?\r\n\r\n@edit\r\nSame goes for \r\n```\r\n\r\nquery ThingActionTest($thingId: ID!) {\r\n viewer {\r\n thing(id: $thingId) {\r\n id\r\n }\r\n }\r\n}\r\n\r\n```\r\n\r\n@edit 2:\r\n\r\nInteresting fact is - direct cache access with same id works totally fine.\r\n\r\n```\r\n apolloClient.store.withinReadTransaction({ transaction in\r\n do {\r\n let variables = [\"isReady\": false]\r\n let data = try transaction.readObject(ofType: ThingAction.self, withKey: actionId, variables: variables)\r\n print(data)\r\n } catch {\r\n print(error.localizedDescription)\r\n }\r\n })\r\n```\r\nThis is only giving me more confusion about query execution on cache.\r\n\r\nI also noticed that direct cache access using query is giving me some confusing error.\r\n`Error at path \"thing)\": missingValue`\r\nWhy it is printing ')' character there? \r\n@edit ok it's just a typo in GraphqlExecutor.swift line 36.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"> The more I dig down into apollo and caching the less I know how exactly this supposed to work.\r\n\r\nWelcome to my last year, my friend 🙃. And also to why I'm planning to simplify a bunch of stuff in the Cache as part of phases 2-3 of the swift codegen rewrite if it's at all possible.\r\n\r\nI can tell you for sure that iOS and Android have no cache compatibility guarantees right now, and that I *think* the issue is that you're using a fragment on a node, and that you don't have the `id` on the node itself - that means that the node won't have an ID, and it won't go into the cache. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I finally figured it out. The problem was missing variables. \r\n\r\nHowever what I noticed is that sometimes when I am asking for data one by one I am getting\r\n`GraphQLResultError(path: lock.id, underlying: Apollo.JSONDecodingError.missingValue)` without any particular reason. Because starting exactly the same `withinReadTransaction` few seconds later is giving me correct response.\r\n","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"Is it giving you that error maybe because the data has not yet been populated? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Data is populated. \r\nI am executing exactly the same load and it can give a results like:\r\n\"I've got data.\"\r\n\"I've got data.\"\r\n\"I've got data.\"\r\nGraphQLResultError(path: lock.id, underlying: Apollo.JSONDecodingError.missingValue)\r\nGraphQLResultError(path: lock.id, underlying: Apollo.JSONDecodingError.missingValue)\r\n\"I've got data.\"\r\n\r\nNo fetching or repopulating cache in between.\r\nUser is offline and no cache manupulations are happening. I just wondered if there is a chance of some sort data access race here?\r\n\r\nI digged down ino the sql file and found that when I am getting this error the reference ID of one object is missing and right after getting data back there is a new one, different than previous (before missing value) one.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"There is definitely a possibility of a data race, there are some known issues with threading in the cache at the moment.\r\n\r\nI'd really need to see your exact code to figure out what's going on with your references - the reference ID should be stable, but any number of things could be happening here to mess that up. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@pgawlowski Were you ever able to resolve this issue? Anything I can do to help here or do you mind if I close this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey @designatednerd \r\nActually yes. The main problem was old cache + messed id's. \r\nThank you for your help.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}}]}},{"__typename":"Issue","title":"How to download schema.json with apollo client for an endpoint with url params and multi headers?","author":{"__typename":"User","login":"XiaoxiaYao","id":"MDQ6VXNlcjIyODk5MDk2","name":"MichaelYao"},"body":"Hi,\r\n\r\nI am trying to download a schema.json file from an endpoint. However, I don't know how to config the the url params and multi headers? Please check the pic below:\r\n![image](https://user-images.githubusercontent.com/22899096/89851786-e5de2980-dbbf-11ea-9a36-1c3499af4dc2.png)\r\nI am able to use graphql in graphiql. But don't know how to config in terminal. I tried:\r\n`apollo client:download-schema --endpoint=https://xxxxxxxxxxx/graphql/ --header='xxxxx-API-Key:xxxx;xxxxx-k:xxxxxx' --data='co=US'`\r\nHowever still no luck. Can anyone help me with this? I did not any doc about this ...so I am here. I don't know how to specify co=US and how to separate the headers with ,(comma) or ; (semi comma) Thank you in advance. Thanks.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! Each header must be passed in separately like so: `--header=\"Header-Key: Header Value\" --header=\"Header-Key-2: Header Value 2\"`\r\n\r\nThere is also a way to set this up using the [Swift Scripting lib](https://www.apollographql.com/docs/ios/swift-scripting) using the [`ApolloSchemaDownloader`](https://www.apollographql.com/docs/ios/swift-scripting/#downloading-a-schema). ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> Hi! Each header must be passed in separately like so: `--header=\"Header-Key: Header Value\" --header=\"Header-Key-2: Header Value 2\"`\r\n> \r\n> There is also a way to set this up using the [Swift Scripting lib](https://www.apollographql.com/docs/ios/swift-scripting) using the [`ApolloSchemaDownloader`](https://www.apollographql.com/docs/ios/swift-scripting/#downloading-a-schema).\r\n\r\nThank you. Sorry, one more thing. Do you know how to deal with url params? co=US? How should I set it?","author":{"__typename":"User","login":"XiaoxiaYao","id":"MDQ6VXNlcjIyODk5MDk2","name":"MichaelYao"}},{"__typename":"IssueComment","body":"URL params should just be the same as a normal URL - `https://example.com?paramName=paramValue¶m2name=param2Value`","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Cool. I will have a try. Thank you @designatednerd. Have a nice day!","author":{"__typename":"User","login":"XiaoxiaYao","id":"MDQ6VXNlcjIyODk5MDk2","name":"MichaelYao"}},{"__typename":"IssueComment","body":"@XiaoxiaYao Mind if we close this issue out then? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm gonna close this out - @XiaoxiaYao if you have further problems please reopen. Anyone else experiencing similar problems, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Changing converting logic for custom objects","author":{"__typename":"User","login":"Shiaulis","id":"MDQ6VXNlcjEzNjAxNzQ4","name":"Andrius Shiaulis"},"body":"Hey awesome Apollo team. I have a question related to custom scalar objects.\r\nWe are moving towards using GraphQL and I'm trying to adapt it for our requests. The problem occurs whenever I'm trying to convert custom objects from our response.\r\nOur backend is using `JSON` type for legacy information. Codegen is trying to convert it to a string:\r\n![image](https://user-images.githubusercontent.com/13601748/90020057-f8d42500-dcb7-11ea-8132-dc3b28699b36.png)\r\n\r\nIs there any way to specify that we don't want that object to be converted to a string?\r\nFor now I know only one solution: pass `--passthroughCustomScalars` key, but the downside of this approach is that I need to create global typealias or type for with `JSON` name for the whole project. Is there any way to not convert the object at all so it can convert ANY type or some more specific name like `ApolloJSON` so in that case name would be more specific?\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Okay I found codegen Readme file :) At least I can make prefix for custom scalars by passing it with codegen option:\r\n```\r\n--customScalarsPrefix=\"Apollo\"\r\n```","author":{"__typename":"User","login":"Shiaulis","id":"MDQ6VXNlcjEzNjAxNzQ4","name":"Andrius Shiaulis"}},{"__typename":"IssueComment","body":"Yep, there's also a `namespace` option that wraps all your stuff in a big `enum` to namespace it. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"HTTPNetworkTransport's URLSessionClient possible [ lost calls / memory leak ]","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null},"body":"Hi team!\r\nFirst of all, thanks for an awesome framework that makes the lives of so many of us that much easier 😄\r\n\r\nWe have run into a [lost calls / memory leak] issue.\r\nWe believe it is closely linked to issue https://github.com/apollographql/apollo-ios/issues/1292.\r\n\r\n### SETUP\r\nDependency manager: SPM\r\nApollo-iOS version: 0.30.0\r\nSetup: Instanced (not a Singleton)\r\n\r\nAlso we provide a `URLSessionClient` that runs on a background callbackQueue to the `HTTPNetworkTransport`:\r\n```\r\nURLSessionClient(\r\n sessionConfiguration: URLSessionConfiguration.background(withIdentifier: \"background\"),\r\n callbackQueue: .some(operation)\r\n)\r\n```\r\n\r\n### INTENDED OUTCOME\r\nWe expect that the calls of all instanced ApolloClients return successfully.\r\nWe also expect that ApolloClients that are not retained in our code get deallocated from the system memory.\r\n\r\n### ACTUAL OUTCOME\r\nWe first noticed that for some reason, new instances of `ApolloClient` (those created after the first instance is not retained in our code anymore) never return from their calls This has made us notice that the created `URLSessionClient`s, `HTTPNetworkTransport`s and `ApolloClient`s are never deallocated properly causing a memory leak.\r\n\r\n### REPRODUCTION STEPS\r\n1 - Make a call with the setup described above.\r\n2 - Remove the retained instance of the ApolloClient.\r\n3 - Create a new ApolloClient and make a new call.\r\n4 - Call does not come back / memory leak occurs.\r\n5 - Repeat from step 2 to create a new unwanted retained instance of `URLSessionClient`, `HTTPNetworkTransport` and `ApolloClient`.\r\n\r\n### OUR CONCLUSIONS\r\nThis part should be taken with a grain of salt as we are not Apollo experts. That said, it is the only conclusion that survived our tests. Having found this https://stackoverflow.com/questions/62612056/why-dispatchqueue-global-still-alive-after-deinit on StackOverflow, we think that the problem stems from the queue keeping alive the instance of the `URLSession` created in `URLSessionClient` in some fashion.\r\n\r\nThis causes multiple retains climbing up the dependence graph of:\r\n- URLSession\r\n- URLSessionClient\r\n- HTTPNetworkTransport\r\n- ApolloClient\r\n- Objects in our code that calls ApolloClient ...\r\n\r\n### OUR SOLUTION\r\nAdding the following to `HTTPNetworkTransport` fixes both our issues:\r\n```\r\ndeinit {\r\n self.client.session.invalidateAndCancel()\r\n}\r\n```\r\n\r\nWe understand that this is most probably not the solution you will want to implement but it might help as a starting point to formulate something that will not jeopardize others that use your framework.\r\n\r\n### OUR INVESTIGATION\r\nIt should be said that we took the liberty to try this as there was code in the `URLSessionClient` for `deinit` that clears all tasks. We surmised that clearing the tasks in that situation did not cause a problem for calls in progress, meaning that clients of the framework should not expect the calls to complete if they stop holding their instance of `ApolloClient`.\r\n\r\nBut we noticed that the `deinit` in the `URLSessionClient` was never called even when its parent `HTTPNetworkTransport` `deinit` was called. We then noticed that the `HTTPNetworkTransport` was never deallocated even though its `deinit` was called.\r\n\r\nThat made us realize that something further down the line was probably holding things recursively. Implementing our solution, everything gets deallocated and for some reason, further ApolloClients return their calls successfully.\r\n\r\n### CONCLUSION\r\nAdvice on how to go forward from here would be greatly appreciated.\r\nThanks in advance for your help. We stand ready to answer any of your questions should you have some.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! Thanks for the extremely detailed report. Very, very odd that `deinit` would get called without the `HTTPNetworkTransport` actually being deallocated - usually the telltale sign of a memory leak is that `deinit` never gets called at all. \r\n\r\nIs this only happening with background sessions, or is it also happening with normal sessions? Or are you using a background configuration for all sessions? \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi again!\r\n\r\nTo answer your question, we are using a background configuration for all sessions. As for normal sessions, we do see some memory leaks but they do not impede calls. Maybe the following will be useful.\r\n\r\nWe tried many configurations, mainly:\r\n- not using a URLSessionClient\r\n- using a URLSessionClient with a `.background` configuration and a callbackQueue `.main`\r\n- using a URLSessionClient with a `.background` configuration and a callbackQueue `.some`\r\n\r\nOnly the configuration of `.background` with a callbackQueue `.some` is suitable for us. Otherwise, some computations happen on the main thread when Apollo decodes our objects which brings the application to a crawl. (This is probably due to a specific situation in our code).\r\n\r\n### OUR TESTS\r\nHere are our results with those configurations in both instance setup and singleton setup. The main things we got out of it are that with an instance setup:\r\n- Calls do not come back if we provide a URLSessionClient\r\n- We always see URLSessionClients being kept in memory. In instruments, some are identified as leaks, some are not.\r\n\r\nWe hope this is clear and it did not confuse you to what's happening. As always, we are here if you need more info 😃.\r\n\r\nNo URLSessionClient\r\n---\r\n\r\n#### Instance\r\n✅ Calls come back\r\n✅ Does not retain objects holding ApolloClient instance in our code\r\n🛑 Retain orphaned UrlSessionClients and shows a leak in instruments\r\n\r\n#### Singleton\r\n✅ Calls come back\r\n✅ Does not retain objects holding ApolloClient instance in our code\r\n✅ Does not retain orphaned UrlSessionClients\r\n\r\n\r\nURLSessionClient with callback queue .main\r\n---\r\n\r\n#### Instance\r\n🛑 Calls do not come back\r\n🛑 Retains objects holding ApolloClient instance in our code\r\n🛑 Retains orphaned UrlSessionClients but does not show a leak in instruments\r\n\r\n#### Singleton\r\n✅ Calls come back\r\n✅ Does not retain objects holding ApolloClient instance in our code\r\n✅ Does not retain orphaned UrlSessionClients\r\n\r\n\r\nURLSessionClient with callback queue .some\r\n---\r\n\r\n#### Instance\r\n🛑 Calls do not come back\r\n🛑 Retains objects holding ApolloClient instance in our code\r\n🛑 Retains orphaned UrlSessionClients but does not show a leak in instruments\r\n\r\n#### Singleton\r\n✅ Calls come back\r\n✅ Does not retain objects holding ApolloClient instance in our code\r\n✅ Does not retain orphaned UrlSessionClients","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null}},{"__typename":"IssueComment","body":"I'm going to take a look deeper at this on Monday but one thing to be aware of is that there is no such thing as \"No `URLSessionClient` - a default one will be created for you if you're using `HTTPNetworkTransport`. It uses `.main` as its default queue, so I'm not sure what would be different between that and passing in your own. \r\n\r\nAdditionally: How are you setting up the instances? Is it possible that ARC is clobbering them because they are not properly retained somewhere and one of the assorted `weak self` calls winds up being nil? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks!\r\n\r\nFor the `URLSessionClient`, we figured that one was created on the Apollo framework side if not provided. Seeing the disparity in behaviour, we thought of sending you our observations on that as well. Maybe the difference between providing ours compared to the one by default is that we always put a `URLSessionConfiguration.background` instead of the `.default` one provided by Apollo.\r\n\r\nAs for how we retain instances, if you are talking about the `URLSessionClient`, we create it and give it to the `HTTPNetworkTransport`. It is all done in the same method and we do not retain either the `URLSessionClient` or the `HTTPNetworkTransport`. If you are talking about the `ApolloClient`, we tested swapping the `ApolloClient` for a mock that implements the same methods. We see no retain on our side.","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null}},{"__typename":"IssueComment","body":"So where do you retain the `ApolloClient` which you've handed the `HTTPNetworkTransport` to? Basically, I have a suspicion that the whole stack is getting hammered by ARC before the call returns if the instance is not being held onto somewhere. That would explain why in the `Instance` case listed above calls don't come back.\r\n\r\nAgain, if you have some sample code to share, that would be most helpful.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"The `ApolloClient` is retained by a **repo** object. When the object is instantiated it is injected with a new `ApolloClient` instance and uses it to make its calls.\r\n\r\nThe first time a user navigates to where a call is needed, we create a repo and start a call, it comes back correctly. The second time a user navigates to where a call is needed, we create a new repo and start a call, it never comes back. We keep those instances alive until they are not needed anymore or the user navigates away. In any case, when we create the second `ApolloClient` instance, nothing returns from the call even if held for over 10 minutes.\r\n\r\nI was able to confirm that calls not coming back happens if we provide a `URLSessionConfiguration` that is `.background`.\r\n\r\nAlso, sorry about the late notice but in debug environment, if we provide a `URLSessionConfiguration` that is `.background`, we often hit line 225 of the `URLSessionClient`:\r\n`assertionFailure(\"No data found for task \\(dataTask.taskIdentifier), cannot append received data\")`\r\n","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null}},{"__typename":"IssueComment","body":"I was able to replicate easily with the iOSTutorial project. What is the easiest way to send you that project amended to reproduce?","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null}},{"__typename":"IssueComment","body":"Email! ellen at apollographql dot com. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@EggYoke The sample you sent was very helpful, thank you. The underlying problem was a retain cycle as outlined in #1366. \r\n\r\nThe secondary problem is that you're attempting to create multiple background sessions with the same identifier at the same time, which the system won't let you do. I found that after the changes in #1366 were applied, I was able to get things to work with a background session by just using `UUID().uuidString` as the identifier, as this prevents any collisions in session name. \r\n\r\nHonestly, I wouldn't really recommend using background sessions for everything as it's kind of overkill, but if you need to for reasons I'm missing, that should at least unblock you.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"This has shipped with `0.31.0` - if you're still having issues with that version, please open a new issue and we'll try to figure it out. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thank you very much for the fast response.\r\nOur calls come back successfully and none of our objects are retained anymore.\r\nThis fixed all our issues, awesome job! 👍 ","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null}}]}},{"__typename":"Issue","title":"Cannot load underlying module for 'Apollo' for unit test target","author":{"__typename":"User","login":"dpatel-git","id":"MDQ6VXNlcjY4NDM2NTk1","name":null},"body":"Hello folks,\r\n\r\nI have following setup.\r\n\r\nXcode 11.3.1 (also tried on 11.6 without success)\r\nApollo 0.29.1\r\nCocoapods 1.9.2\r\n\r\nI am able to compile and run my application, but get the following error when I try to compile the unit test target\r\n\r\n```:0: error: cannot load underlying module for 'Apollo'```\r\n\r\nHere is how I have declared the app and test targets in podfile\r\n\r\n```\r\ntarget 'MyApp' do\r\n pod 'Apollo', Apollo\r\n target 'MyAppTests' do\r\n pod 'OHHTTPStubs', OHHTTPStubs\r\n end\r\nend\r\n```\r\nI have set `MyApp` as host application for the test target\r\n\r\nAny help is appreciated, thanks\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It looks like your `MyAppTests` is missing an `inherit! :search_paths`. See the 2nd example [in the Podfile docs](https://guides.cocoapods.org/using/the-podfile.html). ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks, that fixed the issue.","author":{"__typename":"User","login":"dpatel-git","id":"MDQ6VXNlcjY4NDM2NTk1","name":null}}]}},{"__typename":"Issue","title":"GraphQLQueryWatcher doesn't update its dependent keys","author":{"__typename":"User","login":"teodorpenkov","id":"MDQ6VXNlcjU2MjIyODg=","name":"Teodor Penkov"},"body":"With the `0.23.0` release Apollo changed the way it stores keys in the `QueryWatcher` https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/GraphQLQueryWatcher.swift#L73-L83\r\n\r\nThe problem with this is that the watcher doesn't update its `dependentKeys` like it should. There is a commit that does that but I couldn't follow why it was changed:\r\nhttps://github.com/apollographql/apollo-ios/commit/2b07e69e71a0621795b7089fda84c0ca744ba202\r\n\r\nThe problem that we are experiencing is that we are updating a query in the store with `ReadWriteTransaction` and in the previous versions the updated query captured the newly dependent keys, therefore when a change occured it was propagated to the result handler and now it's not.\r\n\r\nWhat's the reason behind this change and how can we workaround this? Was there a problem with the previous implementation in 0.22.0 https://github.com/apollographql/apollo-ios/blob/0.22.0/Sources/Apollo/GraphQLQueryWatcher.swift#L66-L68","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi, the commit you referenced was part of #1156 which went out with `0.28.0`, not `0.23.0`. You can see a detailed explanation of the bug in #1155. \r\n\r\nWhat version are you actually on right now? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"hey @designatednerd thanks for reaching out.\r\n\r\nI'm using `0.28.0` but I think the problem that I experience is on every version after `0.23.0`.\r\n\r\nOur use case is pagination using the Apollo cache.\r\nWe are doing one `main` query followed by 0 or more `fetch more` queries (based on page info and scroll events) each `fetch more` query updates the main one with its nodes and page info. We've been using this method for a while and it worked pretty well, the reason for that is that the \"main\" query was updating its dependent keys (the nodes from the fetch more queries) and after the commits I mentioned it stopped working.\r\n\r\nMutation values gets to the store correctly but after `didChangeKeys` gets called this results in a watcher's result handler being called with the old values rather than the updated values from the mutation.\r\n\r\nI will run through the commits and PR's that you mentioned and will try to figure out what the problem with the previous behavior was.","author":{"__typename":"User","login":"teodorpenkov","id":"MDQ6VXNlcjU2MjIyODg=","name":"Teodor Penkov"}},{"__typename":"IssueComment","body":"So I know some stuff changed around `0.22.0` that was the motivation for these changes that went out with `0.28.0`, but otherwise I'm not really seeing anything that changed. If you have any suggestions or a PR, I'm more than happy to try them out!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'd either suggest reverting to `0.22.0`'s implementation https://github.com/apollographql/apollo-ios/blob/0.22.0/Sources/Apollo/GraphQLQueryWatcher.swift#L66-L68\r\n\r\nor adding `self.dependentKeys = graphQLresult.dependentKeys` before this line https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/GraphQLQueryWatcher.swift#L79\r\n\r\nIf you don't see problem with that I'm happy to open a PR.","author":{"__typename":"User","login":"teodorpenkov","id":"MDQ6VXNlcjU2MjIyODg=","name":"Teodor Penkov"}},{"__typename":"IssueComment","body":"@designatednerd thanks for the links that you shared. I've checked them and I found the root cause of the problem.\r\n\r\n\"Screen\r\n\r\nI'm pretty sure that if we bring back those lines it wouldn't break anything.","author":{"__typename":"User","login":"teodorpenkov","id":"MDQ6VXNlcjU2MjIyODg=","name":"Teodor Penkov"}},{"__typename":"IssueComment","body":"Hi! Sorry, I was on vacation last week. \r\n\r\nI read [your explanation](https://github.com/apollographql/apollo-ios/pull/1156#discussion_r476476875) here and I think I get it. I'll take a look at this today or tomorrow and see what I can figure out. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Primary Maintainer Out Of Office August 23-30","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"},"body":"I will be taking a break in a place that (not coincidentally) has terrible internet connectivity the week of August 24th. \r\n\r\nKeep opening issues and PRs while I'm out, but please be aware that they will not be addressed until August 31st or thereafter. Thank you for your patience!","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I'm back! ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Ambiguous for type lookup in this context error","author":{"__typename":"User","login":"Shiaulis","id":"MDQ6VXNlcjEzNjAxNzQ4","name":"Andrius Shiaulis"},"body":"Hey hey! Another question from my side :) \r\nIn our backend response contains 2 data fields `userCompanies` and `userCompany` that share type. \r\n![image](https://user-images.githubusercontent.com/13601748/90987179-b81abc80-e591-11ea-9e96-ded615f5630e.png)\r\nThe problem is that code generation creates 2 totally equal structures:\r\n![image](https://user-images.githubusercontent.com/13601748/90987269-573fb400-e592-11ea-8292-1a365a37b737.png)\r\n\r\nIn documentation explorer in GraphiQL I don't see any issues:\r\n![image](https://user-images.githubusercontent.com/13601748/90987304-9837c880-e592-11ea-9f5f-af004aa50ca8.png)\r\n\r\nSo should I still look for a fix on backend side? Is there any way to explain that these data fields share type?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Im getting the exact same problem.\r\n\r\n```swift\r\npublic struct Author: GraphQLSelectionSet {\r\n public static let possibleTypes: [String] = [\"Staff\", \"Customer\"]\r\npublic struct Author: GraphQLSelectionSet {\r\n public static let possibleTypes: [String] = [\"ArticleAuthor\"]\r\n```","author":{"__typename":"User","login":"kylebrowning","id":"MDQ6VXNlcjExMzAyMw==","name":"Kyle Browning"}},{"__typename":"IssueComment","body":"Yeah - this is where the depluralization for type names we're using in the typescript codegen kind of falls apart. The workaround is to use field aliases:\r\n\r\n```graphql\r\nquery MyQuery {\r\n user {\r\n id\r\n userCompany: company // <-- alias\r\n userCompanies\r\n }\r\n}\r\n```\r\n\r\nThis way what's called `userCompany` on your server will be called `company` locally, making the type for that property `Company` and the type for `userCompanies` will be `UserCompany`. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd, thanks for the clarification 👍 ","author":{"__typename":"User","login":"Shiaulis","id":"MDQ6VXNlcjEzNjAxNzQ4","name":"Andrius Shiaulis"}},{"__typename":"IssueComment","body":"@Shiaulis did that work? If so, can we close this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Worked for us. ","author":{"__typename":"User","login":"kylebrowning","id":"MDQ6VXNlcjExMzAyMw==","name":"Kyle Browning"}},{"__typename":"IssueComment","body":"Thanks, let's close it","author":{"__typename":"User","login":"Shiaulis","id":"MDQ6VXNlcjEzNjAxNzQ4","name":"Andrius Shiaulis"}}]}},{"__typename":"Issue","title":"Error: Unable to read file › schema.json. ENOENT: no such file or directory, open 'schema.json'","author":{"__typename":"User","login":"fatma95","id":"MDQ6VXNlcjEyMTc1NDE3","name":"Fatma Mohamed"},"body":"I followed all the correct steps in the document, schema.json and graphql files are on the right places however I always get this error and build fails please help.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! So I'll need a bit more information to help diagnose this. Can you answer a few questions: \r\n\r\n- Have you confirmed that `schema.json` is downloaded and exists where you think it is on your filesystem? \r\n- Are you using the Swift Scripting wrapper or the shell script? \r\n- Can you paste a link to the set of instructions you are following? \r\n\r\nThank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi! I haven't heard back on this issue in over a week so I'm going to close it out - @fatma95 please reopen if you still need help, anyone else with a similar problem, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"No data found for task x, cannot append received data","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"},"body":"One of our tests hitting assert in `URLSessionClient.swift:230` in on CI after updating to latest version (0.31.0).\r\nIt's not networking stack test so don't think we doing anything specific to hit that assert. Looking at code that would indicate some kind race condition...","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Weird! Is it possible it's something leaking over from an older test? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"can't see anything relevant, also it don't happen every run","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"```swift\r\npublic func invalidate() {\r\n self.clearAllTasks()\r\n self.session?.invalidateAndCancel()\r\n self.session = nil\r\n }\r\n```\r\n\r\nshouldn't `self.session?.invalidateAndCancel()` be before `self.clearAllTasks()`? Will try change and see if our tests passes more reliably ","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"Hi! Yeah flipping the cleanup order likely wouldn't help since some tasks are still in-flight, I suspect I need to actually cancel all the in-flight tasks. Thanks for the heads up on this!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Haha damn it, looks like there's a key piece of info about `invalidateAndCancel` that's only in the docs docs and not in the headerdoc: \r\n\r\n\"Screen\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Shipped with version `0.32.1`!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi @designatednerd,\r\n\r\nI am encountering this issue in `0.33.0`, looking at #1383 I'm not quite certain it addressed the root issue given the shared `URLSession` isn't being used in `URLSessionClient`? I have a fairly reproducible case where this `invalidate` logic is getting hit but I'm still encountering this assertion error afterwards, confirmed with some debugging its definitely the same instance floating around. \r\n\r\nThat all said, it does seem that the issue is resolved by calling `invalidateAndCancel` prior to calling the `clear` block (as is currently done in the else branch). I've tested this quite a bit and have been unable to trigger the assertion failure anymore. I'll go ahead and open a PR for you to take a look, hopefully it helps!","author":{"__typename":"User","login":"philfi","id":"MDQ6VXNlcjM5NTY0NjE1","name":null}},{"__typename":"IssueComment","body":"Can confirm that it's not solved in 0.33.0. Just got assert while running tests on iOS12\r\n\r\n\"Screenshot\r\n","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"still happening in 0.36.0 (iOS12 simulator)","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}}]}},{"__typename":"Issue","title":"Crash at runtime when upgrading to 0.31.0 on URLSessionClient.swift, line 95","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"},"body":"Hey guys,\r\n\r\nSo I have an app that works perfectly with 0.30.0 but when upgrading to 0.31.0 I get a crash soon after the app launches:\r\n\r\n```\r\nFatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file /Users/XXX/Library/Developer/Xcode/DerivedData/XXX-bzyicfzsqzelixabxktyzmboxbaj/SourcePackages/checkouts/apollo-ios/Sources/Apollo/URLSessionClient.swift, line 95\r\n```\r\n\r\nThe issue is one this line :\r\n\r\n```\r\nlet task = self.session.dataTask(with: request)\r\n```\r\n\r\nhere `session` is nil.\r\n\r\nLet me know if you need anything else as I can reproduce the crash 100% of the time. Many thanks","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! That's awfully weird, since the session is instantiated in the initializer. Can you share the code you're using to create your client, as well as where in the app lifecycle that's happening? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Something that occurred to me is that in `0.31.0` we added a mechanism to make sure the `URLSession` is properly terminated so as not to create a retain cycle - you can probably throw a breakpoint in [here](https://github.com/apollographql/apollo-ios/blob/d95b4463f78a15fba7e3de2017817a391e9714f0/Sources/Apollo/URLSessionClient.swift#L63) to see if that's getting hit before you get to whatever's creating the data task.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey @designatednerd !\r\n\r\nFirst, thank you very much for answering so quickly, appreciate it :)\r\n\r\nI think your guess of adding a breakpoint into the `invalidate` method of `URLSessionClient` was a good idea. It turns out that when our app starts, we are initializing an `HTTPNetworkTransport` to use into a `SplitNetworkTransport` without any authentication, and when we authenticate (a few seconds after the app starts) we replace that `HTTPNetworkTransport` with a new one, simply by dereferencing the old one and keeping a pointer on a new `SplitNetworkTransport` that contains this new client.\r\n\r\nI think that what may happen is that the first client may have started some work in background, and when it gets destroyed this work hasn't finished, leading to this crash as the `session` is already nil. Could that be possible? ","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"That's possible - I've added some code in #1383 that should cancel any inflight operations on a `URLSessionClient` when `invalidate()` gets called, but I'm not sure if it'll address this crash since it's happening before the task is even added, which means `invalidate` has probably been called on a different thread.\r\n\r\nDefinitely sounds like a race condition is happening here - out of curiosity why are you fully replacing the client rather than using one of the delegate methods to handle authentication?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd Just tested, still crashing.\r\n\r\nI'm not 100% sure why we are replacing the client as I'm not the one who wrote that code, but as far as I understand it's because we are using `SplitNetworkTransport` and we are recreating the websocket so we need to also recreate the http client.","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"From here, I see a couple of workaround options: \r\n\r\n- Hanging on to the instance of `HTTPNetworkTransport` and using that when you have to recreate the web socket rather than creating a fully new transport\r\n- Taking a look at recent changes to the web socket transport, particularly around disconnecting and reconnecting, and seeing if any of those will prevent you from having to recreate. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I took the first option which works, so ok for me now but I guess you still have a race condition somewhere. Thank you very much for your help","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"Yeah for sure - I'm going to have to dig deeper into this but a lot of things are changing with the updated networking stack, so I'd like to get that out before digging back into this.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@benoitletondor We've just shipped something that will allow you to delay starting the websocket after initialization, which in theory should allow you to not have to replace the `SplitNetworkClient`. Do you mind pulling `0.36.0` and letting me know if that gets you to where you need to be? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey @designatednerd ,\r\n\r\nThank you for your help on that. Indeed, it would work for my use case as we can avoid starting the websocket until we have a proper authentication. As I said last time I already followed your advice of keeping the `HTTPNetworkTransport` instance so it's not really needed anymore on my side.\r\n\r\nThanks","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"@benoitletondor Do you mind if I close out this issue then? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Be my guest ;) ","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}}]}},{"__typename":"Issue","title":"ApolloCodegen.run does not throw error when validation of GraphQL query document fails","author":{"__typename":"User","login":"michaelxbarrett","id":"MDQ6VXNlcjMzODIyNjEz","name":null},"body":"From the tutorial:\r\n```\r\ndo {\r\n // Actually attempt to generate code.\r\n try ApolloCodegen.run(from: targetRootURL,\r\n with: cliFolderURL,\r\n options: codegenOptions)\r\n} catch {\r\n // This makes the error message in Xcode a lot more legible.\r\n exit(1)\r\n}\r\n```\r\n\r\nWhen there is an error in the query, the message `Validation of GraphQL query document failed` is logged and outputted to the console with a stacktrace, but no error is thrown in this case.\r\n\r\n\r\nStack trace:\r\n```\r\nValidation of GraphQL query document failed\r\n at Object.validateQueryDocument (Codegen/ApolloCLI/apollo/node_modules/apollo-language-server/lib/errors/validation.js:35:38)\r\n at Object.generate [as default] (Codegen/ApolloCLI/apollo/lib/generate.js:23:18)\r\n at write (Codegen/ApolloCLI/apollo/lib/commands/client/codegen.js:84:54)\r\n at Task.task (Codegen/ApolloCLI/apollo/lib/commands/client/codegen.js:104:46)\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"To clarify: Do you mean that the `exit(1)` is not called because no error is thrown from `run` itself, or that `exit(1)` does not constitute throwing an error? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Also, what version of the SDK are you using? I think there was an issue a couple versions back with our JS CLI where it wouldn't throw errors properly on failure, which should be resolved now.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@michaelxbarrett Were you able to address this by updating? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since I haven't heard back in 3 weeks, I'm going to close this out. @michaelxbarrett Please reopen if you're still experiencing problems. Anyone else with similar problems, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Query watcher not being called when cache is updated on an element of a collection that is added after calling watch","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"},"body":"Hi everyone,\r\n\r\nI've been trying a lot of things on that one and wasn't able to find a way to fix my problem. So in my app I'm having a list of conversations, so I'm creating a `watch` on a query that returns the list of conversations, this is something like that:\r\n\r\n```\r\nuser {\r\n uuid\r\n firstName\r\n lastName\r\n conversations {\r\n uuid\r\n unreadMessagesCount\r\n }\r\n}\r\n```\r\n\r\n> In the app we use the `uuid` key to handle cache, so we make sure to always pass `uuid` in our queries to automatically handle cache update.\r\n\r\nSo the role of the watcher I'm talking about is both to update existing conversations and also be able to catch when a new conversation is created (it can happen and not be initiated by the user, we then trigger an event from the backend that is listen from a subscription in the app). When this event happens it returns something like that\r\n\r\n```\r\nevent {\r\n newConversation {\r\n conversation {\r\n uuid\r\n unreadMessagesCount\r\n // This is the part that adds the new conversation to the existing ones of the users in the cache\r\n user {\r\n uuid\r\n conversations {\r\n uuid\r\n unreadMessagesCount\r\n }\r\n } \r\n }\r\n }\r\n}\r\n```\r\n\r\nIt works great, meaning that when this event happens, the watcher is being called with the newly created conversation, but the issue is that any new cache update for that specific conversation doesn't trigger the watcher again.\r\n\r\nAfter investigating a bit, I realised that the cache is being updated because if I'm adding 3 new messages into the new conversation (setting the `unreadMessagesCount` to 3), the watcher doesn't get called but then if I add 1 new message into an old one, the watcher is being called with both the new message on the old conversation and the 3 new on the new one. \r\n\r\nSo it really seems like `watch` is not being called again for changes on an item that wasn't in a collection when the `watch` was initially made. I've also take a look at https://github.com/apollographql/apollo-ios/issues/281 and making a `fetch` on the same query again after the event doesn't fix the issue.\r\n\r\nLet me know if I'm not clear on something as the whole thing is a bit complicated to explain.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! Can you take a look at v0.32.0 - I fixed something in query watchers in terms of updating dependent keys that I *think* should help with this. If it doesn't, let me know. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey @designatednerd \r\n\r\nSure, if #1377 is resolved too I will be able to test that tomorrow. If that's not the case I guess I won't be able","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"Hey @designatednerd \r\n\r\nI tested and I can confirm 0.32.0 fixes the issue, thank you very much for your help.","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"Reopening this one as the bug seems to be back with 0.34.0 :/ Let me know if you need help on my side","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"@designatednerd I haven't tested 0.33.0 so I'm not sure when the regression happened","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"That's odd, because the test added is passing - I actually spent quite a bit of time making it pass. 🙃 Do you mind opening a new issue with a link to this one since it's in a different version? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Sure","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}}]}},{"__typename":"Issue","title":"Availability of framework with Xcode 12 and iOS version 8","author":{"__typename":"User","login":"novinfard","id":"MDQ6VXNlcjYxMTYwNw==","name":"Soheil Novinfard"},"body":"Is it possible to use the framework with Xcode 12 and iOS version 8? Currently it asks me to upgrade to iOS version 9 with Xcode 12","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"iOS 9 is our minimum supported version regardless of Xcode version. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@novinfard Any further questions or do you mind if I close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Crash while checking graphQLResult with 0.32 and 0.32.1","author":{"__typename":"User","login":"jsm174","id":"MDQ6VXNlcjExOTcxMzc=","name":"Jason Millard"},"body":"Hello. Yesterday I upgraded to 0.32 and immediately started getting crashes anytime one of our services is checking a `graphQLResult`:\r\n\r\n```\r\ncase let .success(graphQLResult):\r\n```\r\n\r\nI downgraded to 0.31 and it started working again. I saw that 0.32.1 was released and figured I'd give it a try, but I'm seeing the same behavior.\r\n\r\nI know this isn't much to go on, but:\r\n\r\n![Screen Shot 2020-09-11 at 9 36 16 AM](https://user-images.githubusercontent.com/1197137/92932578-14476280-f413-11ea-9b8a-02df220cfcfd.png)\r\n\r\n(FWIW, that first preflight is just refreshing oauth tokens if necessary)\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"So, I apologize but I think it is working after all. \r\n\r\nI think maybe after I did a pod update, it never actually rebuilt apollo.\r\n\r\nI will close this. ","author":{"__typename":"User","login":"jsm174","id":"MDQ6VXNlcjExOTcxMzc=","name":"Jason Millard"}},{"__typename":"IssueComment","body":"No worries, that can definitely happen. Thanks for the update!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"codegen produces Swift code that doesn't compile","author":{"__typename":"User","login":"rlimberger","id":"MDQ6VXNlcjQ4NDEyNDI=","name":"Rene Limberger"},"body":"My scheme defines a GQL query named ```shipmentETAs``` and a type ```shipmentETA```. Codegen generates Swift code which incorrectly changes parts of the query and type name to lowercase. As a result, the Swift code generated by codegen doesn't compile.\r\n\r\nSchema:\r\n```\r\n {\r\n \"name\": \"shipmentETAs\",\r\n \"description\": \"\",\r\n \"args\": [\r\n {\r\n \"name\": \"params\",\r\n \"description\": \"\",\r\n \"type\": {\r\n \"kind\": \"NON_NULL\",\r\n \"name\": null,\r\n \"ofType\": {\r\n \"kind\": \"INPUT_OBJECT\",\r\n \"name\": \"QueryShipmentETAParams\",\r\n \"ofType\": null\r\n }\r\n },\r\n \"defaultValue\": null\r\n }\r\n ],\r\n \"type\": {\r\n \"kind\": \"NON_NULL\",\r\n \"name\": null,\r\n \"ofType\": {\r\n \"kind\": \"LIST\",\r\n \"name\": null,\r\n \"ofType\": {\r\n \"kind\": \"OBJECT\",\r\n \"name\": \"ShipmentETA\",\r\n \"ofType\": null\r\n }\r\n }\r\n },\r\n \"isDeprecated\": false,\r\n \"deprecationReason\": null\r\n }\r\n```\r\n\r\nResulting Swift code:\r\n```\r\n public var shipmentEtAs: [ShipmentEta?] {\r\n get {\r\n return (resultMap[\"shipmentETAs\"] as! [ResultMap?]).map { (value: ResultMap?) -> ShipmentEtA? in value.flatMap { (value: ResultMap) -> ShipmentEtA in ShipmentEtA(unsafeResultMap: value) } }\r\n }\r\n set {\r\n resultMap.updateValue(newValue.map { (value: ShipmentEtA?) -> ResultMap? in value.flatMap { (value: ShipmentEtA) -> ResultMap in value.resultMap } }, forKey: \"shipmentETAs\")\r\n }\r\n }\r\n\r\npublic struct ShipmentEta: GraphQLSelectionSet {\r\n...\r\n```\r\n\r\nCompiler error:\r\n`Cannot find type 'ShipmentEtA' in scope`\r\n\r\nSwift 5.3\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Urgh, this is one of the things I'm working on getting rid of with Swift Codegen - this is all handled under the hood in the Typescript codegen in a way that's really, really opaque. Unfortunately for now the only real way to work around it is to alias the name of the field to not have multiple uppercase characters in a row. \r\n\r\nI don't know your schema but here's a general stab at what I think an updated query would look like: \r\n\r\n```query\r\nquery ShipmentArrives($id: ID!) {\r\n shipment(id: $id) {\r\n id\r\n shipmentETA: shipmentEstimate\r\n }\r\n}\r\n```\r\n\r\nLet me know if that works!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks so much @designatednerd ! The alias worked! \r\n```\r\nquery ShipmentEstimates($siteId: ID!) {\r\n shipmentEstimates: shipmentETAs(params: {siteId: $siteId}) {\r\n ...\r\n }\r\n}\r\n```","author":{"__typename":"User","login":"rlimberger","id":"MDQ6VXNlcjQ4NDEyNDI=","name":"Rene Limberger"}},{"__typename":"IssueComment","body":"Woot! Mind if we close this out - I'm already tracking the casing stuff in other tickets. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Fix Apple Silicon on Xcode 12 GM","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"},"body":"Related to #1280. In testing for the Xcode 12 GM everything's working swimmingly via my Intel mac but the DTK is throwing fits that I can't seem to solve at the moment, mostly related to `unable to load standard library` issues. ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"OK well it turns out I am both less dumb than I originally thought for not being able to get this to work, _and_ dumber than I thought for not realizing I shouldn't download the GM on the DTK. \r\n\r\nThe Apple Silicon stuff was not included with the GM since that ships to the public, and AS stuff should still be using the beta track (still Xcode 12b6 for now, probably a 12.1 beta sometime soon). \r\n\r\nClosing this out since everything still works on the most recent version of Xcode to support Apple Silicon, 12.0b6. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Apollo 0.33.0 + Xcode 11.7. Use of unknown directive '#filePath'.","author":{"__typename":"User","login":"Hazeaze","id":"MDQ6VXNlcjgzNTE4NzQ=","name":null},"body":"Hi.\r\nI use SPM for the third-party libraries, updated Apollo from 0.32.1 to 0.33.0, and on the app build, I faced with the problem in the `FileFinder.swift`, where received an error `Use of unknown directive '#filePath'`.\r\n\r\n![image](https://user-images.githubusercontent.com/8351874/93308812-91fcdb00-f824-11ea-9050-275be2b39282.png)\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I got the same error","author":{"__typename":"User","login":"Parilar","id":"MDQ6VXNlcjgxNTk2NDY=","name":"Lars Hallek"}},{"__typename":"IssueComment","body":"`#filePath` is new in Swift 5.3, which ships with Xcode 12. You will need to use Xcode 12 for versions `0.33.0` and higher.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm going to close this out since this is intended behavior. Enjoy Xcode 12!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Exclude Apollo Playground from the main project file to make Carthage faster","author":{"__typename":"User","login":"manicmaniac","id":"MDQ6VXNlcjE2NzIzOTM=","name":"Ryosuke Ito"},"body":"Apollo Playground, which introduced in Apollo 0.33.0 as [a scheme in Apollo.xcoderpoj](https://github.com/apollographql/apollo-ios/blob/0.33.0/Apollo.xcodeproj/xcshareddata/xcschemes/Apollo%20Playground.xcscheme), makes Carthage build slower, and to make matters worse, building Apollo Playground fails in Xcode older than 12 (https://github.com/apollographql/apollo-ios/issues/1391).\r\n\r\nI guess most Apollo users don't want to build Apollo Playground at the time they install dependencies.\r\nHowever, Carthage doesn't provide a convenient way to exclude a specific scheme as discussed in https://github.com/Carthage/Carthage/issues/2529.\r\n\r\nSo to solve this problem, could you exclude Apollo Playground scheme from Apollo.xcodeproj and move it to another xcodeproj or another repo?\r\n\r\n```sh\r\n$ carthage bootstrap --platform iOS --no-use-binaries --cache-builds\r\n*** Checking out ApolloDeveloperKit at \"ce9fd3e1c75c074ae77632a8fe21be635219401b\"\r\n*** Checking out apollo-ios at \"0.33.0\"\r\n*** No cache found for apollo-ios, building with all downstream dependencies\r\n*** xcodebuild output can be found in /var/folders/tm/wy8sj46s6yq4rlfgsxyvd1l80000gn/T/carthage-xcodebuild.Plidos.log\r\n*** Building scheme \"Apollo\" in Apollo.xcodeproj\r\n*** Building scheme \"ApolloCore\" in Apollo.xcodeproj\r\n*** Building scheme \"Apollo Playground\" in Apollo.xcodeproj\r\nld Failed\r\n Task failed with exit code 65:\r\n /usr/bin/xcrun xcodebuild -project /Users/manicmaniac/Projects/manicmaniac/ApolloDeveloperKit/InstallTests/Carthage/Checkouts/apollo-ios/Apollo.xcodeproj -scheme Apollo\\ Playground -configuration Release -derivedDataPath /Users/manicmaniac/Library/Caches/org.carthage.CarthageKit/DerivedData/11.5_11E608c/apollo-ios/0.33.0 -sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/tm/wy8sj46s6yq4rlfgsxyvd1l80000gn/T/apollo-ios SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in /Users/manicmaniac/Projects/manicmaniac/ApolloDeveloperKit/InstallTests/Carthage/Checkouts/apollo-ios)\r\n\r\nThis usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/tm/wy8sj46s6yq4rlfgsxyvd1l80000gn/T/carthage-xcodebuild.Plidos.log\r\nmake: *** [carthage] Error 1\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Have you tried using the [`carthage-build-workaround` script outlined in the release notes?](https://github.com/apollographql/apollo-ios/releases/tag/0.33.0) There's some other nonsense going on with Carthage that I think may be causing the build failures rather than this scheme. \r\n\r\nAs for time reduction, the problem is that if that scheme isn't shared, the playgrounds won't build because it needs different sub-libraries than any of the other schemes. \r\n\r\nI can't for the life of me figure out why Carthage is so against excluding schemes. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> Have you tried using the carthage-build-workaround script outlined in the release notes?\r\n\r\nAh, my bad 😓 \r\nWith the workaround script and Xcode 12, I confirmed it works.\r\n\r\n```sh\r\n$ ./carthage-build-workaround.sh\r\n/tmp/static.xcconfig.hvN4SB\r\n*** Fetching apollo-ios\r\n*** Checking out apollo-ios at \"0.33.0\"\r\n*** xcodebuild output can be found in /var/folders/tm/wy8sj46s6yq4rlfgsxyvd1l80000gn/T/carthage-xcodebuild.6GUdYX.log\r\n*** Building scheme \"Apollo\" in Apollo.xcodeproj\r\n*** Building scheme \"ApolloCodegenLib\" in Apollo.xcodeproj\r\n*** Building scheme \"Apollo Playground\" in Apollo.xcodeproj\r\n*** Building scheme \"ApolloSQLite\" in Apollo.xcodeproj\r\n*** Building scheme \"ApolloCore\" in Apollo.xcodeproj\r\n*** Building scheme \"ApolloWebSocket\" in Apollo.xcodeproj\r\n```","author":{"__typename":"User","login":"manicmaniac","id":"MDQ6VXNlcjE2NzIzOTM=","name":"Ryosuke Ito"}},{"__typename":"IssueComment","body":"Cool - do you mind if we close this out with the answer as \"No\" for removing the `Apollo Playground` scheme? I understand it's inconvenient, but it's not inconvenient that often. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes, let me close this issue and thank you very much for your support 👍 ","author":{"__typename":"User","login":"manicmaniac","id":"MDQ6VXNlcjE2NzIzOTM=","name":"Ryosuke Ito"}}]}},{"__typename":"Issue","title":"Looking for recommendation for Pagination + Watching flow","author":{"__typename":"User","login":"bharath2020","id":"MDQ6VXNlcjkwMzUzNg==","name":null},"body":"_(Have this question [posted ](https://spectrum.chat/apollo/apollo-ios/looking-for-recommendation-to-perform-pagination-watch-in-ios-and-android-clients~a15afb8b-21fb-49a6-a80c-dd2ef097c8ad) in Spectrum chat as well, Adding here for better reach. Apologize for noise.)_\r\n\r\n# Problem\r\n\r\nWe have done some experiments in adopting pagination and encountered a few issues. I am looking for a recommendation on how to extract paginated results that do achieve two of my main goals. For the context, we have a mobile application that has screens that show paginated content that allows infinite vertical scrolling.\r\n\r\n1. Perform pagination in a responsible manner without any lag on the UI\r\n2. Ability to watch any changes to the items retrieved across all pages\r\n\r\nFor example, assume the following schema\r\n\r\n```\r\ntype PageResult {\r\n cursor: String\r\n hasMore: Bool\r\n items: [String]\r\n}\r\nquery {\r\n getItems(cursor: String): PageResult\r\n}\r\n```\r\n\r\nHere are the approaches we tried:\r\n\r\n## Approach 1: Follow the suggestion as per the [Apollo iOS tutorial blog](https://www.apollographql.com/docs/ios/tutorial/tutorial-pagination/)\r\n\r\n1. Load the first page with no cursor with cache policy that writes data back to the cache\r\n2. Load the second page with the cursor and follow the same for the next pages with cache policy that writes data back to the cache\r\n\r\n### Issues with Approach 1\r\n\r\n#### 1. Zombie records:\r\n\r\nFollowing the query path approach to generate cache key, the First page will be written under cache key \"QUERY\\_ROOT.getPage-cursor\", while subsequent pages will hold the items under the cache key \"QUERY\\_ROOT.getItems-cursor-page2cursor\", \"QUERY\\_ROOT.getItems-cursor-page3cursor\", and so on..\r\n\r\nIn our case, The page cursors are generated run time and only valid until the first page is refreshed again to get a new cursor. Following this approach, We notice that all the pages that were previously fetched will never be deleted after re-fetching the first page and hence get accumulated as the user fetches more pages and re-fetches leading to larger cache size over time. Not to mention the more number of records, the higher the read time.\r\n\r\n#### 2. Cannot watch updates to items from the second page onwards:\r\n\r\nWe want to set up a GraphQLQueryWatcher on the paginated query, such that any changes to the items, including items from all the pages retrieved so far. However, Looking at the implementation of the GraphQLQueryWatcher, it appears that with this approach, Watcher will notify only for the items returned from the first page since dependent keys for the watcher includes only keys from the first page.\r\n\r\n## Approach 2: Manually merge data from subsequent pages into the first page\r\n\r\nIn order to solve the Approach #1 Issue #2, We took inspiration from [Apollo react Pagination](https://www.apollographql.com/docs/react/data/pagination/#cursor-based) which does the following:\r\n\r\n1. Load the first page with no cursor with cache policy that writes data back to the cache\r\n2. Load the second page, and so on, with `fetchIgnoringCacheCompletely` cache policy and manually write the data into the First-page query.\r\n\r\n### Issues with Approach 2\r\n\r\n#### 1. Writes are slow\r\n\r\nAs we can notice in Step #2, we merge the previous page with data pulled from the next page and re-write the entire data back. As we fetch more pages, the write latency increases.\r\n\r\n#### 2 Latency of reading the first page exponentially increases\r\n\r\nSince we merge data from all pages into the first page, reading the first page exponentially increases based on the number of items present in the cache. This is more evident with queries that have an increasing number of attributes that are non-scalar data types in the query as the batch loader does round trip to the database for each attribute. With our sample of data, the read time for a query with medium complex schema has clocked 10 seconds to read 150 items on an iPhone XS device.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hey @bharath2020 - just a heads up that I'm bogged down at the moment but this is a *very* good question that I need to work on a better answer to (and that we should have a *way* better answer to overall for mobile), and I think messing around with the tutorial is probably a good place to start with it. And you are very correct that 10 seconds to read 150 items is 🤮. \r\n\r\nIn terms of what you can try while I'm digging out from under what I'm dealing with now, there's the `cacheKeyForObject` closure that you can use to generate a custom cache key. For most items you should be able to cache by ID, and that should avoid having to rewrite all the data if it's not necessary. \r\n\r\nI'm going to leave this open for the community to respond more - I know this has been done well, but my knowledge of details isn't there because I'm focused on other parts of the SDK at the moment. \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks, @designatednerd for the response.\r\n\r\n> For most items you should be able to cache by ID, and that should avoid having to rewrite all the data if it's not necessary.\r\n\r\nInteresting. In approach #2, Given that I am appending items from `morePage` back to `firstPage` and issuing a re-write of data for the first-page query, I am curious how would the store understand to not overwrite data referencing items in the first page? In other words, I understand `cacheKeyForObject` would reduce the number of records written to the database, but even with normalized cache, there would be unnecessary overwrites (in this case the items in the first page) that would add to the write latency. Please correct me If I am wrong.\r\n\r\nP.S. I have cacheKeyForObject enabled in my sample, and timings were taken after. The only part where I would not be able to generate a cache key is for the `PageResult` type, as `cacheKeyForObject` does not expose the variables (or field arguments) used to generate the type, in this case, it is the `cursor` provided for `getItems(cursor:)` query.","author":{"__typename":"User","login":"bharath2020","id":"MDQ6VXNlcjkwMzUzNg==","name":null}},{"__typename":"IssueComment","body":"Again, my knowledge of the cache is not as deep as it should be, but my understanding is you'd be rewriting the references with IDs rather than the entire object and its entire tree of changes. This almost certainly has some unnecessary work, but it would likely constitute a lot *less* unnecessary work than without the `cacheKeyForObject`. \r\n\r\nAnd again, this is not working as well as we want it to. We have some changes to the cache slated for [phases 2 and 3 of the ongoing Swift codegen rewrite](https://github.com/apollographql/apollo-ios/issues/939), and making things less annoying for pagination is one of the major things I want to do within that work. \r\n\r\nWish I had a better answer for you. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Got it. I played a little bit with batch reading objects from the database. I will give it a try to see if we can do the batch updates within a transaction. Right now, each roundtrip to the SQLite database is in its own transaction and I am guessing that is causing the reads to slow down. I have in the past read a huge number of items from SQLite and latency was fine.\r\n\r\nI will see if it makes any difference in the same and post it back.","author":{"__typename":"User","login":"bharath2020","id":"MDQ6VXNlcjkwMzUzNg==","name":null}},{"__typename":"IssueComment","body":"OK - do you mind if we close out this issue? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Ok","author":{"__typename":"User","login":"bharath2020","id":"MDQ6VXNlcjkwMzUzNg==","name":null}}]}},{"__typename":"Issue","title":"It expected a JSON schema introspection result, but got an HTML response instead.","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null},"body":"Hello,\r\n\r\nI am trying to run a script first time but i am receiving below error. \r\n\r\n**Unexpected token < in JSON at position 0\r\n Error: Apollo tried to introspect a running GraphQL service at \r\n http://10.10.10.10/graphql\r\n It expected a JSON schema introspection result, but got an HTML response \r\n instead.\r\n You may need to add headers to your request or adjust your endpoint url.**\r\n\r\nHere is my Script\r\n\r\n # Type a script or drag a script file from your workspace to insert its path.\r\n # Go to the build root and search up the chain to find the Derived Data Path where the source packages are checked out.\r\n DERIVED_DATA_CANDIDATE=\"${BUILD_ROOT}\"\r\n\r\n while ! [ -d \"${DERIVED_DATA_CANDIDATE}/SourcePackages\" ]; do\r\n if [ \"${DERIVED_DATA_CANDIDATE}\" = / ]; then\r\n echo >&2 \"error: Unable to locate SourcePackages directory from BUILD_ROOT: '${BUILD_ROOT}'\"\r\n exit 1\r\n fi\r\n\r\n DERIVED_DATA_CANDIDATE=\"$(dirname \"${DERIVED_DATA_CANDIDATE}\")\"\r\n done\r\n\r\n # Grab a reference to the directory where scripts are checked out\r\n SCRIPT_PATH=\"${DERIVED_DATA_CANDIDATE}/SourcePackages/checkouts/apollo-ios/scripts\"\r\n\r\n if [ -z \"${SCRIPT_PATH}\" ]; then\r\n echo >&2 \"error: Couldn't find the CLI script in your checked out SPM packages; make sure to add the framework to your project.\"\r\n exit 1\r\n fi\r\n\r\n #cd \"${SRCROOT}/${TARGET_NAME}\"\r\n #\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" API.swift\r\n\r\n SCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\n cd \"${SRCROOT}/${TARGET_NAME}\"\r\n \"${SCRIPT_PATH}\"/run-bundled-codegen.sh schema:download --endpoint=http:///graphql schema.json\r\n\r\nXCode Version : 11.3.1\r\nApollo : 0.24.1\r\nInstalled Apollo pod.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi, it looks like the endpoint hasn't had the `` placeholder replaced yet - the `http:///graphql` in your error message makes it look like that's just being stripped out entirely by the CLI. \r\n\r\nUnrelated to your immediate issue, I would strongly recommend running `schema:download` before running `codegen:generate` since codegen uses the result of downloading the schema. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"As of now i am trying to download schema.json from CLI with the following command.\r\n\r\n`apollo schema:download --endpoint=http:///graphql schema.json\r\n`\r\n\r\nBut still i am getting the same error. I didnt get placeholder (in your comment, can you please clarify)\r\n\r\nI have updated my question where i written down a dummy server url","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}},{"__typename":"IssueComment","body":"Hey I am able to download schema.json file from other public graphql url.\r\n\r\nBut now i am facing another error. I am using POD for apollo now.\r\n\r\nRun Script : \r\n\r\n`SCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\ncd \"${SRCROOT}/${TARGET_NAME}\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" API.swift\r\n`\r\n\r\nError :\r\n\r\nLoading Apollo Project [started]\r\nLoading Apollo Project [completed]\r\nGenerating query files [started]\r\nGenerating query files with 'swift' target [title changed]\r\nGenerating query files with 'swift' target [failed]\r\n→ Apollo does not support anonymous operations\r\n GraphQLError: Apollo does not support anonymous operations\r\nCommand PhaseScriptExecution failed with a nonzero exit code\r\n\r\n\r\nIf its not legal then can i raise new issue with this error and close this one","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}},{"__typename":"IssueComment","body":"You need to make sure you give your query a name - otherwise the codegen won't know what name to give the class containing the query. \r\n\r\nSo it has to look like this: \r\n\r\n```graphql\r\nFetchUser($id: ID!) {\r\n user(id: $id) {\r\n name\r\n [etc]\r\n }\r\n}\r\n```\r\n\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks.. this works.","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}},{"__typename":"IssueComment","body":"Hello, \r\n\r\nI am receiving this error right now.\r\n\r\nERROR : Received error response: Field \"country\" argument \"code\" of type \"ID!\" is required, but it was not provided.\r\n\r\nGraphQL : https://countries.trevorblades.com/graphql\r\n\r\nQuery : \r\n\r\n query AllCountry {\r\n country {\r\n name\r\n }\r\n }\r\n\r\niOS Swift Code : \r\n\r\n NetworkClient.sharedInstance().apollo.fetch(query: AllCountryQuery()) { result in\r\n \r\n switch result {\r\n case .success(let GraphQLResult) :\r\n print(GraphQLResult.data?.country as Any)\r\n \r\n \r\n \r\n case .failure(let error) :\r\n print(\"ERROR :\", error.localizedDescription)\r\n }\r\n }\r\n","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}},{"__typename":"IssueComment","body":"I think the error is telling you exactly what the problem is: `Field \"country\" argument \"code\" of type \"ID!\" is required, but it was not provided.` You need to make sure you're passing in a country code for this query.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Fixed. Thanks","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}}]}},{"__typename":"Issue","title":"Swift Package Manager + Xcode 12.0: Target 'arm64-apple-ios-simulator' missing","author":{"__typename":"User","login":"jzeisweiss","id":"MDQ6VXNlcjQyNjEyNTg=","name":"Jimmy Zeisweiss"},"body":"Hello,\r\n\r\nI can no longer use \"Preview\" for SwiftUI or build to a simulator due to the following error.:\r\n\r\n```\r\nerror: could not find module 'Apollo' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64\r\nimport Apollo\r\n```\r\n**Xcode Version**: 12.0 (12A7209)\r\n**Apollo Version**: 33.0\r\n\r\n_Note: I am having no problem building to a device._","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"@jzeisweiss Hi, what package manager are you using? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd - Hey Ellen, I am using Swift Package Manager.","author":{"__typename":"User","login":"jzeisweiss","id":"MDQ6VXNlcjQyNjEyNTg=","name":"Jimmy Zeisweiss"}},{"__typename":"IssueComment","body":"Are you using it on the Developer Transition Kit (I ask since it's looking for the `arm64-apple-ios-simulator` slice)? They took all the Apple Silicon stuff out of 12.0 and put it back in the 12.2 beta, so you'd need to use that if you are. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I am not using the Silicon ARM-Based prototype Mac from the Developer Transition Kit. I am using a 2018 Mac Mini and a 2018 MacBook Pro. However, I did find a workaround. I went in and changed the project settings to:\r\n\"Build Settings\" > \"Build Active Architecture Only\" > Set to \"YES\". This fixed my issue and I can now see the SwiftUI previews as well as build to simulators. Thank you for the speedy responses!\r\n\r\n**Source**: https://stackoverflow.com/questions/56957632/could-not-find-module-for-target-x86-64-apple-ios-simulator","author":{"__typename":"User","login":"jzeisweiss","id":"MDQ6VXNlcjQyNjEyNTg=","name":"Jimmy Zeisweiss"}},{"__typename":"IssueComment","body":"Ah yeah, that'll do it for sure - thank you for sharing your fix! Do you mind if we close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Networking Beta: Convenience constructors for HTTPRequest and JSONRequest","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"},"body":"In my use case i have to append to the `URLRequest.query` before a request is actually sent and that was fairly straight forward with the old network stack using `HTTPNetworkTransportPreflightDelegate.networkTransport(_:willSend:)` \r\n\r\nWith the new network stack things have gotten a bit more complex but i was able to come up with a solution involving a custom `ApolloInterceptor` that turns a given `JSONRequest` into a custom subclass which overrides `toURLRequest()`.\r\n\r\nSo to make implementation of custom HTTPRequests more easy i suggest you to add some convenience constructors for `HTTPRequest` and `JSONRequest` that take a single argument of their own type. This would let me get rid of this bunch of constructor arguments like this:\r\n\r\n```\r\n let customRequest = CustomJSONRequest(jsonRequest)\r\n```\r\n\r\ninstead of this:\r\n``` \r\n let customRequest = CustomJSONRequest(\r\n operation: jsonRequest.operation,\r\n graphQLEndpoint: jsonRequest.graphQLEndpoint,\r\n contextIdentifier: jsonRequest.contextIdentifier,\r\n clientName: jsonRequest.additionalHeaders[\"apollographql-client-name\"] ?? \"\",\r\n clientVersion: jsonRequest.additionalHeaders[\"apollographql-client-version\"] ?? \"\",\r\n additionalHeaders: jsonRequest.additionalHeaders,\r\n cachePolicy: jsonRequest.cachePolicy,\r\n autoPersistQueries: jsonRequest.autoPersistQueries,\r\n useGETForQueries: jsonRequest.useGETForQueries,\r\n useGETForPersistedQueryRetry: jsonRequest.useGETForPersistedQueryRetry,\r\n requestCreator: jsonRequest.requestCreator\r\n )\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"The override is the correct way of doing this - I'm not quite clear why the `super init`, which has a bunch of default parameters, isn't the way you're doing this, though. Can you go into a bit more detail on that? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"When looking for a way to get my `CustomHTTPRequest` with its overriden `toURLRequest()` into place i learned about the concept of `ApolloInterceptor` in the new network stack architecture.\r\n\r\nTherefore i have implemented a custom interceptor to replace the original `HTTPRequest` instance with one of `CustomHTTPRequest` as a substitution. Basically what i'm trying to do here is to create a copy of the request _with whatever particular values its properties have_ but extend its original functionality.\r\n\r\nIf there is something i have misunderstood or a better approach to achive this i'm glad to get enlighted.","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"}},{"__typename":"IssueComment","body":"OK! I think I see what the problem is here: While the `RequestChain` can take an arbitrary subclass of `HTTPRequest`, there's no way to say \"You should use this specific subclass\" from the level of the `RequestChainNetworkTransport`, so as of right now you're having to recreate the request at the interceptor level. \r\n\r\nIt sounds like the issue is that there needs to be a way to specify the request type that's customizable at that level, so that you can actually use the custom type you've created. \r\n\r\nDoes that sound accurate? I'm gonna poke at some ideas on this. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Indeed, if subclassing `HTTPRequest` is the intended way to go, a more simple way to place that type into the processing is greatly appreciated.","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"}},{"__typename":"IssueComment","body":"@knox Please see #1405 . You may have opened a trapdoor to a bigger change but it's a good one 😄 ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Wow i didn't mean to ask for moving mountains but opening `RequestChainNetworkTransport` and `constructRequest(for:cachePolicy:contextIdentifier:)` seems to perfectly fit my needs.","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"}},{"__typename":"IssueComment","body":"Haha, this worked as designed: You pointed out that I hadn't provided an access point to something, so I added it. Then by adding it I realized something else that was annoying me could change. 😇","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"With 0.34.0-rc.2 i was able to implement a clean and simple solution to my use case.","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"}}]}},{"__typename":"Issue","title":"Download Schema.json but server has CSRF Token protection","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null},"body":"Hello,\r\n\r\nI want to download a schema.json file but our server is protected with CSRF Token so which command i need to use to download a schema file and how can i send --header with CSRF token (From where i can get CSRF token means from our server guy or is apollo-client give/generate for downloading schema & passing in --header) ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! Please check out the instructions for [doing this in Bash](https://www.apollographql.com/docs/ios/downloading-schema/) and/or [doing this with the Swift Scripting tools](https://www.apollographql.com/docs/ios/swift-scripting/#downloading-a-schema). Do those docs answer your questions? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi! Since this is pretty clearly documented and I haven't heard anything back in a week, I'm going to close this out - @tapannathvani if you're still having problems please reopen. Anyone else having similar problems, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"is apollo provide internet check class?","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null},"body":"I am trying to check internet connection in my project.. and looking in apollo-ios library also like if you guys providing any reachability type class so without adding any other library or framework i can use your class to check connection\r\n\r\nIf yes then please provide documentation link and if not then please let me know how can i achieve this? and can i check internet connectivity in HTTPNetworkTransportPreflightDelegate (will send) method or in should send method? ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"We do not provide an internet check class, nor do we have plans to do so. \r\n\r\nIf you're using iOS 12 and above, the recommend way of doing things is [using `NWPathMonitor`](https://medium.com/@rwbutler/nwpathmonitor-the-new-reachability-de101a5a8835). If you're storing the most recent result from `NWPathMonitor` the preflight delegate would be a reasonable place to check it. \r\n\r\nPlease note that the Preflight delegate will be going away with `0.34.0` - you can check out the updated networking beta in #1386, and the PR has links to updated documentation. It would probably be fairly easy to add an interceptor that does that network check in the new networking stack. \r\n\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Can we know when can we have 0.34.0?","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}},{"__typename":"IssueComment","body":"Release candidate 2 is available now, gonna let it bake over the weekend and put it out monday night (US-Central time) if I don't hear any major showstoppers.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks for the quick response.","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}}]}},{"__typename":"Issue","title":"No such file or directory: run-bundled-codegen.sh","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null},"body":"I imported via cocoa pods the Apollo, actually it installed 0.30. \r\n\r\nI added exactly the same script as here:\r\nhttps://www.apollographql.com/docs/ios/installation/#troubleshooting \r\nschema.json is under project folder, under the target folder name.\r\nBut I keep receiving:\r\n![image](https://user-images.githubusercontent.com/6308120/94440933-75588f80-01a2-11eb-8095-c1d6862880b1.png)\r\nActually there is no data on SourcePackages folder about Apollo scripts.\r\n\r\nCould you help me?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi, it looks like you're using the Swift Package Manager run script rather than the CocoaPods run script [outlined in this step of the setup instructions](https://www.apollographql.com/docs/ios/installation/#adding-a-code-generation-build-step), because the CocoaPods script should be looking in `Pods/apollo-ios/scripts` rather than doing the weird dance of diving through derived data that the SPM script has to do.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"OMG!!! True. Wee can close the ticket!!!! ","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null}}]}},{"__typename":"Issue","title":"How to inject HTTP headers before fetching a query","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null},"body":"Do you know a mechanism to do that?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"This is covered in the [Advanced Client Creation](https://www.apollographql.com/docs/ios/initialization/) section of our docs. \r\n\r\nFair warning that this will be changing significantly very soon with the release of what's now in RC for #1386 (which I'm hoping to release tonight). The PR has a link to the updated docs for advanced client creation as well. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Error not parsed","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null},"body":"Hi,\r\n\r\nI have a GraphQL which is returning the following:\r\n![image](https://user-images.githubusercontent.com/6308120/94543867-da67c000-024a-11eb-803f-e76731c18064.png)\r\nBut the generated code is not parsing the error, but just giving data:\r\n![image](https://user-images.githubusercontent.com/6308120/94543972-fa977f00-024a-11eb-8689-7fa93a3d05f9.png)\r\nCould you help to identify how to get the errors?\r\n\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Weird - that does look like properly formatted JSON for the error - can you confirm what version of the SDK, Xcode, and Swift you're using here? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"SDK 0.33.0\r\nXcode 11.5 \r\nSwift 5","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null}},{"__typename":"IssueComment","body":"I've got no idea why that's not parsing the error - I put a test together and this is passing (different `\"data\"` key name since I'm using a local type for this test): \r\n\r\n```swift\r\nfunc testGH1415() throws {\r\n let json = \"\"\"\r\n{\r\n \"data\": {\r\n \"hero\": null\r\n },\r\n \"errors\": [\r\n {\r\n \"message\": \"Exception while fetching data (lastViewedProducts) : Customer not logged in\",\r\n \"locations\": [\r\n {\r\n \"line\": 2,\r\n \"column\": 3\r\n }\r\n ],\r\n \"path\": [\r\n \"lastViewedProducts\"\r\n ],\r\n \"extensions\": {}\r\n }\r\n ]\r\n}\r\n\"\"\"\r\n let data = try XCTUnwrap(json.data(using: .utf8),\r\n \"Couldn't create json data\")\r\n \r\n let deserialized = try JSONSerializationFormat.deserialize(data: data)\r\n let jsonObject = try XCTUnwrap(deserialized as? JSONObject)\r\n let response = GraphQLResponse(operation: HeroNameQuery(), body: jsonObject)\r\n \r\n let result = try response.parseResultFast()\r\n XCTAssertNil(result.data)\r\n XCTAssertNotNil(result.errors)\r\n \r\n let error = try XCTUnwrap(result.errors?.first)\r\n XCTAssertEqual(error.message, \"Exception while fetching data (lastViewedProducts) : Customer not logged in\")\r\n XCTAssertEqual(error.locations, [\r\n GraphQLError.Location(line: 2, column: 3),\r\n ])\r\n XCTAssertNotNil(error.extensions)\r\n}\r\n```","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Overwrite whole cache after fetch.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null},"body":"Hello again.\r\n\r\nMy application is trying to archive offline first mode.\r\nWe are using BigQuery to fetch all the data required for app to be usable and focus on offline cache mutations with custom made syc feature. \r\n\r\nThe problem is that after synchronization we are trying to refresh whole cache data. Some of our tasks can fail, most will be successful.\r\nTo avoid too much noise with cache handling, right after syc we are refetching BigQuery once again. \r\nAnd here is our problem. Mutations we performed in offline mode are still present, no matter the fact of success of failure during sync it is because backend is creating it's own unique ID's here and we are just generating UUID as a placeholder. The source of truth is server. So in case of BigQuery fetch I would like to totally teardown current cache and recreate it with BigQuery result.\r\n\r\nCalling clearCache before BigQuery seems to be a little bit risky. I mean there is a risk of loosing data if sth goes wrong with BigQuery.\r\n\r\nAny ideas how to handle?\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Oof, that's a tough one. This is part of why sync is so hard (and frankly why I have zero interest in handling it on our end). \r\n\r\nThe first thing that jumps to mind is making a second instance of whatever cache you're using, swapping in a store with that cache, and then putting the old one back if things fail. I won't say that won't be a giant pain, but off the top of my head that's at least something that will keep the old data in case your `BigQuery` fails. \r\n\r\nLike I said though, sync is really hard. I don't think there's going to be a simple, straightforward solution to this problem. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@pgawlowski Anything else I can help with here or do you mind if I close this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since I haven't heard back in a week, I'm going to close this out. @pgawlowski feel free to reopen if you have more questions - anyone else with similar problems, please open a separate issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Question about ApolloInterceptor","author":{"__typename":"User","login":"dchohfi","id":"MDQ6VXNlcjUwODYzNg==","name":"Diego Chohfi"},"body":"Hey, amazing rewrite of the http architecture, good naming and nice usage of open/close principles.\r\n\r\nJust one stuff, I'm not sure how many times the `interceptAsync` method gets called, as it receives both request and an option response, I think this will be called twice, I'm correct?\r\n\r\nIf this is correct, talking about an interceptor that adds authentication token to the request, might be better to check if we don't have the response yet? Should I only add the token if the response is nil?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Each interceptor is called once - they're called in sequence based on the order of the array passed in from the `InterceptorProvider`. So if you want to put a token in, you can probably just add the token adding interceptor to the beginning of that array. \r\n\r\nYou can see an example of this in the [updated tutorial here](https://www.apollographql.com/docs/ios/tutorial/tutorial-mutations/#add-authentication-handling).","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"So the interceptor isn't called before each request and after each response?","author":{"__typename":"User","login":"dchohfi","id":"MDQ6VXNlcjUwODYzNg==","name":"Diego Chohfi"}},{"__typename":"IssueComment","body":"Thank your for your response! Now I get it, sorry about that.","author":{"__typename":"User","login":"dchohfi","id":"MDQ6VXNlcjUwODYzNg==","name":"Diego Chohfi"}}]}},{"__typename":"Issue","title":"JSONRequest losing headers when useGETForQueries is true","author":{"__typename":"User","login":"dchohfi","id":"MDQ6VXNlcjUwODYzNg==","name":"Diego Chohfi"},"body":"## Bug report\r\n\r\nAfter migrating my project to the new version, I'm not able to use a service that has authentication via header.\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.0\r\n- Xcode version: 12.0.1\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nCreate an interceptor that adds a header to the request, the NetworkTransporter must have `useGETForQueries=true`.\r\n\r\n## Further details\r\n\r\nWhen the method `toURLRequest` gets called, the request gets recreated and all headers are lost, including the defaults added by apollo. After digging into the code, I found that the library is instantiating a new `URLRequest` instead of just changing the URL.\r\n\r\nhttps://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/JSONRequest.swift#L101","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I would love to send a PR to fix it, just want to confirm first if this is what is happening.","author":{"__typename":"User","login":"dchohfi","id":"MDQ6VXNlcjUwODYzNg==","name":"Diego Chohfi"}}]}},{"__typename":"Issue","title":"Massive API.swift file ","author":{"__typename":"User","login":"RomanTysiachnik","id":"MDQ6VXNlcjMxNjUyMjY1","name":"Roman Tysiachnik"},"body":"## Feature request\r\n\r\nGenerate each query, mutation, fragment and scalar type in a separate file.\r\n\r\n## Motivation\r\n\r\nWe use Apollo in production on a pretty large project.\r\nRight now our generated `API.swift` file is almost 10 Mb and it has 255,000+ lines of code.\r\nAfter we create a new query/mutation, the file may be overwritten completely, that it is impossible to understand anything in git. \r\nMoreover, Xcode freezes for about a minute when we try to open that single file.\r\n\r\n| Code | Git mess |\r\n| :--: | :--: | \r\n| \"Screen | \"Screen |\r\n\r\n\r\n## Proposed solution\r\n\r\nAs far as all requests and types are public classes, it shouldn't be hard to put each of them in a separate file.\r\nAll those files can also be sorted in folders to make it much easier to navigate through the API.\r\nAPI ->\r\n--Scalars ->\r\n----Upload.swift\r\n--Fragments ->\r\n----UserFragment.swift\r\n--Queries ->\r\n----UserQuery.swift ->\r\n--Mutations ->\r\n----CreateUserMutation.swift\r\n\r\n#### Benefits\r\n\r\n- Each request/type in a separate file and it is easy to navigate among them;\r\n- No freezes when you accidentally open an API file and it freezes Xcode for minutes.\r\n- Only new updates of the API in source control. \r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"If you provide a folder path instead of a file path to the generate command, it will do exactly this: a separate file for everything.","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"@TizianoCoroneo \r\n\r\nCould you share an example, please? ","author":{"__typename":"User","login":"RomanTysiachnik","id":"MDQ6VXNlcjMxNjUyMjY1","name":"Roman Tysiachnik"}},{"__typename":"IssueComment","body":"This is the script as is in [the docs](https://www.apollographql.com/docs/ios/installation/):\r\n```bash\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" API.swift\r\n```\r\n\r\nIf you make a folder named `API` just next to your `API.swift` file, and then remove the `.swift` extension from the last argument of the script, it should work:\r\n```bash\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" API/\r\n```","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"I'm using Swift scripting to generate API from this [doc](https://www.apollographql.com/docs/ios/swift-scripting/):\r\n```swift\r\nApolloCodegen.run(\r\n from: queriesURL,\r\n with: apolloCLIURL,\r\n options: Options.codegen\r\n )\r\n```\r\n\r\nAnd I couldn't find a way to get rid of that massive file.","author":{"__typename":"User","login":"RomanTysiachnik","id":"MDQ6VXNlcjMxNjUyMjY1","name":"Roman Tysiachnik"}},{"__typename":"IssueComment","body":"Ok. I guess I've managed how to handle that, there's another `init` that allows you to specify output format:\r\n\r\n```swift\r\nlet operationIDsURL = outputURL\r\n .appendingPathComponent(\"operationIDs.json\")\r\n\r\nlet schemaURL = outputURL\r\n .appendingPathComponent(\"schema.json\")\r\n\r\n ApolloCodegenOptions(\r\n codegenEngine: .default,\r\n operationIDsURL: operationIDsURL,\r\n outputFormat: .multipleFiles(inFolderAtURL: outputURL),\r\n urlToSchemaFile: schemaURL\r\n )\r\n```\r\n\r\nClosing the issue :) ","author":{"__typename":"User","login":"RomanTysiachnik","id":"MDQ6VXNlcjMxNjUyMjY1","name":"Roman Tysiachnik"}},{"__typename":"IssueComment","body":"So, I'm noticing we're getting massive differences in file sizes from the generated output depending on if we use the `apollo codegen:generate` command through the NPM installed CLI vs. the **SwiftCodegenLib**.\r\n\r\nLike... one of our files is almost 20mb from **SwiftCodegenLib** but 224kb from the NPM CLI.\r\n\r\nWhat could be causing such as massive difference?","author":{"__typename":"User","login":"Mordil","id":"MDQ6VXNlcjM1MDY3NzY=","name":"Nathan Harris"}},{"__typename":"IssueComment","body":"I just compared the commands, and it looks like the default `mergeInFieldsFromFragmentSpreads: true` is the source of the \"bloat\".\r\n\r\nWhat is the cost/benefit of having that set to `true`, as it is by default?","author":{"__typename":"User","login":"Mordil","id":"MDQ6VXNlcjM1MDY3NzY=","name":"Nathan Harris"}},{"__typename":"IssueComment","body":"I'm very surprised to hear it's causing that big a jump. `mergeInFieldsFromFragmentSpreads` ensures that fields in spreads (the `...BlahFragment` operator) are actually on the returned object. It basically is the difference between calling `object.propertyFromFragment` and `object.fragment.propertyFromFragment` on literally everything, which can get REAL old. \r\n\r\n@Mordil you've got my email, can you send me before/after of your API.swift so i can validate assumptions? \r\n\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"In our codebase adding the `mergeInFieldsFromFragmentSpreads` option causes 220k+ lines of code to appear, mostly:\r\n- getter/setters for each property in the fragment\r\n- memberwise initializers that are omitted if a type contains a fragment (I found this behavior quite surprising; I would prefer to always have `init`s for testing purposes)\r\n\r\n(I have to admit that we overuse fragments, and that's the main culprit.)\r\n\r\nMight be interesting to use [dynamic member lookup with keypaths](https://www.avanderlee.com/swift/dynamic-member-lookup/) to reduce code bloat, so that the enclosing type can refer dynamically to the properties of the enclosed fragment. I guess this road will be explored in the context of the new Swift Codegen though, right?","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"Yes. Also representing fragments as protocols means that you can have the properties straight on the object without duplication. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Query watcher not being called when cache is updated on an element by another query/subscription/mutation","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"},"body":"## Bug report\r\n\r\nQuery watcher not being called when cache is updated on an element of a collection that is added after calling watch\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.0\r\n- Xcode version: 12.0.1\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nI've been trying a lot of things on that one and wasn't able to find a way to fix my problem. So in my app I'm having a list of conversations, so I'm creating a `watch` on a query that returns the list of conversations, this is something like that:\r\n\r\n```\r\nuser {\r\n uuid\r\n firstName\r\n lastName\r\n conversations {\r\n uuid\r\n unreadMessagesCount\r\n }\r\n}\r\n```\r\n\r\n> In the app we use the `uuid` key to handle cache, so we make sure to always pass `uuid` in our queries to automatically handle cache update.\r\n\r\nSo the role of the watcher I'm talking about is both to update existing conversations and also be able to catch when a new conversation is created (it can happen and not be initiated by the user, we then trigger an event from the backend that is listen from a subscription in the app). When this event happens it returns something like that\r\n\r\n```\r\nevent {\r\n newConversation {\r\n conversation {\r\n uuid\r\n unreadMessagesCount\r\n // This is the part that adds the new conversation to the existing ones of the users in the cache\r\n user {\r\n uuid\r\n conversations {\r\n uuid\r\n unreadMessagesCount\r\n }\r\n } \r\n }\r\n }\r\n}\r\n```\r\n\r\nIt works great, meaning that when this event happens, the watcher is being called with the newly created conversation, but the issue is that any new cache update for that specific conversation doesn't trigger the watcher again.\r\n\r\nAfter investigating a bit, I realised that the cache is being updated because if I'm adding 3 new messages into the new conversation (setting the `unreadMessagesCount` to 3), the watcher doesn't get called but then if I add 1 new message into an old one, the watcher is being called with both the new message on the old conversation and the 3 new on the new one. \r\n\r\nSo it really seems like `watch` is not being called again for changes on an item that wasn't in a collection when the `watch` was initially made. I've also take a look at https://github.com/apollographql/apollo-ios/issues/281 and making a `fetch` on the same query again after the event doesn't fix the issue.\r\n\r\nLet me know if I'm not clear on something as the whole thing is a bit complicated to explain.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"To add more to this, I feel like this is not related to collections only. If you have 1 query that watches something, then another query/mutation updates this cache indirectly (not using the same query, but another query that contains the same element with the same `uuid`), it doesn't work.","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"Do you have any thoughts on why the test that was added would be passing, but what you're working with would not be working?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm afraid no, but all I can tell is that it works with 0.32.0 and not with 0.34.0","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"Hi @designatednerd,\r\n\r\nI think I have the same problem but not on a collection. My watcher is not triggered anymore since I have updated Apollo from 0.31.0 to 0.34.1. I have a watcher in cachePolicy .returnCacheDataAndFetch on this Query.\r\n\r\n```\r\nquery GetRide($rideId: ID!) {\r\n ride(id: $rideId) {\r\n ...EndRideFragment\r\n }\r\n}\r\n```\r\n\r\nAnd I have a mutation that updates my cache and normally triggers my watcher.\r\n```\r\nmutation StopRide($input: StopActiveRideInput!) {\r\n stopActiveRide(input: $input) {\r\n ride {\r\n ...EndRideFragment\r\n }\r\n }\r\n}\r\n```\r\nSince my Apollo pod upgrade, not working anymore. My watcher is not triggered when mutation payload updates my cache.","author":{"__typename":"User","login":"Narayane","id":"MDQ6VXNlcjQ5MjEzMDg=","name":"Sébastien BALARD"}},{"__typename":"IssueComment","body":"This is also occurring for me. 0.33.0 (non beta) worked; but not 0.34.0 or 0.34.1","author":{"__typename":"User","login":"dhritzkiv","id":"MDQ6VXNlcjEzNDk4NjU=","name":"Daniel Hritzkiv"}},{"__typename":"IssueComment","body":"@dhritzkiv That makes sense, the network stack and how it interacts with the cache changed completely in 0.34.0. \r\n\r\nApologies, I've been under the weather. I'm gonna do some digging starting tomorrow to try to figure out how I broke this without breaking the tests 🙃","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"No rush from me! I was able to roll back to 0.33.0 no problem","author":{"__typename":"User","login":"dhritzkiv","id":"MDQ6VXNlcjEzNDk4NjU=","name":"Daniel Hritzkiv"}},{"__typename":"IssueComment","body":"I can wait 1 week to have feedback from you @designatednerd on this issue.\r\nIf you need more time to investigate or to solve it, I could roll back to 0.33.0 to avoid blocking me in production","author":{"__typename":"User","login":"Narayane","id":"MDQ6VXNlcjQ5MjEzMDg=","name":"Sébastien BALARD"}},{"__typename":"IssueComment","body":"Same here, I rollbacked to 0.32.1 so no rush from me, and thanks for taking time investigating this!","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"I'm trying to reproduce this issue to investigate what could be going on, but it's been hard because unfortunately our tests aren't set up to run in real life conditions, where concurrency may play a role. The existing watcher tests all continue to pass, and so do some new ones I've been adding.\r\n\r\nIt would be helpful to learn more about the way people who experience this are using the framework, and what behavior they are seeing:\r\n- How are you initializing and configuring the client, cache, store and network transport?\r\n- Are you calling methods on `ApolloClient` from the main thread or from a background thread? Do you receive results on the main queue as well, or are you passing in a custom queue?\r\n- Does the issue occur 100% of the time, or only sometimes?\r\n- Are there other operations in flight when this happens, or does it also happen with just a single watcher and a single related query or mutation?\r\n- Anything else unusual or noticeable?\r\n\r\nI know this is a long shot, but it would be even more helpful if anyone was able to share a project that reliably exhibits this issue.","author":{"__typename":"User","login":"martijnwalraven","id":"MDQ6VXNlcjU0NDg1","name":"Martijn Walraven"}},{"__typename":"IssueComment","body":"A few more thoughts after taking a closer look at this:\r\n\r\n1) It seems any operations using the `WebSocketTransport` always ignore the cache completely starting in 0.33 (I believe https://github.com/apollographql/apollo-ios/commit/444c465671c786659599a16da4b2d23d43648a74 is where this change was introduced). That means subscription results are not actually published to the store, and thus will not trigger watchers. (@benoitletondor I think that would at least explain your initial bug report).\r\n\r\n2) That doesn't yet explain why queries and mutations would also fail to trigger watchers (assuming those are not using the `WebSocketTransport`). There is a possibility for misconfiguration however, which would lead to inadvertently having multiple stores (see https://github.com/apollographql/apollo-ios/issues/1438). Could some of you be bitten by this maybe?\r\n\r\n3) Using a custom `NetworkTransport` also currently ignores the cache completely (see https://github.com/apollographql/apollo-ios/pull/1442 for an in progress PR to work around this). Any chance this could explain the behavior some of you are seeing?","author":{"__typename":"User","login":"martijnwalraven","id":"MDQ6VXNlcjU0NDg1","name":"Martijn Walraven"}},{"__typename":"IssueComment","body":"I'm not using WebSocketTransport, but 3. sound like it could be what's plaguing us! Will have some time in two weeks to poke around that","author":{"__typename":"User","login":"dhritzkiv","id":"MDQ6VXNlcjEzNDk4NjU=","name":"Daniel Hritzkiv"}},{"__typename":"IssueComment","body":"@martijnwalraven I guess 3. could be an explanation in my case, I have a custom `NetworkTransport` implementation (http request headers additions, checks on http response)\r\n\r\n`public func send(operation: Operation, completionHandler: @escaping (_ result: Result, Error>) -> Void) -> Cancellable` in 0.33\r\n\r\nbecomes\r\n\r\n`public func send(operation: Operation, cachePolicy: CachePolicy, contextIdentifier: UUID?, callbackQueue: DispatchQueue, completionHandler: @escaping (Result, Error>) -> Void) -> Cancellable where Operation : GraphQLOperation` in 0.34\r\n\r\nI need to change\r\n```\r\ndo {\r\n let body = try self.serializationFormat.deserialize(data: data) as! JSONObject\r\n let response = GraphQLResponse(operation: operation, body: body)\r\n completionHandler(.success(response))\r\n} catch { }\r\n```\r\ninto\r\n```\r\ndo {\r\n let body = try self.serializationFormat.deserialize(data: data) as! JSONObject\r\n let response = GraphQLResponse(operation: operation, body: body)\r\n let result = try response.parseResultFast()\r\n completionHandler(.success(result))\r\n} catch { }\r\n```\r\nto try to conform my code to the new signature","author":{"__typename":"User","login":"Narayane","id":"MDQ6VXNlcjQ5MjEzMDg=","name":"Sébastien BALARD"}}]}},{"__typename":"Issue","title":"Why the response is not being triggered and no interceptors are dispatched?","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null},"body":"I'm building the client like this:\r\n![image](https://user-images.githubusercontent.com/6308120/94703838-90143b00-033f-11eb-8033-3f2727a09fbe.png)\r\nThis is my Interceptor Provider:\r\n![image](https://user-images.githubusercontent.com/6308120/94703879-9c989380-033f-11eb-8fab-ea802d571565.png)\r\nAnd this is an example of the query fetch:\r\n![image](https://user-images.githubusercontent.com/6308120/94703946-aae6af80-033f-11eb-93aa-b7670cb5c41d.png)\r\nIt is never stopping at result or at any interceptor, but console is dispatching:\r\n![image](https://user-images.githubusercontent.com/6308120/94704042-c81b7e00-033f-11eb-9ca7-ad9b833251b2.png)\r\n\r\nDo you have any idea what is wrong there?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"You are not actually including anything that calls the network, it looks like. You will need to include the `NetworkFetchInterceptor`, probably between request and response logging interceptors. \r\n\r\nI don't know why the response logging interceptor would be showing a 200 response when there's nothing that came through, because the request never went out to the network.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Obsolete type GraphQLHTTPResponseError","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"},"body":"## Bug report\r\n\r\nWith the new network stack (yeah!) a few types such as `GraphQLHTTPResponseError` became obsolte but did not get removed from code base yet.\r\n\r\n## Versions\r\n\r\n- `apollo-ios` SDK version: 0.34.0\r\n\r\n## Steps to reproduce\r\n\r\n\"Find usages\" of `GraphQLHTTPResponseError`, `GraphQLHTTPRequestError` and probably others.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"`GraphQLHTTPRequestError` is still used, but good catch on the response error. \r\n\r\nPlease note that \"find usages\" isn't the be-all, end-all, especially for enum types - always worth doing a text search through the full codebase. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"The problem here for me was that by not beeing broken because of a removed class my validations got semantically broken because they where still checking for that type.\r\n\r\nOf course you're right about `GraphQLHTTPRequestError`. I've mistaken that.\r\n\r\nBut still, regarding your advise to check for \"usages\" with full text search i have to strongly disagree. In fact i heavily rely on this kind of type based analysis and navigating through code and therefore i prefer AppCode over Xcode a lot because of it outstanding capabilities in that. You should give it a try.","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"}},{"__typename":"IssueComment","body":"I agree that it's helpful, but particularly when it comes to removing stuff, I've found it better to belt-and-suspenders things by actually searching out where something is used (even in AppCode, which I have used before). ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"This has been removed with `0.35.0`. If you find other unused types, please open a new issue. Thanks!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Enhance support for custom cache key resolver logic","author":{"__typename":"User","login":"qingqingliu","id":"MDQ6VXNlcjMzMDk3NjE=","name":null},"body":"## Feature request\r\n\r\nAdd similar support of [CacheKeyResolver](https://github.com/apollographql/apollo-android/blob/main/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheKeyResolver.kt) as from Android Apollo Client library. \r\n\r\n## Motivation\r\n\r\nCurrent iOS library provides cacheKeyForObject on ApolloClient that allows you to provide custom cache key for response, but there is no way for client app to provide custom cache key for request. This feature is needed in case client wants to use a different cache key for request\r\n\r\n## Proposed solution\r\n\r\nFollow Android pattern to introduce CacheKeyResolver on ApolloClient and support custom cache key for both response and request key.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"We're going to be looking in late 2020-early 2021 at getting our mobile caching more aligned, both across iOS and android and with our web cache, and this is one of the things I'll definitely be considering. \r\n\r\nI'm definitely open to discussion if you're interested in implementing this yourself.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks @designatednerd for the follow up. I see this is being part of bigger alignment between iOS and Android, I would probably wait for an overall proposal first. Happy to contribute though once the proposal is in place\r\n\r\nAs android side does seems have more feature supports like refetch, optimistic updates and custom cache key etc, wondering whether the direction for iOS would be following Android design pattern","author":{"__typename":"User","login":"qingqingliu","id":"MDQ6VXNlcjMzMDk3NjE=","name":null}},{"__typename":"IssueComment","body":"We're going to try to line up on what's best for both - the biggest issue right now is that iOS had a long period where no development took place (while Android was chugging along well with open-source contributions) and I'm still digging my way out of that hole. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Enum generation with `INIT` case","author":{"__typename":"User","login":"bezoadam","id":"MDQ6VXNlcjI1NjEzMTI1","name":"Adam Bezak"},"body":"## Bug report\r\n\r\nHi, enum is declared like this:\r\n![Snímka obrazovky 2020-10-01 o 8 26 56](https://user-images.githubusercontent.com/25613125/94775340-ede86780-03bf-11eb-9f4e-f9cb5bc9f5a0.png)\r\n\r\nand generated code throws these errors:\r\n![Snímka obrazovky 2020-10-01 o 8 27 08](https://user-images.githubusercontent.com/25613125/94775447-18d2bb80-03c0-11eb-9fe5-b6f6d12420ef.png)\r\n\r\nIt looks like there is problem with `INIT` case when using enum.\r\n\r\n## Versions\r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.0.1\r\n- Swift version: 5\r\n\r\n## Steps to reproduce\r\n\r\nGenerate code with `init` in enum case.\r\n\r\nIs it problem on my side or bug in apollo codegen. Any possible fixes?\r\nThanks.\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It's the codegen - it's not properly escaping the case named `init`, which is a reserved Swift keyword. Upcoming codegen should handle this better but it's gonna be a bit - is this schema already public or is it still being evolved? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Schema is partially public but I think there is not chance that there will be some changes. Anyway if I change `.init` to ``.init`` on lines where error is triggered, it disappears. But of course on next build code is regenerated. So I think this should be fixed in codegen.","author":{"__typename":"User","login":"bezoadam","id":"MDQ6VXNlcjI1NjEzMTI1","name":"Adam Bezak"}},{"__typename":"IssueComment","body":"Yeah, absolutely - fixing the current codegen is a pain (which is why it's being rewritten) so I was trying to make sure it was necessary before diving into it. 🙃","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thank you 👍 it is not necessary for me, I think i can handle it somehow (use temporary script to rename all `.init` cases to `\".init\"`)","author":{"__typename":"User","login":"bezoadam","id":"MDQ6VXNlcjI1NjEzMTI1","name":"Adam Bezak"}},{"__typename":"IssueComment","body":"You'd need to make it\r\n\r\n```swift\r\n`.init`\r\n```\r\n\r\n rather than `\".init\"`, but if you're ok with that, I'm very OK with not diving into typsecript hell 😇. If that's cool with you, mind if we close this one out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"When adding interceptors, they don't parse properly errors","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null},"body":"SDK 0.34.0\r\n\r\nI can fetch the data, response is received:\r\n![image](https://user-images.githubusercontent.com/6308120/94791351-cac9b200-03d7-11eb-9d99-78a0bacddbcf.png)\r\nBut when handling it:\r\n![image](https://user-images.githubusercontent.com/6308120/94791434-e92fad80-03d7-11eb-934b-7777241fbad7.png)\r\nIt is entering the failure, but with a totally separate error:\r\n![image](https://user-images.githubusercontent.com/6308120/94791471-f8166000-03d7-11eb-8e70-c9a48d108e87.png)\r\nActually, that error does not contain anything related to the errors data is receiving.\r\nEven with just the Network Interceptor:\r\n![image](https://user-images.githubusercontent.com/6308120/94791498-02d0f500-03d8-11eb-8877-bc49dd33a64e.png)\r\n\r\nCould you help there?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"If I use LegacyInterceptorProvider it does work","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null}},{"__typename":"IssueComment","body":"You don't have a parsing interceptor happening here, so the data is not being parsed by the time it gets to the end of the interceptor chain. The parsing isn't done by the chain itself, it's done by the individual interceptors.\r\n\r\nIf you're creating your own interceptor provider, you have to provide _all_ the interceptors that you're planning to use, including the ones that do the parsing. A good place to start is to copy the interceptors that are in `LegacyInterceptorProvider` and then add your custom interceptors to that array wherever you want them to execute. \r\n\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Is there anything else I can help with here, or can we close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"You can close it. Many thanks!\n\nEl mar., 6 oct. 2020 a las 0:43, Ellen Shapiro ()\nescribió:\n\n> Is there anything else I can help with here, or can we close this issue\n> out?\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly, view it on GitHub\n> ,\n> or unsubscribe\n> \n> .\n>\n\n\n-- \n*Jose Ángel Zamora Cobo*\nTelecommunication Engineer\nAndroid/iOS Senior Software Engineer\n\n","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null}}]}},{"__typename":"Issue","title":"Failed codegen when using GitHub GraphQL schema","author":{"__typename":"User","login":"mattia","id":"MDQ6VXNlcjExMTM4OA==","name":"Mattia Valzelli"},"body":"## Bug report\r\n\r\nWhile trying to use the [Swift scripting codegen tooling](https://www.apollographql.com/docs/ios/swift-scripting/) I was not able to generate the `API.swift` file given the corresponding schema file.\r\n\r\nAn error like this is generated \r\n\r\n> Field \"AcceptEnterpriseAdministratorInvitationInput.clientMutationId\" already exists in the schema. It cannot also be defined in this type extension.\r\n\r\n\r\nBut using the GraphQL verification tool available in the [same repo](https://github.com/octokit/graphql-schema) it passes. (running `npm start validate:ts`)\r\n\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.2 beta 2 (12B5025f)\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nSet up the project as described in the [Swift scripting guide](https://www.apollographql.com/docs/ios/swift-scripting/) and use the GitHub schema definition with the following files:\r\n - [schema.graphql](https://raw.githubusercontent.com/octokit/graphql-schema/master/schema.graphql)\r\n - [schema.json](https://raw.githubusercontent.com/octokit/graphql-schema/master/schema.json)\r\n\r\n## Further details\r\n\r\n
\r\n Example `main.swift`\r\n \r\n```swift\r\nimport ApolloCodegenLib\r\n\r\n// Grab the parent folder of this file on the filesystem\r\nlet parentFolderOfScriptFile = FileFinder.findParentFolder()\r\n\r\n// Use that to calculate the source root of both the\r\nlet sourceRootURL = parentFolderOfScriptFile\r\n .apollo.parentFolderURL() // Sources\r\n .apollo.parentFolderURL() // Codegen\r\n .apollo.parentFolderURL() // My Project\r\n\r\n// From the source root, figure out where your target\r\n// root is within your main project\r\nlet targetRootURL = sourceRootURL\r\n .apollo.childFolderURL(folderName: \"My Project\")\r\n\r\n// Set up the URL you want to use to download the project\r\nlet endpoint = URL(string: \"https://api.github.com/graphql\")!\r\n\r\n// Create an options object for downloading the schema\r\nlet schemaDownloadOptions = ApolloSchemaOptions(\r\n endpointURL: endpoint,\r\n headers: [\"Authorization: Bearer XXXXXXXXX\"],\r\n outputFolderURL: targetRootURL\r\n)\r\n\r\n// Calculate where you want to create the folder where the CLI will\r\n// be downloaded by the ApolloCodegenLib framework.\r\nlet cliFolderURL = sourceRootURL\r\n .apollo.childFolderURL(folderName: \"Codegen\")\r\n .apollo.childFolderURL(folderName: \"ApolloCLI\")\r\n\r\ndo {\r\n // Actually attempt to download the schema.\r\n try ApolloSchemaDownloader.run(with: cliFolderURL,\r\n options: schemaDownloadOptions)\r\n} catch {\r\n // This makes the error message in Xcode a lot more legible,\r\n // and prevents the script from continuing to try to generate\r\n // code if the schema download failed.\r\n exit(1)\r\n}\r\n\r\n// Create the default Codegen options object (assumes schema.json\r\n// is in the target root folder, all queries are in some kind\r\n// of subfolder of the target folder and will output as a\r\n// single file to API.swift in the target folder)\r\nlet codegenOptions = ApolloCodegenOptions(targetRootURL: targetRootURL)\r\n\r\ndo {\r\n // Actually attempt to generate code.\r\n try ApolloCodegen.run(from: targetRootURL,\r\n with: cliFolderURL,\r\n options: codegenOptions)\r\n} catch {\r\n // This makes the error message in Xcode a lot more legible.\r\n exit(1)\r\n}\r\n```\r\n
\r\n\r\nPlease let me know if I can help debug this. Also I am new to GraphQL, so I may be doing something wrong.\r\n\r\nThank you for this library!","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I've definitely seen this from the `.graphql` version of the GitHub schema before, but it looks from the code like you're downloading the JSON version of it. Can you please confirm that and attach a copy of the schema you're getting from GitHub so I can take a look? Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> I've definitely seen this from the `.graphql` version of the GitHub schema before, but it looks from the code like you're downloading the JSON version of it. Can you please confirm that and attach a copy of the schema you're getting from GitHub so I can take a look? Thank you!\r\n\r\nYes, of course. The schema I'm downloading is from the [octokit repo](https://github.com/octokit/graphql-schema).\r\nThe files are:\r\n - [schema.graphql](https://gist.github.com/mattia/d2cc50fdbfc1a90e58c4c35716677052)\r\n - [schema.json](https://gist.github.com/mattia/4545c6371577d3a7c7c17722bf7266f2).\r\n\r\nThank you and have a nice day!","author":{"__typename":"User","login":"mattia","id":"MDQ6VXNlcjExMTM4OA==","name":"Mattia Valzelli"}},{"__typename":"IssueComment","body":"OK looks like I had it backwards, it's the JSON that's giving the weird error and the SDL that seems to be working fine. If you update your schema download options to downloading SDL instead of the default JSON option, that should work: \r\n\r\n```swift\r\n// Create an options object for downloading the schema\r\nlet schemaDownloadOptions = ApolloSchemaOptions(\r\n schemaFileType: .schemaDefinitionLanguage,\r\n endpointURL: endpoint,\r\n headers: [\"Authorization: Bearer XXXXXXXXX\"],\r\n outputFolderURL: targetRootURL\r\n)\r\n```","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks for the reply. I've been real busy these days but I will try to come back to you in the next few days after trying your suggestion.\r\n\r\nThanks again! Have a nice day","author":{"__typename":"User","login":"mattia","id":"MDQ6VXNlcjExMTM4OA==","name":"Mattia Valzelli"}},{"__typename":"IssueComment","body":"OK cool - I'm going to close this issue out for now, please let us know if using the Schema Definition Language version of their schema doesn't work by reopening this issue. \r\n\r\nAnyone else having a similar problem, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Is it okay to git ignore API.swift?","author":{"__typename":"User","login":"prateek3255","id":"MDQ6VXNlcjIxMjc3MTc5","name":"Prateek Surana"},"body":"## Question\r\n\r\nSince API.swift is auto-generated, is it good practice to add it to `.gitignore`?\r\n\r\nWe tried adding it to `.gitignore` but whenever someone new clones the repo, the code fails to compile because of a broken reference to API.swift, and hence we have to manually pass it for the very first time.\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.32.1\r\n- Xcode version: 11.4\r\n- Swift version: 5.1","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"This is not a recommended practice - the exact problem you're having illustrates why this isn't a good idea. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Okay, thanks for the clarification","author":{"__typename":"User","login":"prateek3255","id":"MDQ6VXNlcjIxMjc3MTc5","name":"Prateek Surana"}}]}},{"__typename":"Issue","title":"Using a custom Date scalar","author":{"__typename":"User","login":"Renish-Development","id":"MDQ6VXNlcjQ3Njg0NzE5","name":"Renish_Development"},"body":"@cerupcat @jzhw0130: You should be able to pass `--passthrough-custom-scalars` to `apollo-codegen` to avoid generating a `typealias` to `String` for custom scalars. You can then add your own alias and conversion code, see [here](https://github.com/apollographql/apollo-ios/issues/23#issuecomment-261697349) for an example.\r\n\r\n_Originally posted by @martijnwalraven in https://github.com/apollographql/apollo-ios/issues/94#issuecomment-327287361_","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"How to use/implement Date type custom scalar in iOS?\r\n\r\nI'm working with GraphQL. I have successfully implement Query and Mutation in iOS app.\r\nI'm facing issue with Date Type. As per references, I have added --passthrough-custom-scalars in Run Script BUT I'm facing compilation issue.\r\n**I'm facing issue with \"--passthrough-custom-scalars\" variable. I have added below code in Run script but I'm facing an error.**\r\n\r\n```\r\nDERIVED_DATA_CANDIDATE=\"${BUILD_ROOT}\"\r\nwhile ! [ -d \"${DERIVED_DATA_CANDIDATE}/SourcePackages\" ]; do\r\nif [ \"${DERIVED_DATA_CANDIDATE}\" = / ]; then\r\necho >&2 \"error: Unable to locate SourcePackages directory from BUILD_ROOT: '${BUILD_ROOT}'\"\r\nexit 1\r\nfi\r\nDERIVED_DATA_CANDIDATE=\"$(dirname \"${DERIVED_DATA_CANDIDATE}\")\"\r\ndone\r\nSCRIPT_PATH=\"${DERIVED_DATA_CANDIDATE}/SourcePackages/checkouts/apollo-ios/scripts\"\r\nif [ -z \"${SCRIPT_PATH}\" ]; then\r\necho >&2 \"error: Couldn't find the CLI script in your checked out SPM packages; make sure to add the framework to your project.\"\r\nexit 1\r\nfi\r\ncd \"${SRCROOT}/${TARGET_NAME}\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./*/.graphql --localSchemaFile=\"schema.json\" API.swift\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh schema:download --endpoint=\"endpointURL\"\r\n#custom scalars\r\n**$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift --passthrough-custom-scalars**\r\n```\r\n\r\n**Code for Define Date Scalars**\r\n```swift\r\npublic typealias DateTime = Date\r\nextension DateTime: JSONDecodable, JSONEncodable {\r\n public init(jsonValue value: JSONValue) throws {\r\n guard let string = value as? String else {\r\n throw JSONDecodingError.couldNotConvert(value: value, to: String.self)\r\n }\r\n guard let date = ISO8601DateFormatter().date(from: string) else {\r\n throw JSONDecodingError.couldNotConvert(value: value, to: Date.self)\r\n }\r\n self = date\r\n }\r\n public var jsonValue: JSONValue {\r\n return ISO8601DateFormatter().string(from: self)\r\n }\r\n}\r\n```\r\n\r\n**I have reviewed schema JSON have a Date variable but API.swift still string type.**\r\nHere is my graphql mutation.\r\n```graphql\r\nmutation AddPeriod($uid:ID!, $start_time : Date!, $flow: PeriodFlowInput){\r\n addPeriod(uid:$uid, start_time : $start_time, flow: $flow){\r\n id\r\n start_time\r\n end_time\r\n flow {\r\n value\r\n flow_time\r\n }\r\n }\r\n}\r\n```\r\n\r\nHow can I pass date in GraphQL mutation. Please help me. Thanks in advance","author":{"__typename":"User","login":"Renish-Development","id":"MDQ6VXNlcjQ3Njg0NzE5","name":"Renish_Development"}},{"__typename":"IssueComment","body":"Hi @Renish-Development - I updated your comment to add some formatting. \r\n\r\nIt looks like your type is called `Date` rather than `DateTime`, which would mean I believe you need to have your typealias be:\r\n\r\n```swift\r\ntypealias Date = Swift.Date\r\n```\r\n\r\nAnd then have your extension be on `Date` rather than `DateTime`. Give that a shot, let me know how it goes.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd , \r\n\r\n**1. Swift Date is Not available. I'm using Xcode 12. Please look at the attached screen shot.**\r\n\r\n**2. I'm also facing issue with execute --passthrough-custom-scalars. Please let me know what I missed for custom scalars**\r\n\r\n**$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift --passthrough-custom-scalars**\r\n\r\n\"Screenshot\r\n","author":{"__typename":"User","login":"Renish-Development","id":"MDQ6VXNlcjQ3Njg0NzE5","name":"Renish_Development"}},{"__typename":"IssueComment","body":"Argh, I meant `Foundation.Date`. I always forget what's swift and what's foundation📈\r\n\r\nAnd `--output API.swift` has to be the last argument - move `--passthrough-custom-scalars` before that. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd , Its' not working. Please can I do any mistake or issue due to the updated version of Xcode 12. I'm using Xcode 12. Please check with your side and let me know it's work or not. Happy top share more information","author":{"__typename":"User","login":"Renish-Development","id":"MDQ6VXNlcjQ3Njg0NzE5","name":"Renish_Development"}},{"__typename":"IssueComment","body":"I did notice that the param is `--passthroughCustomScalars` rather than `--passthrough-custom-scalars` - that could be part of it. If that's not what's not working, please let me know in more detail what isn't working and in what way it is not working. Thanks. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi @Renish-Development is there anything more I can help with here or can we close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"You're far from the only person who's asked a ton of questions about this so I've added a page to our example playground to try and clarify this. Please see #1474 for further details","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd , Please add verify and step by step code or make tutorial as per latest version of GIT repo. Also I have not found proper documentation regarding custom scalar, pass token in API call, generate schema file with auth token and so on. I'm happy to help you anyway and if you can guide I will write tutorial for the same. Looking forward....","author":{"__typename":"User","login":"GlobesyncTechnologies","id":"MDQ6VXNlcjUzNDc1MDIx","name":"Renish | GlobeSync Technologies"}},{"__typename":"IssueComment","body":"@GlobesyncTechnologies Please see the PR I linked for an example of using a custom scalar. Please check out [our full tutorial](https://www.apollographql.com/docs/ios/tutorial) for full setup instructions. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Mismatched stores for ApolloClient/LegacyInterceptorProvider","author":{"__typename":"User","login":"danpalmer","id":"MDQ6VXNlcjIwMjQwMA==","name":"Dan Palmer"},"body":"## Bug report\r\n\r\nCaveat: this isn't quite a bug, perhaps more of a design bug, but we nearly shipped a bug in our app because of it. Also, I may just be missing things!\r\n\r\nThere are two ways to set up an `ApolloStore` for the networking in Apollo, and unless both are done, in the same way, I believe there can be inconsistencies.\r\n\r\nFor example, we previously did this in our `ApolloClient` setup:\r\n\r\n```swift\r\nlet networkTransport = HTTPNetworkTransport(url: baseURL)\r\nlet cache = InMemoryNormalizedCache()\r\nlet store = ApolloStore(cache: cache)\r\nlet client = ApolloClient(networkTransport: networkTransport, store: store)\r\n```\r\n\r\nWhen upgrading to the newest version of Apollo, we originally re-wrote this as:\r\n\r\n```swift\r\nlet provider = LegacyInterceptorProvider()\r\nlet networkTransport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: baseURL)\r\nlet cache = InMemoryNormalizedCache()\r\nlet store = ApolloStore(cache: cache)\r\nlet client = ApolloClient(networkTransport: networkTransport, store: store)\r\n```\r\n\r\nAs far as I can tell (please tell me if I'm wrong!) this has set up a store that is now not being used at all. We can still call `client.clearCache()` or `client.cacheKeyForObject` and it will use the store that we created, but this would _not_ affect the store being used by the interceptors.\r\n\r\nSimilarly, we could have configured a more complex cache setup, but that would not be used by the interceptors.\r\n\r\nIf we corrected this in the following way...\r\n\r\n```swift\r\nlet cache = InMemoryNormalizedCache()\r\nlet store = ApolloStore(cache: cache)\r\nlet provider = LegacyInterceptorProvider(store: store)\r\nlet networkTransport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: baseURL)\r\nlet client = ApolloClient(networkTransport: networkTransport)\r\n```\r\n\r\n...this would also introduce bugs because while our correct store is being used for the networking, `client.clearCache` or `client.cacheKeyForObject` are pointing to the `ApolloClient`'s default store from its init method.\r\n\r\n## Versions\r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.0\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nSee above for the process that can lead to incorrect use. This is roughly the steps that we took while upgrading Apollo to 0.34.x – i.e. we went through two invalid implementations before reaching one that we believe is valid.\r\n\r\n## Further details\r\n\r\nAs mentioned above, this isn't really a bug, but I think it's a design issue that could be improved. My recommendation would be to eliminate the store from the `ApolloClient` entirely, and leave it up to the user to coordinate the store with their interceptor provider. Potentially the store could become part of the interceptor provider protocol so that the client could still back `cacheKeyForObject`/`clearCache` onto the provider's store.\r\n\r\nAn alternative would be to eliminate the store from the interceptor provider, and ensure that in the client the store is set correctly on the provider so that they always line up.\r\n\r\nLastly, if maintaining backwards compatibility is key, the store from the provider and the store from the client could be compared at the end of the client initialiser, and an error raised if they are not exactly the same object.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Is there a particular using you're not passing in the `store` parameter for `client` on that last version? eg: \r\n\r\n```swift\r\nlet cache = InMemoryNormalizedCache()\r\nlet store = ApolloStore(cache: cache)\r\nlet provider = LegacyInterceptorProvider(store: store)\r\nlet networkTransport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: baseURL)\r\nlet client = ApolloClient(networkTransport: networkTransport, store: store)\r\n```\r\n\r\nThat would ensure you have the same store in all places. \r\n\r\nI do agree it's a little overcomplicated at the moment - I do plan to keep evolving this, and I appreciate the feedback.\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> Is there a particular using you're not passing in the store parameter for client on that last version? eg:\r\n\r\nNot particularly, but we did go through this stage on the way to our fully working version, which is pretty much what you have in your example. The fact that there were multiple opportunities for human error in getting to that working solution suggests there's a better design possible.\r\n\r\nIdeally these would be caught by the type system, or made un-representable, as I don't believe they are states of the system with valid use-cases.\r\n\r\nWould you accept a PR to address this? If so, what's your preferred approach out of those options I outlined, or is there another way you'd like to solve this?","author":{"__typename":"User","login":"danpalmer","id":"MDQ6VXNlcjIwMjQwMA==","name":"Dan Palmer"}},{"__typename":"IssueComment","body":"If you're not using a custom interceptor provider, the default initializer for `ApolloClient` initializes all this stuff for you - is that more what you're thinking? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> If you're not using a custom interceptor provider, the default initializer for ApolloClient initializes all this stuff for you - is that more what you're thinking?\r\n\r\nI think that route is safe.\r\n\r\nWe were transitioning from the legacy networking stack where we used `HTTPNetworkTransportPreflightDelegate` though. To maintain compatibility we decided to use `LegacyInterceptorProvider` and add an additional interceptor that did what our preflight delegate implementation had previously done, hence ending up with needing to pass the store into two different places, and this getting out of sync in two different ways before we realised the implicit dependency between those two places.\r\n\r\nAlso, just realised that the 3rd code example in the issue body is roughly what's in `Network.swift` in the docs here: https://www.apollographql.com/docs/ios/tutorial/tutorial-mutations/ – following the docs here will result in an invalid construction of the networking stack I think.\r\n\r\nHaving thought about this a bit more, I think there's a more common way this could also be done incorrectly:\r\n\r\n```swift\r\nlet provider = LegacyInterceptorProvider()\r\nlet networkTransport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: baseURL)\r\nlet client = ApolloClient(networkTransport: networkTransport, store: store)\r\n```\r\n\r\nIf not manually constructing a store at all, but instantiating a custom interceptor provider, there are two different stores being used and therefore it's impossible to clear the cache of the \"real\" one, but no error would be raised clearing the cache of the unused one.\r\n\r\nIt's possible I've missed somewhere that the stores get \"joined up\" – I'm new to Swift and don't know much about the Apollo codebase and may not understand the intention here. Apologies if that's the case!\r\n\r\n- - -\r\n\r\nI think there are 3 possible options here (although very open to more suggestions!):\r\n\r\n1. Eliminate the store from the ApolloClient entirely, leave it up to the user to coordinate the store with their interceptor provider. User will need to hold a reference to it for setting/getting the cache key, or clearing the cache.\r\n\r\n2. Eliminate the store from the interceptor provider init, have the client inject it into the interceptor provider. This way the user only has one place to pass it in, and if they don't the default one is still the same.\r\n\r\n3. If maintaining backwards compatibility is key, the store from the provider and the store from the client could be compared at the end of the client initialiser, and an error raised if they are not exactly the same object.\r\n\r\n","author":{"__typename":"User","login":"danpalmer","id":"MDQ6VXNlcjIwMjQwMA==","name":"Dan Palmer"}},{"__typename":"IssueComment","body":"Good catch on the example in the tutorial, that's definitely an error.\r\n\r\nThere are (rare) instances where someone intentionally wants to use different stores, but you're right that most of the time, that's not the case. \r\n\r\nI think of the options you propose, 2 probably makes the most sense. I'll try to see what I can do here. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> There are (rare) instances where someone intentionally wants to use different stores, but you're right that most of the time, that's not the case.\r\n\r\nInteresting! I'm not sure I quite understand what the use-case is for the client to have a different store to the interceptor provider? I can't see how that client store gets used apart from by the user... which means if I've understood correctly, it's not plugged in to the Apollo internals?","author":{"__typename":"User","login":"danpalmer","id":"MDQ6VXNlcjIwMjQwMA==","name":"Dan Palmer"}},{"__typename":"IssueComment","body":"basically there are some people who use multiple clients with multiple stores, and there are some...odd ways people make that work. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I've shipped the PR removing the default stores with `0.36.0` - I took a couple swipes at doing something else besides that, but everything I tried wound up *far* more complicated than \"actually make people select what store they're passing\". \r\n\r\nGoing to close this one out, please open a new issue if you think you've got a better suggestion!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Nice one! PRs look good. Straightforward approach sounds good – I can't see myself making the mistakes above if this was in place. Better API ergonomics can come later if they're needed at all.\r\n\r\nThanks for your work on this!","author":{"__typename":"User","login":"danpalmer","id":"MDQ6VXNlcjIwMjQwMA==","name":"Dan Palmer"}}]}},{"__typename":"Issue","title":"Can not find 'GenericScalar' in scope","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null},"body":"## Bug report\r\n\r\nBackend is JWT and when i'll try to execute a mutation for tokenVerification it gives me an error. We have Payload (Scalar Type) as response it in. I have added --passthroughCustomScalars in run script also.\r\n\r\n`SCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\ncd \"${SRCROOT}/${TARGET_NAME}\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" --passthroughCustomScalars API.swift\r\n`\r\n\r\n## Versions\r\n\r\n\r\n- `apollo-ios` SDK version: POD 0.34.0\r\n- Xcode version: XCode 12\r\n- Swift version: Swift 5\r\n\r\n## Steps to reproduce\r\n\r\nPlease add Scalar type response in mutation/query and try to build the project (first clear build folder)\r\n\r\n## Further details\r\n\r\nI have tried to do Type Conversion using this help : https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/JSONStandardTypeConversions.swift\r\n\r\nBut its not working as we are using swift 5 i think.\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! Can you clarify a bit: \r\n\r\n- What is the name of your custom scalar type, `Payload` or `GenericScalar`? \r\n- What is the underlying type of your custom scalar? It sounds like it's a string containing the JWT, I just want to double check\r\n- Have you tried using a `typealias` to define the scalar type? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@tapannathvani Hi, do you have answers to any of the questions I asked? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Closing this issue as i am not using Payload response data now.","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}}]}},{"__typename":"Issue","title":"Add example for direct writing to the cache","author":{"__typename":"User","login":"michael-mckenna","id":"MDQ6VXNlcjE0MDM1MTQ4","name":null},"body":"## Feature request\r\n\r\nAdd examples for writing directly to the cache, hopefully for all variants of the \"write\" function:\r\n```\r\ntransaction.write(object:withKey:)\r\ntransaction.write(data:forQuery:)\r\ntransaction.write(object:withKey:variables:)\r\n```\r\n\r\nLooks like only `read` and `update` are in the docs at the moment.\r\nhttps://github.com/apollographql/apollo-ios/blob/main/docs/source/caching.mdx#direct-cache-access\r\n\r\n## Motivation\r\n\r\nI'm new to GraphQL and using it for a side project has a learning experience. I don't want to get the whole server and datasource set up yet - would like to just do the iOS portion and have some sort of proof of concept going before pursuing it further. Because of this, I'm using the direct cache access exclusively for now. The extra examples in the readme will help me and future devs a lot. I come from using Realm and Core Data so this is quite a bit different for me.\r\n\r\n## Outstanding Questions\r\n\r\nIs there a sample app that utilizes direct cache access? If so, it'd be great to add a reference to that.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi, I can certainly add one, but I will say that the idea is that you avoid manually reading from or writing to the cache unless you absolutely have to, and let the store handle most of the nonsense around dealing with cache keys and things like that.\r\n\r\nIf it's your first time messing around with it and you just want to get an idea of how it works, I'd recommend checking out the app from the [Tutorial](https://www.apollographql.com/docs/ios/tutorial/), which uses a server that's already set up. You can then more easily inspect how things go into the in-memory cache or, if you want to, you can switch to using the SQLite cache and examine the SQLite database. \r\n\r\nThat will also allow you to have a base to mess around from if you are interested in seeing how the writing works if you need it.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd Just to clarify, it is still the expectation though that you should use manual cache updating after mutations / incoming subscriptions, correct? Recently I started to receive JSON `missingValue` errors in my cache updates and I'm not sure if it has anything to do with the major architectural changes that have been going on. ","author":{"__typename":"User","login":"Nickersoft","id":"MDQ6VXNlcjIxMDQxMjk=","name":"Tyler Nickerson"}},{"__typename":"IssueComment","body":"Subscriptions don't hit the cache at all at the moment - I wasn't part of that decision but it makes sense from a standpoint of \"This is constantly changing information, we don't necessarily want to cache all of it\", and also from a performance standpoint. So yes, that you'd need to do manually.\r\n\r\nMutation results can update the cache, though if you're not using a `cacheKeyForObject` function that says the cache key should be based on a unique identifier, you will need to update any related queries manually. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Can't update the RequestBodyCreator for WebSocketTransport","author":{"__typename":"User","login":"lowki93","id":"MDQ6VXNlcjU0NzMwMTc=","name":"budain"},"body":"## Bug report\r\n\r\nWe use `WebSocketTransport` and we need to override the `requestBodyCreator` parameters.\r\nWe define `CustomBodyCreator`:\r\n```\r\nstruct CustomBodyCreator: RequestBodyCreator {\r\n \r\n public func requestBody(\r\n for operation: Operation,\r\n sendOperationIdentifiers: Bool\r\n ) -> GraphQLMap {\r\n .....\r\n }\r\n \r\n}\r\n\r\n```\r\n\r\nwe put it when we initialize the `WebSocketTransport`: \r\n```\r\n WebSocketTransport(request: request, requestBodyCreator: CustomBodyCreator())\r\n```\r\n\r\nThe method call in `WebSocketTransport` don't use the method define in the procotol :\r\n```\r\n func sendHelper(operation: Operation, resultHandler: @escaping (_ result: Result) -> Void) -> String? {\r\n let body = requestBodyCreator.requestBody(for: operation, sendOperationIdentifiers: self.sendOperationIdentifiers)\r\n ....\r\n return sequenceNumber\r\n }\r\n```\r\nBut `requestBody` from our struct is never call.\r\n\r\nThere is a an extension for `RequestBodyCreator` that define the function in the protocol : \r\n```\r\nextension RequestBodyCreator {\r\n /// Creates a `GraphQLMap` out of the passed-in operation\r\n ///\r\n /// - Parameters:\r\n /// - operation: The operation to use\r\n /// - sendOperationIdentifiers: Whether or not to send operation identifiers. Defaults to false.\r\n /// - sendQueryDocument: Whether or not to send the full query document. Defaults to true.\r\n /// - autoPersistQuery: Whether to use auto-persisted query information. Defaults to false.\r\n /// - Returns: The created `GraphQLMap`\r\n public func requestBody(for operation: Operation,\r\n sendOperationIdentifiers: Bool = false,\r\n sendQueryDocument: Bool = true,\r\n autoPersistQuery: Bool = false) -> GraphQLMap {\r\n.....\r\n}\r\n```\r\n\r\nWhy can put this default implementation in `ApolloRequestBodyCreator` directly ?\r\n```\r\n// Helper struct to create requests independently of HTTP operations.\r\npublic struct ApolloRequestBodyCreator: RequestBodyCreator {\r\n // Internal init methods cannot be used in public methods\r\n public init() { }\r\n}\r\n```\r\n\r\nWhy we can't override this ?\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.0.1\r\n- Swift version: 5.2 \r\n\r\n## Further details\r\n\r\nWe need to override this to make `WebSocketTransport`with `AppSync`from AWS","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi, apologies for the delay, I was under the weather. \r\n\r\nYou can't override `ApolloRequestBodyCreator` because it's not intended to be overridden - that's why `RequestBodyCreator` is a protocol with a default implementation: That way your custom implementation can use the default implementation without having to implement it yourself if you don't need to. \r\n\r\nThat being said, there've been some changes to this class recently (mostly, removing all the stuff that was going on for uploads) that might make changes make sense. \r\n\r\nI'm not sure why your custom implementation wouldn't be getting called - I would double check that the request creator is being passed in everywhere you expect it to be by setting some breakpoints and validating whether you've got your `CustomRequestCreator` or an `ApolloRequestBodyCreator`, and then working backwards to try to figure out where things are going wrong. If it is the custom request creator, that's definitely a bug. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"OK updating a test, I am now seeing the issue you're having - looks like something I gave [literally an entire talk on](https://speakerdeck.com/designatednerd/protocols-all-the-way-down-dotswift-paris-january-2018?slide=63) just came to bite me because I have angered the gods of iOS development 🤦‍♀️ \r\n\r\nThe issue is the default implementation is getting called even if it's overridden when the only type the compiler knows about is the protocol itself. \r\n\r\nUnfortunately I think the approach in #1448 is going to break things too hard - it removes the ability for anyone to use the default implementation at all. I will make some changes with some tests to validate it works though. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"This has shipped with `0.35.0`. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Am running to this error `Cannot find 'HTTPNetworkTransport' in scope` and `Cannot find type 'HTTPNetworkTransportDelegate' in scope` when am trying to make calls, ApolloClient Version 0.34.1","author":{"__typename":"User","login":"gbrigens","id":"MDQ6VXNlcjQyMTAxNTY=","name":"Гералд Бирген"},"body":"Am running to this error `Cannot find 'HTTPNetworkTransport' in scope` and `Cannot find type 'HTTPNetworkTransportDelegate' in scope` when am trying to make calls, ApolloClient Version 0.34.1\r\n\r\nHere is my code;\r\n```\r\nfinal class Network {\r\n static let shared = Network()\r\n private lazy var networkTransport: NetworkTransport = {\r\n \r\n let transport = HTTPNetworkTransport(url: URL(string: \"https://exampe.com/grapghql\")!)\r\n transport.delegate = self\r\n \r\n return transport\r\n }()\r\n \r\n private(set) lazy var apollo = ApolloClient(networkTransport: self.networkTransport)\r\n}\r\n\r\nextension Network: HTTPNetworkTransportDelegate {\r\n func networkTransport(_ networkTransport: NetworkTransport, shouldSend request: URLRequest) -> Bool {\r\n return true\r\n }\r\n \r\n func networkTransport(_ networkTransport: NetworkTransport, willSend request: inout URLRequest) {\r\n \r\n let token = \"\"\r\n var headers = request.allHTTPHeaderFields ?? [String: String]()\r\n headers[\"Authorization\"] = \"Bearer \\(token)\"\r\n \r\n request.allHTTPHeaderFields = headers\r\n }\r\n}\r\n```\r\nI appreciate your feedback.\r\n\r\n_Originally posted by @gbrigens in https://github.com/apollographql/apollo-ios/issues/909#issuecomment-706535757_","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! In 0.34.0 after an RFC and multiple betas, we released an updated networking stack which removed these methods in favor of a `RequestChainNetworkTransport`. Please see the [0.34.0 release notes](https://github.com/apollographql/apollo-ios/releases/tag/0.34.0) for links to updated documentation.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd this is my first time working with Apolloclient and GraphQL. I have ted the one from the link still running into errors `Cannot find 'NetworkInterceptorProvider' in scope`... Do you have an example that shows passing authorization headers?","author":{"__typename":"User","login":"gbrigens","id":"MDQ6VXNlcjQyMTAxNTY=","name":"Гералд Бирген"}},{"__typename":"IssueComment","body":"Yes, the [tutorial bit on additional mutations](https://www.apollographql.com/docs/ios/tutorial/tutorial-mutations/) has an example","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd thank you for your help, hope in future there will be more tutorials on iOS. I have been searching for content online and there isn't much compared to Android.","author":{"__typename":"User","login":"gbrigens","id":"MDQ6VXNlcjQyMTAxNTY=","name":"Гералд Бирген"}},{"__typename":"IssueComment","body":"Yes, definitely in the long term plan to beef that up.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Cannot query field \"currencyTypes\" on type \"Query\".","author":{"__typename":"User","login":"Hazem-Mohammed","id":"MDQ6VXNlcjU1Mjk4MDg0","name":null},"body":"Hello all,\r\n\r\nThis is my first time to work with GraphQl and i have a very weird issue if i try to add any new query to my .graphql file i get error Cannot query field on type\r\ni faced this issue once and the solution was simply download the new schema file and it is work just fine now it doesn't work and if the Backend add any new query and i try to use it i get the same error even after update the schema file.\r\n\r\nnow i have the same issue again and i have tried almost everything:\r\n1- remove schema and download the new one.\r\n2- remove the (Generate Apollo GraphQL API) and add it again\r\n3- remove apollo SDK and reinstall it (cocoapods)\r\n4- update apollo SDK to the latest version\r\n5- make sure the schema have the new query's (works fine with the android)\r\n\r\n1- screenshot from Altair GraphQl Client:\r\n\"Screen\r\n\r\n\r\n2- screenshot from Xcode:\r\n\"Screen\r\n\"Screen\r\n\r\n3- screenshot from schema file this one show that the query is there.\r\n\"Screen\r\n\r\n4- screenshot from .graphql file:\r\n\"Screen\r\n\r\ni really don't know what is the issue here i have tried to clean project file , restart Xcode, restart Mac and the 5 steps mentioned above with no result and the same schema file work just fine with the android team.\r\n\r\nany help will be much appreciated \r\n- `apollo-ios` SDK version: 0.33.0\r\n- Xcode version: 11.6\r\n- Swift version: 5","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"finally i solved the issue.\r\ni was downloading the schema file from terminal using this command:\r\napollo schema:download --endpoint=https://myEndPoint schema.json\r\n\r\nthat was working with me in past but for some unknown reason using this command cause the problem\r\n\r\nThe solution:\r\nDownload schema using CLI script:\r\nSCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\ncd \"${SRCROOT}/${TARGET_NAME}\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh schema:download --endpoint=http://myEndPoint schema.json\r\n","author":{"__typename":"User","login":"Hazem-Mohammed","id":"MDQ6VXNlcjU1Mjk4MDg0","name":null}}]}},{"__typename":"Issue","title":"Crash in Alamofire","author":{"__typename":"User","login":"tspecht","id":"MDQ6VXNlcjYwMzE0NA==","name":null},"body":"## Bug report\r\n\r\nSince upgrading to the latest `0.34.0` release line with the revamped networking stack, we are seeing intermittent failures in conjunction with Alamofire. Is this a known issue?\r\n\r\n```\r\nCode Type: X86-64 (Native)\r\nParent Process: launchd_sim [2352]\r\nResponsible: SimulatorTrampoline [2256]\r\nUser ID: 501\r\n\r\nDate/Time: 2020-10-13 14:15:09.012 +0000\r\nOS Version: Mac OS X 10.15.5 (19F101)\r\nReport Version: 12\r\nAnonymous UUID: 4763FA26-E06C-409D-9FAC-0174438B0AC7\r\n\r\n\r\nTime Awake Since Boot: 2500 seconds\r\n\r\nSystem Integrity Protection: disabled\r\n\r\nCrashed Thread: 7 Dispatch queue: org.alamofire.session.rootQueue\r\n\r\nException Type: EXC_BAD_ACCESS (SIGSEGV)\r\nException Codes: KERN_INVALID_ADDRESS at 0x000027b7a55693a0\r\nException Note: EXC_CORPSE_NOTIFY\r\n\r\nTermination Signal: Segmentation fault: 11\r\nTermination Reason: Namespace SIGNAL, Code 0xb\r\nTerminating Process: exc handler [6910]\r\n\r\nVM Regions Near 0x27b7a55693a0:\r\n mapped file 000000011638b000-000000011caba000 [103.2M] r--/rwx SM=COW Object_id=254d583f\r\n--> \r\n MALLOC_NANO 0000600000000000-0000600008000000 [128.0M] rw-/rwx SM=ALI \r\n\r\nApplication Specific Information:\r\nCoreSimulator 704.12.2 - Device: iPhone 11 (********-****-****-****-************) - Runtime: iOS 13.7 (17H22) - DeviceType: iPhone 11\r\n\r\nThread 7 Crashed:: Dispatch queue: org.alamofire.session.rootQueue\r\n0 libobjc.A.dylib \t0x00007fff512b7c6a objc_retain + 10\r\n1 com.apple.Foundation \t0x00007fff259243bf NSKeyValueWillChange + 510\r\n2 com.apple.Foundation \t0x00007fff25923ff7 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 487\r\n3 com.apple.Foundation \t0x00007fff259249f2 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 68\r\n4 com.apple.Foundation \t0x00007fff2591f6da _NSSetLongLongValueAndNotify + 269\r\n5 com.apple.CFNetwork \t0x00007fff230f3bfc 0x7fff22f52000 + 1711100\r\n6 com.apple.Foundation \t0x00007fff2594f28c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7\r\n7 com.apple.Foundation \t0x00007fff2594f1ad -[NSBlockOperation main] + 80\r\n8 com.apple.Foundation \t0x00007fff259520dc __NSOPERATION_IS_INVOKING_MAIN__ + 17\r\n9 com.apple.Foundation \t0x00007fff2594e3ee -[NSOperation start] + 731\r\n10 com.apple.Foundation \t0x00007fff25952a20 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 17\r\n11 com.apple.Foundation \t0x00007fff25952540 __NSOQSchedule_f + 182\r\n12 libdispatch.dylib \t0x00007fff520e9344 _dispatch_block_async_invoke2 + 83\r\n13 libdispatch.dylib \t0x00007fff520dc8cb _dispatch_client_callout + 8\r\n14 libdispatch.dylib \t0x00007fff520e260c _dispatch_lane_serial_drain + 707\r\n15 libdispatch.dylib \t0x00007fff520e3044 _dispatch_lane_invoke + 388\r\n16 libdispatch.dylib \t0x00007fff520ed0c4 _dispatch_workloop_worker_thread + 626\r\n17 libsystem_pthread.dylib \t0x00007fff52301a3d _pthread_wqthread + 290\r\n18 libsystem_pthread.dylib \t0x00007fff52300b77 start_wqthread + 15\r\n```\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: `0.34.0`\r\n- Xcode version: 11.7 as well as 12.0\r\n- Swift version: 5.1 as well as 5.3\r\n\r\n## Steps to reproduce\r\n\r\nHappens intermittently, hard to come up with exact steps.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"That's a new one on me - under the hood we're using the same `URLSessionClient` that wraps `URLSession` as we were previously, so there shouldn't be anything messing with `URLSession` that wasn't already happening before. \r\n\r\nThe crash is happening on the Alamofire queue, but it looks like it's happening pretty deep within foundation when a block operation tries to change a value and it triggers KVO, and then something blows up. \r\n\r\nFew questions:\r\n- Have you seen this happen on device or just on sim? \r\n- Have you cleaned your build folder since this happened? \r\n- Did Alamofire also update versions or is it still an older version?\r\n- Are you using the apollo-alamofire wrapper (which is totally separate from this repo) or are you just using AF in parallel to what we're doing? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I see several people have 👍'd this - any further details from anyone would be helpful","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd we have been doing some more experiments on our end, the common denominator so far seems to be recent versions of Firebase. We opened a separate issue in their repository hoping to get some insights on that, would be helpful to know if any of the other users upvoting this here are also using Firebase in their projects. Wondering if there might be some method swizzling going on somewhere? 🤔 \r\n\r\nhttps://github.com/firebase/firebase-ios-sdk/issues/6734","author":{"__typename":"User","login":"tspecht","id":"MDQ6VXNlcjYwMzE0NA==","name":null}},{"__typename":"IssueComment","body":"Oh interesting - yes that definitely seems plausible. For what it's worth our codebase is entirely in Swift, which doesn't completely prevent us from using swizzling but does make it way more of a pain. Either way, we do not use any swizzling. \r\n\r\nFor others running into this issue, are you also using Firebase? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I am also using Firebase","author":{"__typename":"User","login":"ethan021021","id":"MDQ6VXNlcjE1MzI5NjU4","name":"Ethan"}},{"__typename":"IssueComment","body":"OK - since the stack trace doesn't show anything from the Apollo API, we're not doing any swizzling that could cause the crashes in the stack trace, and there seems to be an issue with the Firebase SDK and other people having this issue seem to also be using Firebase, I'm going to close this issue and direct folks to the [Firebase issue where this is being discussed in significantly more detail](https://github.com/firebase/firebase-ios-sdk/issues/6734). \r\n\r\nThanks all for the heads up on this!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"run-bundled-codegen.sh: No such file or directory","author":{"__typename":"User","login":"mobile-simformsolutions","id":"MDQ6VXNlcjYzMjI1OTEz","name":null},"body":"## run-bundled-codegen.sh: No such file or directory\r\n\r\ni'm implementing this demo as per the documentation (https://www.apollographql.com/docs/ios/tutorial/tutorial-obtain-schema) but after adding script into build phase it will showing me this error:\r\n\r\n**Command PhaseScriptExecution failed with a nonzero exit code**\r\n**Script-3E447D9625386A88004AD507.sh: line 10: /run-bundled-codegen.sh: No such file or directory\r\nCommand PhaseScriptExecution failed with a nonzero exit code**\r\n\r\n![Screenshot 2020-10-16 at 10 32 30 AM](https://user-images.githubusercontent.com/63225913/96215184-e8337a00-0f9a-11eb-8a38-b02591340731.png)\r\n\r\n## Versions\r\n0.34.1\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.0.1\r\n- Swift version: 5","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It looks like you may have skipped step 6, in which you add the build script where the script path is retrieved. It links to [these instructions](https://www.apollographql.com/docs/ios/installation/#adding-a-code-generation-build-step) which are separated out by package manager. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"got it thanks but one suggestion for documentation please make one section where whole script was there.","author":{"__typename":"User","login":"mobile-simformsolutions","id":"MDQ6VXNlcjYzMjI1OTEz","name":null}},{"__typename":"IssueComment","body":"Appreciate the feedback - for what it's worth the reason it's linked is because those instructions had been changing enough that having it in two places meant that it was going to constantly get out of sync. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Help wanted migrating to new Networking stack","author":{"__typename":"User","login":"taher-mosbah","id":"MDQ6VXNlcjIzMDAwODc=","name":"Mohamed Taher Mosbah"},"body":"## Question\r\nGreetings 👋 \r\n\r\nWe are trying to update our custom implementation of a `NetworkTransport` to the new networking stack in version 0.34 but can't seem to figure out where to start, we took a look at the release notes and the documentation `RequestChainNetworkTransport` seems promising but can't figure out how to achieve the same results.\r\n\r\nHere is the current implementation:\r\n\r\n```\r\nimport Foundation\r\nimport Apollo\r\n\r\n/// A network transport that uses HTTP POST requests to send GraphQL operations to a server, and that uses `URLSession` as the networking implementation.\r\npublic class ApolloHTTPGETNetworkTransport: NetworkTransport {\r\n public enum NetworkError: Swift.Error {\r\n case invalidURLComponents\r\n }\r\n\r\n let url: URL\r\n let session: URLSession\r\n let serializationFormat = JSONSerializationFormat.self\r\n let jsonEncoder = JSONEncoder()\r\n\r\n /// Creates a network transport with the specified server URL and session configuration.\r\n ///\r\n /// - Parameters:\r\n /// - url: The URL of a GraphQL server to connect to.\r\n /// - configuration: A session configuration used to configure the session. Defaults to `URLSessionConfiguration.default`.\r\n /// - sendOperationIdentifiers: Whether to send operation identifiers rather than full operation text, for use with servers that support query persistence. Defaults to false.\r\n public init(url: URL, configuration: URLSessionConfiguration = URLSessionConfiguration.default, sendOperationIdentifiers: Bool = false) {\r\n self.url = url\r\n self.session = URLSession(configuration: configuration)\r\n self.sendOperationIdentifiers = sendOperationIdentifiers\r\n }\r\n\r\n /// Send a GraphQL operation to a server and return a response.\r\n ///\r\n /// - Parameters:\r\n /// - operation: The operation to send.\r\n /// - completionHandler: A closure to call when a request completes.\r\n /// - response: The response received from the server, or `nil` if an error occurred.\r\n /// - error: An error that indicates why a request failed, or `nil` if the request was successful.\r\n /// - Returns: An object that can be used to cancel an in progress request.\r\n public func send(operation: Operation, completionHandler: @escaping (Result, Error>) -> Void) -> Cancellable where Operation: GraphQLOperation {\r\n let query = requestBody(for: operation)\r\n guard var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else {\r\n completionHandler(.failure(NetworkError.invalidURLComponents))\r\n return EmptyCancellable()\r\n }\r\n urlComponents.queryItems = query.compactMap { queryMapItem -> URLQueryItem? in\r\n guard let queryMapItemValue = queryMapItem.value else { return nil }\r\n if let queryMapItemValue = queryMapItemValue as? JSONObject {\r\n guard let queryItemValue = ((try? String(data: JSONSerializationFormat.serialize(value: queryMapItemValue), encoding: .utf8)) as String??) else { return nil }\r\n return URLQueryItem(name: queryMapItem.key, value: queryItemValue)\r\n }\r\n if let queryMapItemValue = queryMapItemValue as? String {\r\n return URLQueryItem(name: queryMapItem.key, value: queryMapItemValue)\r\n }\r\n return nil\r\n }\r\n\r\n var request = URLRequest(url: url)\r\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\r\n request.httpMethod = \"GET\"\r\n request.url = urlComponents.url\r\n let task = session.dataTask(with: request) { (data: Data?, response: URLResponse?, error: Swift.Error?) in\r\n if let error = error {\r\n completionHandler(.failure(error))\r\n return\r\n }\r\n\r\n guard let httpResponse = response as? HTTPURLResponse else {\r\n fatalError(\"Response should be an HTTPURLResponse\")\r\n }\r\n\r\n if !httpResponse.isSuccessful {\r\n completionHandler(.failure(GraphQLHTTPResponseError(body: data, response: httpResponse, kind: .errorResponse)))\r\n return\r\n }\r\n\r\n guard let data = data else {\r\n completionHandler(.failure(GraphQLHTTPResponseError(body: nil, response: httpResponse, kind: .invalidResponse)))\r\n return\r\n }\r\n\r\n do {\r\n guard let body = try self.serializationFormat.deserialize(data: data) as? JSONObject else {\r\n throw GraphQLHTTPResponseError(body: data, response: httpResponse, kind: .invalidResponse)\r\n }\r\n let response = GraphQLResponse(operation: operation, body: body)\r\n completionHandler(.success(response))\r\n } catch {\r\n completionHandler(.failure(error))\r\n }\r\n }\r\n\r\n task.resume()\r\n\r\n return task\r\n }\r\n\r\n private let sendOperationIdentifiers: Bool\r\n\r\n private func requestBody(for operation: Operation) -> GraphQLMap {\r\n if sendOperationIdentifiers {\r\n guard let operationIdentifier = operation.operationIdentifier else {\r\n preconditionFailure(\"To send operation identifiers, Apollo types must be generated with operationIdentifiers\")\r\n }\r\n return [\"id\": operationIdentifier, \"variables\": operation.variables]\r\n }\r\n return [\"query\": operation.queryDocument, \"variables\": operation.variables]\r\n }\r\n}\r\n\r\nfileprivate extension HTTPURLResponse {\r\n var isSuccessful: Bool {\r\n return (200..<300).contains(statusCode)\r\n }\r\n\r\n var statusCodeDescription: String {\r\n return HTTPURLResponse.localizedString(forStatusCode: statusCode)\r\n }\r\n\r\n var textEncoding: String.Encoding? {\r\n guard let encodingName = textEncodingName else { return nil }\r\n\r\n return String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding(encodingName as CFString)))\r\n }\r\n}\r\n\r\n```\r\n\r\nfeel free to ask me any questions about the code and thanks for your time !\r\n\r\n## Versions\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 120.1\r\n- Swift version: 5.3","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"So it looks like you could probably get to this point with what you're doing by passing in a custom `RequestBodyCreator` to `RequestChainNetworkTransport` and then setting the `useGETForQueries` parameter to `true` - I believe almost all the rest of this is handled for you automatically in the RCNT otherwise.\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@taher-mosbah Anything else I can help with here? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"thanks for your answer, it's clear will try to implement as soon as I got the time 😄 ","author":{"__typename":"User","login":"taher-mosbah","id":"MDQ6VXNlcjIzMDAwODc=","name":"Mohamed Taher Mosbah"}}]}},{"__typename":"Issue","title":"Swift scripting error with xcode 12","author":{"__typename":"User","login":"jdevng","id":"MDQ6VXNlcjI2ODE3NDEw","name":null},"body":"## Bug report\r\n\r\nInitialization of Codegen directory at \r\n\r\nhttps://www.apollographql.com/docs/ios/swift-scripting/\r\n\r\nresults in error.\r\n\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.35\r\n- Xcode version: 12.0.1\r\n- Swift version: Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)\r\n\r\n## Steps to reproduce\r\n```\r\n\r\n% swift packet init --type executable\r\nerror: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-packet (No such file or directory)\r\n```\r\n\r\n\r\n## Further details\r\n\r\nPlease replace this line with any further details or context necessary to understand the problem. Delete this section if you don't have anything further to add.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I think you mean `swift package --init` rather than `swift packet --init`","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm blind. Will delete :) Thank you. Should learn to copy!","author":{"__typename":"User","login":"jdevng","id":"MDQ6VXNlcjI2ODE3NDEw","name":null}}]}},{"__typename":"Issue","title":"set the timeout of the ApolloCodegenLib","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"},"body":"I am following the guide to download zip file with CLI.\r\nHow can I set the timeout of the ApolloCodegenLib:CLIDownloader ?\r\nMy network is so bad :(\r\n\r\n```\r\nswift run\r\n[DEBUG - ApolloCodegenLib:CLIDownloader.swift:72] - Downloading zip file with the CLI...\r\ndownloadTimedOut(after: 30.0)\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"For anyone stumbling across this, all of the methods to call into the codegen lib should have a `timeout` parameter. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Create WebsocketTransport without connecting automatically","author":{"__typename":"User","login":"winstondu","id":"MDQ6VXNlcjgxNzQzMTA=","name":"Winston Du"},"body":"## Feature request\r\n\r\nCurrently, the designated initializer for the WebSocketTransport[ immediately connects the websocket. ](https://github.com/apollographql/apollo-ios/blob/cf537701e407bed1a13df6dd6288d641abdda42a/Sources/ApolloWebSocket/WebSocketTransport.swift#L128)\r\n\r\nWe wish to manually control when it does its first connection.\r\n\r\n## Motivation\r\n\r\nWe want to our app's webservers to able to handle load, and at high traffic times we actually want the ability to disable automatic websocket connections to our server at app startup.\r\n\r\n## Proposed solution\r\n\r\nAdd a parameter to the [designated initializer](https://github.com/apollographql/apollo-ios/blob/cf537701e407bed1a13df6dd6288d641abdda42a/Sources/ApolloWebSocket/WebSocketTransport.swift#L128) on whether the websocket should connect immediately on initialization. In otherwords, wrap the `websocket.connect()` call in an `if` statement.\r\n\r\nAdditional notes: \r\nBecause the mutex-locked `reconnect` parameter only comes into play after the the first disconnection (which can only happen after the first connection), that parameter does not affect things.\r\n \r\n## Outstanding Questions\r\n- It is up to the implementor to decide whether there should be a separate api for the first websocket connection, or if the developer can just call `reconnectWebSocket()`","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Seems like a reasonable request, and thank you for adding a PR! I'll keep feedback over on the PR just for the sake of clarity. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"allowSpecificHTTPSCertificateForHost warning in iOS 14","author":{"__typename":"User","login":"DiwakarThapa","id":"MDQ6VXNlcjI5OTE3Nzk5","name":"diwakar thapa"},"body":"I started receiving following warning on Xcode after I update my iPhone to iOS 14. How to fix this warning? \r\n ## Warning\r\nnil host used in call to allowSpecificHTTPSCertificateForHost: \r\nnil host used in call to allowAnyHTTPSCertificateForHost:\r\nnil host used in call to allowSpecificHTTPSCertificateForHost: \r\nnil host used in call to allowAnyHTTPSCertificateForHost:\r\n\r\n## Network Transport \r\nprivate var networkTransport: HTTPNetworkTransport {\r\n let configuration = URLSessionConfiguration.default\r\n configuration.timeoutIntervalForResource = 65\r\n configuration.timeoutIntervalForRequest = 65\r\n let client = URLSessionClient(sessionConfiguration: configuration)\r\n let transport = HTTPNetworkTransport(url: URL(string: self.baseUrl)!, client: client)\r\n transport.delegate = self\r\n return transport\r\n }\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.30.0\r\n- Xcode version: 11.2.1\r\n- Swift version: 5","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Wow, weird! Never seen that before. We're not doing anything that I'm aware of that should be calling any of those methods. \r\n\r\nWould be curious if this is still happening in versions `0.34.0` and above - we made some pretty significant changes to the networking stack there. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@DiwakarThapa Is there any further information you can share here? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since I haven't heard back in a couple weeks, I'm going to close this out - @DiwakarThapa if you get more info feel free to reopen. Anyone else with a similar problem, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Initializer default values make it very easy to accidentally create 2 distinct ApolloStore's","author":{"__typename":"User","login":"namolnad","id":"MDQ6VXNlcjYxNDg0ODA=","name":"Dan Loman"},"body":"## Bug report\r\n\r\nCurrently it's very easy, through default initializer values, to end up with multiple ApolloStore's and the inability to properly invalidate your cache. I just spent a fair amount of time debugging this issue, which I think could be resolved by removing some default values in one or both the `ApolloClient`'s and `LegacyInterceptorProvider`'s initializers. The problem is as follows:\r\n\r\n``` swift\r\nlet interceptorProvider: LegacyInterceptorProvider = .init() // More likely to use your own subclass for authentication\r\nlet transport: RequestChainNetworkTransport = .init(\r\n interceptorProvider: interceptorProvider,\r\n endpointURL: baseUrl.appendingPathComponent(\"graphql\")\r\n)\r\nlet client: ApolloClient = .init(\r\n networkTransport: transport\r\n)\r\n```\r\n\r\nThe above code creates two separate `ApolloStore`'s with default caches of `InMemoryNormalizedCache()` for both the `LegacyInterceptorProvider` and for the `ApolloClient`. When going to invalidate your cache here, you will invalidate one of the caches (the ApolloStore one), but the InterceptorProvider's cache will remain untouched, which is where results seem to be fetched from, thus making it impossible to actually invalidate the cache. Without these default values, I believe this problem would be obvious to the developer.\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.0\r\n- Xcode version: 12.0.1\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nInitialize the ApolloClient using default values, as above.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Yeah this is basically a dupe of #1438 - I'm going to take a look at your solution, I was still pondering exactly how to get this set up in a friendlier way. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yup, definitely a dupe — sorry for missing that and thanks for taking a look!","author":{"__typename":"User","login":"namolnad","id":"MDQ6VXNlcjYxNDg0ODA=","name":"Dan Loman"}},{"__typename":"IssueComment","body":"This has shipped with `0.36.0`!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"graphql file with description","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"},"body":"Any way to add description to graphql file? This results in errors in compile time.\r\n\r\nA good example would be:\r\n\r\n```\r\n\"\"\"\r\nA simple GraphQL schema which is well described.\r\n\"\"\"\r\nschema {\r\n query: Query\r\n}\r\n```\r\n\r\nhttp://spec.graphql.org/draft/#sec-Descriptions\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"In theory that should not result in errors - can you give an example of a file where this is resulting in errors, along with the errors? Any information around your setup would also be really helpful. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Just add \r\n\r\n \"\"\"\r\n A simple GraphQL schema which is well described.\r\n \"\"\"\r\n\r\nto the first line of any .graphql file and Build then you will see the error.\r\n\r\n Showing Recent Messages\r\n Error: Syntax error in \r\n\r\n file:///Users/mac/a.graphql: Syntax \r\n\r\n Error: Unexpected Name \"query\".\r\n\r\n","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"}},{"__typename":"IssueComment","body":"Are you trying to add this to your operation graphQL files, or to the Schema graphQL file? This syntax is intended for the schema - you can see an example in [the version of the GitHub Schema we're using for some tests](https://github.com/apollographql/apollo-ios/blob/main/Sources/GitHubAPI/schema.docs.graphql). \r\n\r\nIf you were to try to add this to an operation's graphQL file like: \r\n\r\n```graphQL\r\n\"\"\"\r\nA simple GraphQL schema which is well described.\r\n\"\"\"\r\nquery UserInfo($id: ID!) {\r\n user(id: $id) {\r\n name\r\n }\r\n}\r\n```\r\n\r\nThat would not compile. Does that help? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@wongzigii Any thoughts on my response? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Good to know! Thanks @designatednerd ","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"}}]}},{"__typename":"Issue","title":"Is there any way to have a hybrid cache instead of memory/disk exclusively?","author":{"__typename":"User","login":"malonehedges","id":"MDQ6VXNlcjEyMDkyMjk2","name":"Malone Hedges"},"body":"Is there any official (or community) support for a hybrid cache for Apollo iOS?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Not at this time but I have had at least one customer talk to us about this. We're gonna be doing some heavy work around the cache in the next couple months but probably after that we can take a look. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Awesome, would love to adopt a hybrid cache when one is available","author":{"__typename":"User","login":"malonehedges","id":"MDQ6VXNlcjEyMDkyMjk2","name":"Malone Hedges"}}]}},{"__typename":"Issue","title":"some thoughts on Interceptors","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"},"body":"## Feedback\r\n\r\nI just update from 0.33.0 to 0.36.0 and want to share some thoughts on Interceptors.\r\n\r\n- confusing what does proceedAsync, handleErrorAsync, retry and kickoff do. If I have error in response and want to retry do I call retry? or kickoff?\r\n- `Request`ChainNetworkTransport but you pass response Interceptors to it (as request and response interceptors are the same list)\r\n- confusing that same call used for request and response, only way to check for response == nil in `interceptAsync`\r\n- `TokenAddingInterceptor` from docs adds Authorization header to request not depending if its request or response. Is that how it should be?\r\n- `RequestChainNetworkTransport` have `additionalHeaders` - shouldn't this be interceptor?\r\n- there is `AutomaticPersistedQueryInterceptor` and also `autoPersistQueries` on `RequestChainNetworkTransport` what should I use?\r\n- There is `LegacyInterceptorProvider` but something not \"legacy\" (`NetworkInterceptorProvider`) only mentioned in documentation. How do I create custom provider where I add only my interceptors and leave \"default\" ones untouched? `NetworkInterceptorProvider` from docs have 10 interceptors, `LegacyInterceptorProvider` have 7. Should I inherit from `LegacyInterceptorProvider` or should I copy one from docs and constantly track if new Interceptor will just appear in the list?\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36.0\r\n- Swift version: 5.3","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"comment about `TokenAddingInterceptor` is invalid as it is inserted in first place (so it can't be response)","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"> confusing what does proceedAsync, handleErrorAsync, retry and kickoff do. If I have error in response and want to retry do I call retry? or kickoff?\r\n\r\n- `proceedAsync` is called anytime you want to have the chain proceed to the next interceptor\r\n- `handleErrorAsync` is called anytime you want to have the chain return an error to the original caller\r\n- `kickoff` should only be called by you when you want to start the chain from scratch.\r\n- `retry` should be called if you want to retry a request - it will [reset the interceptor index under the hood and call `kickoff` to restart the chain](https://github.com/apollographql/apollo-ios/blob/9c624bbcfa1c8b3b909ee0c53ec43ebb1a50e944/Sources/Apollo/RequestChain.swift#L129). You should use this method rather than trying to reset the index yourself. Basically, don't call `kickoff` on the chain from within an interceptor, call `retry`. \r\n\r\n> RequestChainNetworkTransport but you pass response Interceptors to it (as request and response interceptors are the same list) confusing that same call used for request and response, only way to check for response == nil in interceptAsync\r\n\r\nI'm not totally clear on what the question here is - is it \"Why are we using the same interceptors for preparing a request as handling a response?\" If yes, please confirm, if not, please clarify. Thanks. \r\n\r\n> TokenAddingInterceptor from docs adds Authorization header to request not depending if its request or response. Is that how it should be?\r\n\r\nYes - the idea of that is that you put it first so that it is the first change applied before a request goes out. \r\n\r\n> RequestChainNetworkTransport have additionalHeaders - shouldn't this be interceptor?\r\n\r\nThese are intended to be additional headers that must be added to every single request, and which do not change (for example, an API key or a language setting). The interceptors are intended for things which may change (for example, a user's authentication token). \r\n\r\n> there is AutomaticPersistedQueryInterceptor and also autoPersistQueries on RequestChainNetworkTransport what should I use?\r\n\r\nThe short answer is both - `autoPersistQueries` tells you whether auto-persisted queries should be used at all, and the interceptor does the work of checking for APQ-related errors and auto-retrying when needed. Essentially, `autoPersistQueries` tells you if you should send APQ hashes outgoing, and the interceptor handles incoming responses to tell if you need to retry due to an APQ failure. \r\n\r\n> There is LegacyInterceptorProvider but something not \"legacy\" (NetworkInterceptorProvider) only mentioned in documentation. How do I create custom provider where I add only my interceptors and leave \"default\" ones untouched? NetworkInterceptorProvider from docs have 10 interceptors, LegacyInterceptorProvider have 7. Should I inherit from LegacyInterceptorProvider or should I copy one from docs and constantly track if new Interceptor will just appear in the list?\r\n\r\nYou _can_ inherit from `LegacyInterceptorProvider`, and override the method providing the array of interceptors. This is easier if you're putting interceptors at the beginning or end of the array rather than interspersing them throughout. If they're interspersed, it's likely better create your own implementation of `InterceptorProvider` and using the array provided by `LegacyInterceptorProvider` as a starting point. \r\n\r\nI will call out in release notes if any changes are made to the `LegacyInterceptorProvider`, particularly new interceptors - the intent is that the core interceptors should not change. \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I was going through a similar thinking process as @RolandasRazma yesterday doing the same 0.33->0.36 migration. Would be super helpful if you added these explanations to the documentation for other people. ","author":{"__typename":"User","login":"Nealsoni00","id":"MDQ6VXNlcjcwMTMxOTE=","name":"Neal Soni"}},{"__typename":"IssueComment","body":"Have y'all had a chance to read through [the updated client creation documentation](https://www.apollographql.com/docs/ios/initialization/#advanced-client-creation), particularly the [section on how the request chain works](https://www.apollographql.com/docs/ios/initialization/#how-the-requestchain-works)? I would be particularly interested in where you feel like that's not clear enough. Thanks!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I did, I think for me most confusion would have been averted if:\r\n\r\n- there would be 2 lists: pre server call and post server call having different call signature (no reply in \"pre\" ones)\r\n- there would be no \"Legacy\" in class names as it made not clear what to use\r\n- don't feel feel comfortable of just copying list of \"default\" interceptors as that list might change without the realising","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"> there would be 2 lists: pre server call and post server call having different call signature (no reply in \"pre\" ones)\r\n\r\nOne of the reasons I went with a single chain is we've had repeated feature requests to have the data associated with what was being requested passed through to the completion handler. I will be taking a look at some options based on feedback here, I think maybe there could be some other options that might make `NetworkTransport` unnecessary and allow the user to send data through any transport (ie, send it with a websocket if you really feel like it). \r\n\r\n> there would be no \"Legacy\" in class names as it made not clear what to use\r\n\r\nOK. I believe I tried to explain \"Legacy\" vs \"Codable\" as \"What we've been using\" vs \"What we will be using in the future\" in those docs, but it sounds like that didn't help. I'll try to clarify that.\r\n\r\n> don't feel feel comfortable of just copying list of \"default\" interceptors as that list might change without the realising\r\n\r\nI mean, that's going to be a problem no matter what if you need to intersperse different interceptors - if you're subclassing hte default list and relying on the default order in terms of where to insert your interceptors, that's going to cause problems too. Again, I can certainly commit to making sure I make it very clear in release notes when any of this changes. \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@RolandasRazma @Nealsoni00 I've just opened a PR with updated docs. Would love your feedback on #1484. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> One of the reasons I went with a single chain is we've had repeated feature requests to have the data associated \r\n\r\nEverything could still work as it does now under the hood. 2 list would allow to not have \"response\" in pre list\r\n\r\n> I mean, that's going to be a problem no matter what\r\n\r\nthat's not necessary true if there would be 2 lists as in most cases you need \"pre action\" and \"post action\"\r\n\r\n\r\nI already migrated and now it's more clear what's going on so I'm not advocating for a change. Most likely all new users will do better as they have no expectations ","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"> 2 list would allow to not have \"response\" in pre list\r\n\r\nThat's fair. \r\n\r\n> I'm not advocating for a change.\r\n\r\nI think if we're gonna make one it's better to do it sooner rather than later, honestly. I also need to think a few things over, to be honest.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"OK, I've merged #1464. I will continue to think about what could work to make it easier to deal with when an interceptor will be called - pre or post response - and see what I can come up with. However, I wanted to check - do you feel there's anything else here that still needs to be directly addressed before we can close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I will close it","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"@RolandasRazma thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Crash in 0.36.0","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"},"body":"## Bug report\r\n\r\nCrash using interceptors\r\n\r\n\"Screenshot\r\n\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36.0\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nI have TokenAddingInterceptor that retrieves token from server and asynchronously calls `chain.proceedAsync`. I have check for TokenAddingInterceptor being released to not call up the chain on dealloc, so that's not the case.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"The crash is happening in the `URLSessionClient` rather than in any of the interceptors - it looks like the client either a) Hasn't had a chance to set up its `URLSession` or b) has had the session torn down. \r\n\r\nCan you share how you're setting up your `TokenAddingService`? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"There is nothing interesting to see there. It just check for token validity if it it expired updates it from server and calls back. I will try to trace/fix crash as it's blocking us, but as its another race condition its not going to be simple as I can't even replicate it reliably. Sometimes it crashes every run (tests) sometimes I hit https://github.com/apollographql/apollo-ios/issues/1376 and sometimes all tests passes without any problem :)","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"I can replicate it with example from https://www.apollographql.com/docs/ios/tutorial/tutorial-mutations/\r\n\r\n```swift\r\nclass TokenAddingInterceptor: ApolloInterceptor {\r\n func interceptAsync(chain: RequestChain, request: HTTPRequest, response: HTTPResponse?, completion: @escaping (Result, Error>) -> Void) {\r\n DispatchQueue.main.async { [weak self] in\r\n guard self != nil else { return }\r\n chain.proceedAsync(request: request, response: response, completion: completion)\r\n }\r\n }\r\n \r\n}\r\n```","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"This is how memory graph looks for crashing client\r\n\r\n\"Screenshot\r\n","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"NetworkFetchInterceptor:32 don't you need `self.currentTask?.cancel()` before it?\r\n\r\nP.S. adding cancel didn't stop crash, but still, don't you need it there? (made PR https://github.com/apollographql/apollo-ios/pull/1476)","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"Ok, what's happening is that `RequestChain` (created in `RequestChainNetworkTransport`) lifetime is longer than `LegacyInterceptorProvider` and `LegacyInterceptorProvider` does `shouldInvalidateClientOnDeinit` \r\n\r\n`RequestChain` is created in `RequestChainNetworkTransport`, `LegacyInterceptorProvider` is released invalidating client and `RequestChain` knows nothing about it. \r\n\r\nI managed to \"solve\" it by retaining link to chain in `RequestChainNetworkTransport` and canceling it in `deinit` - not sure if that's correct thing to do, as that would imply that I need to cancel it on send as well (or retain all references created by send)","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"sorry for spam @designatednerd ","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"I thought not retaining chain would help\r\n\r\n```swift\r\nclass TokenAddingInterceptor: ApolloInterceptor {\r\n func interceptAsync(chain: RequestChain, request: HTTPRequest, response: HTTPResponse?, completion: @escaping (Result, Error>) -> Void) {\r\n DispatchQueue.main.async { [weak self, weak chain] in\r\n guard self != nil else { return }\r\n chain?.proceedAsync(request: request, response: response, completion: completion)\r\n }\r\n }\r\n \r\n}\r\n```\r\n\r\nbut that's not the case - it is deallocated before we can update token and call to server never executed","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"right - if you let go of the chain there there's nothing hanging on to it, so ARC smashes it. \r\n\r\nI'm surprised the legacy interceptor provider is getting deallocated - that indicates that the Request Chain Network Transport itself is getting deallocated. I would really like to see how you're setting this stuff up for tests - it seems like maybe something is calling into an old instance of RCNT in different tests. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"`RequestChainNetworkTransport` is deallocated, but the problem is not that it is deallocated, the problem is that it doesn't cleanup properly while it does that\r\n\r\n```swift\r\nclass TokenAddingInterceptor: ApolloInterceptor {\r\n func interceptAsync(chain: RequestChain, request: HTTPRequest, response: HTTPResponse?, completion: @escaping (Result, Error>) -> Void) {\r\n DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { [weak self] in\r\n guard self != nil else { return }\r\n chain?.proceedAsync(request: request, response: response, completion: completion)\r\n }\r\n }\r\n}\r\n\r\nlet transport = RequestChainNetworkTransport(...)\r\nlet apolloClient = ApolloClient(networkTransport: transport, ...)\r\napolloClient.fetch(query: ...)\r\n```\r\n\r\nwill make whole app crash in 1 second because `ApolloClient` will be deallocated together with `RequestChainNetworkTransport` while `RequestChain` will be retained by block (and it has to be)\r\n\r\nCrash will happen because deallocatingin `LegacyInterceptorProvider` will call `client.invalidate()` that will nil `URLSessionClient.sesion` and after 1 sec it will be accessed with force unwrap","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"this is the crash https://github.com/apollographql/apollo-ios/pull/1480","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"I guess easy workaround would be to remove force unwrap, but the real problem is that `RequestChain` don't know that it is no longer needed. Correct fix would be to add \"cancel\" for chain in `RequestChainNetworkTransport` as mentioned in https://github.com/apollographql/apollo-ios/issues/1473#issuecomment-717173144 the only difficulty it that there is multiple chains per transport and all of them needs to be cancelled","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"Created PR with workaround https://github.com/apollographql/apollo-ios/pull/1481 but somehow don't fee good about it :) It doe's work, but feels like some code smell","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"should I close this?","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"I'll close it when it actually ships","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"GraphQLError parsing issue in response?.parsedResponse ","author":{"__typename":"User","login":"StanislavCekunov","id":"MDQ6VXNlcjk3NzQ0Nzc=","name":null},"body":"Hello Apollo community,\r\nI am currently updating our codebase to support `RequestChainNetworkTransport` interface. \r\nIn a previous structure I used `HTTPNetworkTransportGraphQLErrorDelegate` to catch `GraphQLError` to initiate access token update and retryHandler to retry faild request. \r\n\r\nWith the new `RequestChain` structure I am perfoming same action inside ResponseCodeInterceptor. Though, `GraphQLError` is not being parced anymore. I am accessing it by `response?.parsedResponse?.errors`\r\n\r\nHere is the response raw data: \r\n`{\"errors\":[{\"message\":\"Access denied\",\"path\":[\"getUserDetails\"],\"locations\":[{\"line\":2,\"column\":1}],\"extensions\":{\"code\":\"accessTokenExpired\"}}],\"data\":null}`\r\n\r\nWould love to get some help or suggestions where is the right way to fetch `GraphQLError` this time.\r\nAm I doing something wrong? \r\nThanks\r\n\r\n## Versions\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36.0\r\n- Swift version: 5.3\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I would probably do this check in an interceptor that runs after `LegacyParsingInterceptor` - that's where the actual parsing takes place, and after it's gone through that inteceptor, you should be able to access it using `response?.parsedResponse?.errors`. \r\n\r\nThe `ResponseCodeInterceptor` that's provided by default is mostly just checking to make sure the response code is something vaguely sane before attempting to parse the result","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thank you @designatednerd !\r\nI have added a new interceptor `AccessTokenValidationInterceptor` right after `LegacyParsingInterceptor`. \r\nSolved. 🙌 \r\n\r\n","author":{"__typename":"User","login":"StanislavCekunov","id":"MDQ6VXNlcjk3NzQ0Nzc=","name":null}},{"__typename":"IssueComment","body":"@StanislavCekunov Mind if we close this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Using same query with different set of fields","author":{"__typename":"User","login":"vani2","id":"MDQ6VXNlcjQ3MzQ5ODM=","name":"Ivan Vavilov"},"body":"## Question\r\n\r\nI have query of `draftProfile` and `profile`\r\n\r\n```GraphQL\r\nquery fetchProfile {\r\n draftProfile {\r\n firstName\r\n secondName\r\n },\r\n profile {\r\n firstName\r\n secondName \r\n }\r\n}\r\n```\r\n\r\nLater I need to make the same query but only `profile` object.\r\n\r\n```GraphQL\r\nquery fetchProfile {\r\n profile {\r\n firstName\r\n secondName \r\n }\r\n}\r\n``` \r\n\r\nIf I declare these two queries I get the error `There are multiple definitions for the `fetchProfile` operation. Please rename or remove all operations with the duplicated name before continuing.`.\r\n\r\nHow I can make it possible? \r\n\r\n## Versions\r\n\r\n- `apollo-ios` SDK version: 0.35\r\n- Xcode version: 12.0\r\n- Swift version: 5.3","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"You need to give the two queries different names at the `query fetchProfile` point. Maybe `query fetchProfileWithDraft` for that top one and just `fetchProfile` for the bottom one? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Oh, yes, that's easy. Thanks.","author":{"__typename":"User","login":"vani2","id":"MDQ6VXNlcjQ3MzQ5ODM=","name":"Ivan Vavilov"}}]}},{"__typename":"Issue","title":"XCode 12 : Could not find module ‘Apollo’ for target ‘arm64-apple-ios-simulator’; found: x86_64-apple-ios-simulator, x86_64","author":{"__typename":"User","login":"poorvasingh04","id":"MDQ6VXNlcjIwMDkwODU5","name":"Poorva Singh"},"body":"## Bug report\r\n\r\nXCode 12 : Could not find module ‘Apollo’ for target ‘arm64-apple-ios-simulator’; found: x86_64-apple-ios-simulator, x86_64\r\nUnable to build app against iOS simulator using XCode 12.\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.27.1 and 0.36.0\r\n- Xcode version: 12\r\n- Swift version: 5\r\n\r\n## Steps to reproduce\r\nBuild code against iOS simulator. I am using app to build against iOS simulator for UI tests.\r\n\r\n## Further details\r\n\r\nCode fails to compile. I also added following post install script in podfile:\r\n\r\npost_install do |pi|\r\n pi.pods_project.targets.each do |t|\r\n t.build_configurations.each do |config|\r\n config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'\r\n config.build_settings[\"EXCLUDED_ARCHS[sdk=iphonesimulator*]\"] = \"arm64\"\r\n end\r\n end\r\nend\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It looks like your post-install script's change `EXCLUDED_ARCHS` is actively excluding the `arm64` type that the compiler is looking for. Is there a particular reason why you're excluding that? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd yes. To compile with Xcode 12 against iOS simulator, we need to exclude arm64 architecture in app and all the linked pods. This is same issue as described here: https://stackoverflow.com/questions/63607158/xcode-12-building-for-ios-simulator-but-linking-in-object-file-built-for-ios","author":{"__typename":"User","login":"poorvasingh04","id":"MDQ6VXNlcjIwMDkwODU5","name":"Poorva Singh"}},{"__typename":"IssueComment","body":"Interesting - there's a related suggestion in there about making sure that `ONLY_ACTIVE_ARCH` is set to yes for your debug setup. In a sample CocoaPods app I've got where that's set up I have not seen this issue.\r\n\r\nI *think* as long as you're not building on a developer transition kit, setting that up should help with this, since it seems like Xcode is trying to build the universe, then complaining that the thing you specifically told it not to build isn't there.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd ONLY_ACTIVE_ARCH is already set to Yes","author":{"__typename":"User","login":"poorvasingh04","id":"MDQ6VXNlcjIwMDkwODU5","name":"Poorva Singh"}},{"__typename":"IssueComment","body":"🤔 That's...very odd if you're not on a developer transition kit. Are you on a developer transition kit? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd no. I am not in a developer transition kit. I am trying to build app against simulator for my UI tests but it fails with Xcode 12.1","author":{"__typename":"User","login":"poorvasingh04","id":"MDQ6VXNlcjIwMDkwODU5","name":"Poorva Singh"}},{"__typename":"IssueComment","body":"Here's a couple other things I can think of that are unlikely but worth checking: \r\n\r\n- If there's more than one target in your project, are all targets in your project set for `ONLY_ACTIVE_ARCH`, or just the main application?\r\n- Is your scheme set to run the tests in release mode rather than debug mode? \r\n- Is there something about XCUI tests that's trying to build the app for release even though your tests are set in debug?\r\n\r\nIf none of those turn up the problem, do you mind either emailing me your project or a sample project that reproduces this issue? ellen at apollographql dot com. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Were you ever able to figure this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Race condition when unsubscribing","author":{"__typename":"User","login":"marioradonic","id":"MDQ6VXNlcjQxNTg3Mzc=","name":null},"body":"## Bug report\r\n\r\nI've been randomly (but often) getting `.unprocessedMessage` errors in my `.subscribe(...` handlers. I had a look at the code and it seems to me that there is a possible race condition.\r\n\r\nWhen [unsubscribing](https://github.com/apollographql/apollo-ios/blob/e0f65fee8c197239dbefbf1386b8e7f83b684f25/Sources/ApolloWebSocket/WebSocketTransport.swift#L301) from a subscribe task websocket message is sent requesting the subscription to stop and handler is released. It might be possible that a message is received from the socket with the update before the backend has time process this stop message and stop sending the messages. So in the [processMessage](https://github.com/apollographql/apollo-ios/blob/e0f65fee8c197239dbefbf1386b8e7f83b684f25/Sources/ApolloWebSocket/WebSocketTransport.swift#L146) method we end up in [this clause](https://github.com/apollographql/apollo-ios/blob/e0f65fee8c197239dbefbf1386b8e7f83b684f25/Sources/ApolloWebSocket/WebSocketTransport.swift#L177) because there is no subscription handlers any more. And then **all** the other handlers are notified about this error. This doesn't seem right to me as there was nothing wrong with other subscriptions.\r\n\r\nI'm not an expert in web sockets, so I don't know what the best solution would be. Maybe wait for the ack message from backend? But then the subscriber might get a message after cancelling the task, which is not nice. Maybe keep an intermittent array of task ids whose cancellation hasn't been acknowledged by the backend and ignore messages for those subscribers? That is if there is a stop acknowledge message from backend.\r\n\r\nI don't mind creating a PR if someone suggests the approach on how to fix this.\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.35.0\r\n- Xcode version: 12.1\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nI have a rx code in format of:\r\n`subscribeSomething().flatMapLatest { subscribeSomethingElse(using: $0) }`\r\n\r\nWhen the first subscription updates the second one is cancelled and new one is created.\r\n\r\n## Further details\r\n\r\nI can probably restructure my query so it's all done in one subscription, which would fix my issue but the underlying problem will still be there although it might happen less often.\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I don't have any bright ideas on this one, websockets are also not my area of expertise. \r\n\r\n@fassko, if you're around, would love to hear any thoughts you have.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I was using GraphQL subscriptions with just one subscription. Otherwise, you can run into these weird side effects that you explained.","author":{"__typename":"User","login":"fassko","id":"MDQ6VXNlcjI5NDgy","name":"Kristaps Grinbergs"}},{"__typename":"IssueComment","body":"@fassko Well, it was worth a shot 🙃\r\n\r\n@marioradonic - Are you subscribing to the same `subscription` from your schema multiple times, or are there different `subscription`s defined that you're using? Basically, are your multiple subscriptions all returning the same information, or different information?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I am using multiple. Basically, I am subscribing to entity A, and when it updates I subscribe to entity B, cancelling the previous B subscription if there was any. (this cancelled subscription causes the problem - if the message comes from the backend with the cancelled subscription id the first entity A subscriber and the new B subscriber get the error message.\r\n\r\nI had another look at the websocket connection and it seems there is no closing acknowledgment message from the backend upon closing the subscription. So I'm not sure at which point should an unhandled message be considered an internal error. In any case I don't think it's a good API design that all the other subscribers get the error message, since nothing is wrong with their subscriptions. Maybe there could be a global error handler for these kinds of errors?\r\n\r\n","author":{"__typename":"User","login":"marioradonic","id":"MDQ6VXNlcjQxNTg3Mzc=","name":null}},{"__typename":"IssueComment","body":">cancelling the previous B subscription if there was any. \r\n\r\nIn theory you shouldn't have to cancel any existing subscription to entity B - if you've already got a running subscription it should continue to get all updates.\r\n\r\nIt may help me understand a bit better if you can give a concrete example of what entity A and entity B are representing. To take an example from our sample code, if you've subscribed to all reviews of Star Wars episodes, then as soon as you get a review of _Return of the Jedi_ kick off a second subscription that only handles _Jedi_ reviews, any further reviews that come in on that first subscription for _Jedi_ would also come in on the second subscription, without needing to stop and restart. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"spectrum.chat/apollo link is unavailable, Heroku error shown","author":{"__typename":"User","login":"gemmakbarlow","id":"MDQ6VXNlcjMzNzk2Mw==","name":"Gemma Barlow"},"body":"## Bug report\r\n\r\nMorning folks ! \r\n\r\nNot technically an Apollo bug, but I wanted to flag that https://spectrum.chat/apollo, linked from [CONTRIBUTING.md](https://github.com/apollographql/apollo-ios/blob/main/CONTRIBUTING.md), is currently returning a Heroku error.\r\n\r\n\"Screen\r\n\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- N / A\r\n\r\n## Steps to reproduce\r\n\r\n- N / A\r\n\r\n## Further details\r\n\r\nPlease feel free to close this if it isn't something you are in control of / hosting yourselves. I wasn't able to find a status page for the tool / platform and am not familiar with it. Google results get mixed in with the ISP provider unfortunately. 😄 ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Haha, i have the same problem with the ISP, particularly since they are _my_ ISP. \r\n\r\nSpectrum is a chat platform that got bought out by GitHub about a year and a half ago - we'd been using them prior to that buyout and have been continuing to do so. Thanks for the heads up on this, but unfortunately there isn't much we can do about their deploys failing. Upside is it seems to be back up and running now, though!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"How to handle errors correctly","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null},"body":"Hi,\r\nI am currently on the stage of migrating from 0.33 -> 0.36. Gone through all the provided documentation, but I am still confused on what would be the correct way of handling errors(also read the suggested article: https://medium.com/@sachee/200-ok-error-handling-in-graphql-7ec869aec9bc).\r\n\r\nBefore going to write this question, I just wanted to give it a try myself.\r\nOne of the most important use cases related to error handling is that we want to cover the case when a auth token expires on the backend, which results in an error when performing the next app query or mutation. At this stage, we want to catch the error, perform automatically a relogin(call `login` mutation), which basically will return a new auth token and after all that re-execute the failed request(query/mutation).\r\nAs far as I managed to understand, the best way to do this is through `ApolloErrorInterceptor`, which I basically did. I created a custom `ApolloErrorInterceptor`, returned it in `InterceptorProvider.additionalErrorInterceptor`.\r\nThe first problem I met is that it seems that not absolutely all errors get through this interceptor. Which left me without ideas on how to continue, but since this new apollo sdk approach is pretty fresh, I also left some space to consider it might be a bug, `full stop`.\r\n\r\nNow my question is: what is the correct way of handling errors? Can we improve the documentation to provide more examples about it?\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Interesting, I thought it was me but maybe `InterceptorProvider.additionalErrorInterceptor` is not what we expect.\r\nI just went through same update and had same problem as you do. what worked for me was:\r\n\r\n```swift\r\n/// InterceptorProvider\r\n func interceptors(for operation: Operation) -> [ApolloInterceptor] {\r\n return [\r\n MaxRetryInterceptor(),\r\n LegacyCacheReadInterceptor(store: self.store),\r\n TokenAddingInterceptor(...),\r\n NetworkFetchInterceptor(client: self.client),\r\n TokenErrorInterceptor(...),\r\n ResponseCodeInterceptor(),\r\n LegacyParsingInterceptor(cacheKeyForObject: self.store.cacheKeyForObject),\r\n AutomaticPersistedQueryInterceptor(),\r\n LegacyCacheWriteInterceptor(store: self.store),\r\n ]\r\n }\r\n\r\n func additionalErrorInterceptor(for operation: Operation) -> ApolloErrorInterceptor? {\r\n return nil\r\n }\r\n```\r\n\r\n```swift\r\n/// TokenErrorInterceptor\r\n func interceptAsync(chain: RequestChain, request: HTTPRequest, response: HTTPResponse?, completion: @escaping (Result, Error>) -> Void) {\r\n guard\r\n let responseStatusCode = response?.httpResponse.statusCode,\r\n responseStatusCode == 401\r\n else {\r\n chain.proceedAsync(request: request, response: response, completion: completion)\r\n return\r\n }\r\n \r\n tokenService.renewAccessToken { [weak self] (error: OAuthSwiftError?) in\r\n guard self != nil else { return }\r\n \r\n if let error = error {\r\n chain.handleErrorAsync(error, request: request, response: response, completion: completion)\r\n } else {\r\n chain.retry(request: request, completion: completion)\r\n }\r\n }\r\n }\r\n```\r\n\r\nneither `additionalErrorInterceptor` nor having `TokenErrorInterceptor` after `ResponseCodeInterceptor` worked","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"`additionalErrorInterceptor` is generally intended for error handling *after* something has been dealt with by the request chain. In this case, you want to deal with it *within* the request chain, so that you can call retry. \r\n\r\n@RolandasRazma's example is a great one if the token error is coming back from middleware and causing a `401 Unauthorized` to be returned. \r\n\r\nIf there's something within GraphQL that's returning the error, you'll get a `200 OK` and an error on `GraphQLResult`'s `errors` property. In that case, you would want to insert your `TokenErrorInterceptor` after the `LegacyParsingInterceptor`, since that's where those would actually be parsed.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> `additionalErrorInterceptor` is generally intended for error handling _after_ something has been dealt with by the request chain.\r\n\r\nJust for the sake of understanding it better, what does it mean and why in some particular conditions it is not called.? I guess some of the docs needs to be more explicit about the use cases when it should be used.","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"It only wouldn't be called if it doesn't exist. It's designed to be a place to have all errors, no matter what the origin, pass through before being handed back to the caller. This allows for things like error logging that are hard to do without a centralized error handler. \r\n\r\nI'll work on clarifying this in the docs.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@odanu @RolandasRazma Added some docs on the additional error interceptor to #1484 ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"OK, that's merged - is there anything else here I can help clarify, or do you mind if we close this out?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I think you can close this ticket. Though you have to maybe give it a try for different use cases around `additionalErrorInterceptor`. As written above, it looks like it doesn't catch all the errors.","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"> nor having `TokenErrorInterceptor` after `ResponseCodeInterceptor` worked\r\n\r\nHere the issue would be that the `401` response code would be caught by the `ResponseCodeInterceptor` [and returned as an error through `handleErrorAsync`](https://github.com/apollographql/apollo-ios/blob/a00031c2a357c03a2f58a5dda0afb35462dfef42/Sources/Apollo/ResponseCodeInterceptor.swift#L44) (which in turn [calls the `additionalErrorInterceptor` if it exists](https://github.com/apollographql/apollo-ios/blob/a00031c2a357c03a2f58a5dda0afb35462dfef42/Sources/Apollo/RequestChain.swift#L149)) and the chain would not proceed. \r\n\r\nThat would mean `TokenErrorInterceptor` wouldn't get called because an error has already been caught. That's why you have to put it before the `ResponseCodeInterceptor`. \r\n\r\nDoes that help explain why that wouldn't work? Or is there another place where things aren't showing up where you expect them to? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"No Ellen. I was not referring this part. Let's sum up again the thoughts.\r\nThe documentation and you, assures that `additionalErrorInterceptor` gets called, having the error which was collected in any of the interceptors. Which basically means that no matter at which level of the request/response/parsing/etc an error occurs, it will arrive to the `additionalErrorInterceptor`.\r\nNow as mentioned in the initial question, it seems that not all of the errors reach the `additionalErrorInterceptor`. That was my initial test. I just thought it would be the right place to handle all the errors, but got blocked because some of the errors didn't get to it. Check the question again please :).","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"Right, and my question is, what are the errors that are not passed through in your testing? \r\n\r\nNote that if there is an _expected_ error, which is handled by the interceptor (for example, the auto-persisted-query-specific error which is handled by the `AutomaticPersistedQueryInterceptor`), then that is not passed on since that is an error that was expected and handled. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I will try to collect the information tomorrow;)","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"So I can find 2 cases when `additionalErrorInterceptor` is not used:\r\n1. when an interceptor caught the error triggered retry... the example with expired token\r\n2. `GraphQLError` objects which arrive through `GraphQLResults.errors` array.\r\n\r\nBut I guess both of these cases is expected behaviour.","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"You're correct - because a `GraphQLResult` can contain partial results with an error explaining what's missing, simply having `errors` be non-empty doesn't indicate that a request failed. \r\n\r\nYou can see an example of where we're looking for _specific_ errors to handle in that array in the `AutomaticPersistedQueryInterceptor`, and if you know your backend will be returning _specific_ errors you need to handle in that array (for example, token expiration errors there instead of as a 401), you can add your own interceptors to handle those. \r\n\r\nOtherwise, `GraphQLError`s should be returned as part of the `GraphQLResult`.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@odanu Anything else here or can I close this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Oh sorry. All good. I had to close it earlier.","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"👍 Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"How to fix that error?","author":{"__typename":"User","login":"zinminphyo","id":"MDQ6VXNlcjMzMzY4MzQ3","name":"Zin Min Phyo"},"body":"## Bug report\r\n\r\nPlease replace this line with a short description of the problem. Make sure you've read `CHANGELOG.md` in the root of the repo to make sure a new version hasn't already addressed your problem!\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.0\r\n- Swift version: 5\r\n\"Screen\r\n\r\n- Package manager:\r\n\r\n## Steps to reproduce\r\n\r\nPlease replace this line with steps to reproduce the problem.\r\n\r\n## Further details\r\n\r\nPlease replace this line with any further details or context necessary to understand the problem. Delete this section if you don't have anything further to add.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"@zinminphyo Can you please share more details about when and how this happened? It's not something I can necessarily tell you why it's happening without more detail. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since I haven't gotten any further details here, I'm going to close this out. @zinminphyo Please reopen with further details if you have them. Anyone else with a similar problem, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Generate Apollo GraphQL Api Bitrise issue","author":{"__typename":"User","login":"Kevin94singh","id":"MDQ6VXNlcjIxMzQ3NDg5","name":"Kevin Singh"},"body":"Hi,\r\n\r\nWhen building on a local machine with Fastlane, everything works ok. However, when I try to upload my build with Bitrise, I'm getting an error: \r\n\r\n```\r\n- ▸ Running script 'Generate Apollo GraphQL API'\r\n** ARCHIVE FAILED **\r\nThe following build commands failed:\r\n\tPhaseScriptExecution Generate\\ Apollo\\ GraphQL\\ API /Users/vagrant/Library/Developer/Xcode/DerivedData/project_name-asogvanbfzdyhybkhoculdmlwwfk/Build/Intermediates.noindex/ArchiveIntermediates/project_name_beta/IntermediateBuildFilesPath/project_name.build/Release-iphoneos/project_name_beta/Script-7A325491234C77FE003B1AE2.sh\r\n(1 failure)\r\n[11:36:34]: Exit status: 65\r\n```\r\n**Our Generate Apollo GraphQL API script**\r\n\r\n```\r\nSCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\ncd \"${SRCROOT}/ProjectName\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" API.swift\r\n```\r\n\r\n| - project_folder\r\n | project.xcodeproj\r\n | - target_folder \r\n | schema.json\r\n | AppDelegate.swift\r\n | ViewController.swift\r\n | etc...\r\n | - another_folders\r\n | etc...\r\n\r\n**Apollo version: 0.30, iOS, Bitrise Fastlane version 2.7.x ** We have two targets (prod and beta), currently trying to build for Beta.\r\n\r\nI think that there might be an issue with NPM. In our workflow on Bitrise, I've set `run npm command`- `install -g apollo@2.25` - the version I have on my machine. But this step doesn't help. \r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"If you're using `run-bundled-codegen` it shouldn't be an issue with NPM - the bundled codegen downloads Node and all dependencies as a workaround because we were having *so* many problems with NPM. It certainly seems like another issue is happening that's causing the code generation to fail but isn't spitting out a reason correctly. \r\n\r\nI take it things build correctly when you try to run this locally? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> If you're using `run-bundled-codegen` it shouldn't be an issue with NPM - the bundled codegen downloads Node and all dependencies as a workaround because we were having _so_ many problems with NPM. It certainly seems like another issue is happening that's causing the code generation to fail but isn't spitting out a reason correctly.\r\n> \r\n> I take it things build correctly when you try to run this locally?\r\n\r\nYes, when I run this locally with Fastlane, it builds correctly.","author":{"__typename":"User","login":"Kevin94singh","id":"MDQ6VXNlcjIxMzQ3NDg5","name":"Kevin Singh"}},{"__typename":"IssueComment","body":"Weird - and are you using Fastlane on bitrise as well, or something else? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes, we are using Fastlane. Our steps for a workflow are Activate SSH Key, Git Clone repository, and Fastlane (set to a version 2.x.x, that is currently 2.7.1).","author":{"__typename":"User","login":"Kevin94singh","id":"MDQ6VXNlcjIxMzQ3NDg5","name":"Kevin Singh"}},{"__typename":"IssueComment","body":"Cool, thanks for clarifying - how are you setting things to \"beta\" - using a Scheme or a build configuration or some combination thereof? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"We have two schemes - \"beta\" and \"prod\". Each has its own target. The script is implemented in both targets .","author":{"__typename":"User","login":"Kevin94singh","id":"MDQ6VXNlcjIxMzQ3NDg5","name":"Kevin Singh"}},{"__typename":"IssueComment","body":"And am I correct in assuming the `.graphql` files and `API.swift` output are in the same folder (under `\"${SRCROOT}/ProjectName\"`), just shared between both targets? \r\n\r\nHonestly, if it's working locally and the only error info you're getting from Bitrise is a generic exit code 65, I'm not sure how much help I can be - you may want to reach out to them to see if you can get more detailed logs about what's not building on your beta version. \r\n\r\nOne thing I have tried in the past when something's building locally but not on CI for me is to check it back out in a separate folder and try from there - I've definitely found issues where there's some kind of local config not checked into version control that means it works in your main working directory, but not for anyone else (including CI) that checks it out. Probably worth a shot just to rule that out as a cause.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes, it is shared between both targets. Prod build shows the same failure as a beta. \r\n\r\nI'll try to get more detailed logs and let you know. Thank you for your time! 😊","author":{"__typename":"User","login":"Kevin94singh","id":"MDQ6VXNlcjIxMzQ3NDg5","name":"Kevin Singh"}}]}},{"__typename":"Issue","title":"callbackQueue is not used in WebSocketTransport","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"},"body":"## Bug report\r\n\r\nhttps://github.com/apollographql/apollo-ios/blob/185d6b784538691b5a4287c25df9cae140abec02/Sources/ApolloWebSocket/WebSocketTransport.swift#L361 callbackQueue is unused\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36.0\r\n\r\n## Steps to reproduce\r\n\r\nsubscribe using any callbackQueue, callback is done on some internal one","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Welp, that's embarrassing. Fix is up in #1507. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"thanks","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"Thank YOU for catching it","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"WebSocketTransport.send completionHandler is called in non escaping manner in case of error","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"},"body":"## Bug report\r\n\r\nhttps://github.com/apollographql/apollo-ios/blob/185d6b784538691b5a4287c25df9cae140abec02/Sources/ApolloWebSocket/WebSocketTransport.swift#L364\r\n\r\ncompletionHandler is called in non escaping manner in case of error\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36.0","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Do you mean it's not called on the callback queue? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Was thinking about @escaping but yes, calling it on callback cue would fix that","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"It's declared as [`@escaping` here](https://github.com/apollographql/apollo-ios/blob/185d6b784538691b5a4287c25df9cae140abec02/Sources/ApolloWebSocket/WebSocketTransport.swift#L362) - declaring escaping does not require it to escape, though. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"sure, but it might break flow depending on what's happening internally\r\n\r\n```swift\r\nWebSocketTransport.send {\r\n print(\"a\")\r\n}\r\n\r\nprint(\"b\")\r\n```\r\n\r\nwhat order will be output depends on internal state and that's not great.\r\n\r\nIn any case, closing as https://github.com/apollographql/apollo-ios/pull/1507 fixes it","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}}]}},{"__typename":"Issue","title":"Compatibility issues on Linux with CommonCrypto","author":{"__typename":"User","login":"abdimaye","id":"MDQ6VXNlcjI5MDIzNzI2","name":null},"body":"## Feature request\r\n\r\nThe CommonCrypto module is only available in Xcode 10+. It would be nice to have this replaced with an open source module such that the apollo client can run on other platforms.\r\n\r\n## Motivation\r\n\r\nWe are currently trying to run parts of our codebase on Linux.\r\n\r\n## Proposed solution\r\n\r\nReplace CommonCrypto with an open source library. There are only two files in ApolloCore that use it and the diff wouldn't be that big. \r\n\r\nI was looking at `swift-crypto` https://swift.org/blog/crypto/ but there are compatibility issues where it requires mocos 10.15 and apollo requires 10.10. \r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"We don't *officially* support Linux, but I would very much like to. My thought is that we could make some kind of protocol that uses `swift-crypto` for Linux band still uses `CommonCrypto` on iOS etc. Would be more than open to a PR if you have some time, I'm buried at the moment. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Apollo CLI step fails to locate SourcePackages directory ","author":{"__typename":"User","login":"alcamla","id":"MDQ6VXNlcjI5MDQ1Mjk=","name":"Alejandro Camacho"},"body":"## Bug report\r\n\r\nI am following the steps on the tutorial for iOS. I added Apollo to the project using SPM. After adding the corresponding CLI script, and building the project, I get the following error: \r\n`error: Unable to locate SourcePackages directory from BUILD_ROOT: '/Users/myUser/Library/Developer/Xcode/DerivedData/Build/Products'`\r\nI have noticed that BUILD_ROOT is set to that folder directly, so there is no chance that the while loop finds the SourcePackages folder. I am running on Xcode 12.1\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36\r\n- Xcode version: 12.1\r\n- Swift version: 5.3\r\n- Package manager: Swift package manager\r\n\r\n## Steps to reproduce\r\n\r\n1. Create project\r\n2. Add Apollo dependency using SPM\r\n3. Add new run script phase with the code generation build step for SPM\r\n4. Modify the last line to download the schema on first run\r\n5. Build the project \r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Ugh, I bet they changed the damned location of the source packages in 12.1 - it's definitely undocumented. \r\n\r\nI'll get a look at this tomorrow, but I think I'm going to recommend trying the [Swift Scripting Setup](https://www.apollographql.com/docs/ios/swift-scripting/) - that doesn't have any dependency on going diving through the derived data folder. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}}]}}}} +{"data":{"repository":{"__typename":"Repository","name":"apollo-ios","issues":{"__typename":"IssueConnection","nodes":[{"__typename":"Issue","title":"Xcode 12 Beta Archive issue ","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"},"body":"I failed to archive app with 12.0 beta 2 and I found that other libraries have similar issues.\r\n\r\n- https://github.com/airbnb/lottie-ios/issues/1214\r\n- https://github.com/Alamofire/Alamofire/issues/3240\r\n\r\n# Error message\r\n\r\n```\r\nUndefined symbols for architecture armv7:\r\n \"type metadata for Swift._StringObject.Variant\", referenced from:\r\n outlined init with take of Swift._StringObject.Variant in ApolloStore.o\r\nld: symbol(s) not found for architecture armv7\r\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\r\n```\r\n\r\n# Environment\r\nApollo version: 0.28.0\r\nXcode version: 12.0 beta 2 (12A6163b)\r\nSwift version: 5.3 (swiftlang-1200.0.16.13 clang-1200.0.22.25)\r\nPlatform(s) running Apollo: iOS\r\nmacOS version running Xcode: 10.15.5","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Weird! I'm literally testing the new beta right now, and I was just able to build and test `0.29.1` with Xcode 12 b2 without any problem. Have you cleaned your build folder and/or done the [derived data dance](http://derivedata.dance) recently? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":">Have you cleaned your build folder and/or done the derived data dance recently?\r\n\r\nI've tried it but it hasn't helped...\r\n\r\nCould you try setting the build configuration to release? ~~It seems that the optimization level is related.~~ Or try archive.","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"}},{"__typename":"IssueComment","body":"Can't really do archive on a framework, but can confirm this is showing up if I switch the Run action to build for release. \r\n\r\nIt looks like the issue is [some kind of bug with substrings in the beta](https://developer.apple.com/forums/thread/649918?answerId=614735022#614735022). Unfortunately because we support older versions of iOS, disabling armv7 support in the library isn't really a good option for us. \r\n\r\nIt also looks like the workaround for our library isn't as simple as [Lottie's](https://github.com/airbnb/lottie-ios/pull/1215) - we're not using `prefix` and `suffix` methods on `String` anywhere in the main `Apollo` lib, and I'm getting an error on compilation in release mode with a totally different file than you are (`GraphQLResultNormalizer.o`) that's not doing any super-obvious string manipulation. \r\n\r\nIf you have some time to dig around, I'd encourage you to. At this point I've got enough on my plate that something clearly acknowledged by Apple as a bug and which only affects release builds on a beta Xcode is not going to be something I prioritize digging into on my own. Will definitely check back in on this with subsequent beta releases though. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"https://github.com/zhangao0086/DKImagePickerController/issues/669","author":{"__typename":"User","login":"OmarJalil","id":"MDQ6VXNlcjI1NTIwMDE1","name":"Jalil"}},{"__typename":"IssueComment","body":"@designatednerd Thank you for your research. I want to wait for this bug to be fixed in a future Xcode version.","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"}},{"__typename":"IssueComment","body":"I am experiencing this issue as well, which prevented Carthage from building Apollo. I mentioned the issue in the Xcode 12 thread: https://github.com/apollographql/apollo-ios/pull/1280\r\n\r\nI fixed the issue here: https://github.com/danl3v/apollo-ios/tree/0.29.1-xcode12 and it works fine. Feel free to cherry-pick the latest commit to another version of apollo as required. Hopefully Apple will fix its substring issue","author":{"__typename":"User","login":"danl3v","id":"MDQ6VXNlcjg4MzE4OA==","name":"Daniel Levy"}},{"__typename":"IssueComment","body":"Xcode 12 beta 3 just came out, and I am now no longer able to reproduce this by switching the run action to build for release. \r\n\r\n@danl3v @nkmrh Can you please confirm that this is no longer an issue on the `betas/xcode-12` branch for you? Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Will do early next week","author":{"__typename":"User","login":"danl3v","id":"MDQ6VXNlcjg4MzE4OA==","name":"Daniel Levy"}},{"__typename":"IssueComment","body":"@designatednerd @danl3v I confirmed the issue on the `betas/xcode-12 ` branch with Xcode 12.0 beta 3. Unfortunately the one reproduced :(","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"}},{"__typename":"IssueComment","body":"@nkmrh Weird! Did you do `Clean Build Folder` before trying to archive? I double-checked that I'd done that before trying to do the run action as build for release and it still worked. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I checked the betas/xcode-12 branch again and the build was successful but when I add it to a simple project with cocoapods, it still fails to build... (archive is still failing)","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"}},{"__typename":"IssueComment","body":"Interesting....I'll poke at that today. Thanks!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I tried it with Xcode 12 beta 4, it solved!","author":{"__typename":"User","login":"nkmrh","id":"MDQ6VXNlcjU2NDQ0MjA=","name":"Hajime Nakamura"}},{"__typename":"IssueComment","body":"Excellent! I'm going to close this issue out then - if anyone has issues archiving on Beta 4 or after, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Beta 4 works for us!","author":{"__typename":"User","login":"danl3v","id":"MDQ6VXNlcjg4MzE4OA==","name":"Daniel Levy"}}]}},{"__typename":"Issue","title":"[Web] - Installation panel doesn't expand content","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"},"body":"![image](https://user-images.githubusercontent.com/7384288/86875928-2ad0f500-c116-11ea-8d1f-804f25c74d0f.png)\r\n\r\nClicking the Installation panel doesn't show the content.\r\n\r\nChrome 83.0.4103.116 64-bit","comments":{"__typename":"IssueCommentConnection","nodes":[]}},{"__typename":"Issue","title":"[Web] - Installation panel doesn't expand content","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"},"body":"![image](https://user-images.githubusercontent.com/7384288/86875928-2ad0f500-c116-11ea-8d1f-804f25c74d0f.png)\r\n\r\nClicking the Installation panel doesn't show the content.\r\n\r\nChrome 83.0.4103.116 64-bit","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Oops! I'll let our docs team know, thank you for the heads up!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Fixed by https://github.com/apollographql/apollo-ios/pull/1306\r\n\r\nCheck it out here: https://www.apollographql.com/docs/ios/installation/","author":{"__typename":"User","login":"trevorblades","id":"MDQ6VXNlcjEyMTY5MTc=","name":"Trevor Blades"}},{"__typename":"IssueComment","body":"Thanks @trevorblades, you rock!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"通过 CocoaPods 导入 Apollo 丢失 WebSocket","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null},"body":"通过 CocoaPods 导入 Apollo 丢失 WebSocket\r\nPodfile 文件中添加 pod 'Apollo', '~> 0.29.0' 执行pod install 完成后 在工程 Pods 中 只有 Apollo/Core 文件 无法找到 Apollo/WebSocket \r\n引用 import ApolloWebSocket 报错 \" No such module 'ApolloWebSocket' \"\r\n\r\n如下图:\r\nPodfile文件:\r\n\"WeChatf75880a9f15d2f78d3d97ec0cd4bc4d9\"\r\n\r\npod search Apollo\r\n\"pod_search_apollo\"\r\n\r\npod install 完成后\r\n\"pod_install\"\r\n\r\n使用代码\r\n\"code\"\r\n\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Google translated:\r\n\r\n> Importing Apollo via CocoaPods loses WebSocket\r\n> Add pod'Apollo' in the Podfile file,'~> 0.29.0' After executing pod install, only Apollo/Core files cannot be found in the project Pods.\r\n> Quoting import ApolloWebSocket reports error \"No such module'ApolloWebSocket'\"\r\n>\r\n> As shown below:\r\n> Podfile\r\n\r\nYou need to add the `Apollo/WebSocket` subspec in order to access the WebSocket library - it is not included by default, only the core libraries are included by default. So your podfile should look like this if you want to use the web socket library: \r\n\r\n```\r\npod 'Apollo', '~>0.29.0'\r\npod 'Apollo/WebSocket', '~>0.29.0'\r\n```","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"ok","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null}}]}},{"__typename":"Issue","title":"Figure out how to test cache key generation with JSON objects","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"},"body":"#1281 addresses an issue where cache keys were being unstably generated when one of the items was a JSON array. I haven't been able to find an API that takes JSON arrays, so we need to find an alternate method of testing key generation for this. Don't want to hold up an actual fix for the issue until I can figure this out, so making this issue to come back to it.","comments":{"__typename":"IssueCommentConnection","nodes":[]}},{"__typename":"Issue","title":"Fatal error (\"Optional is only JSONEncodable if Wrapped is\") when trying to update SqlNormalizedCache manually after a successful mutation operation","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"},"body":"While using Apollo iOS 0.29.1, I appear to be running into an issue similar to the one reported [here](https://github.com/apollographql/apollo-ios/issues/1271). I asked for help with this issue in [Spectrum](https://spectrum.chat/apollo/apollo-ios/updating-cache-after-insert-mutation~71008cf0-6ccf-4474-95bb-ac22c83e9616), and @designatednerd asked me to create a new issue.\r\n\r\nI'm trying to update the SqlNormalizedCache (which is setup and working properly) using the result of a successful mutation operation:\r\n\r\n```\r\napollo.perform(mutation: InsertTaskResponseMutation(taskId: 1, response: \"\")) { result in\r\n guard\r\n let resultData = try? result.get().data,\r\n let taskResponseDetails = resultData.insertTaskResponses?.returning.first?.fragments.taskResponseDetails\r\n else {\r\n return\r\n }\r\n\r\n apollo.store.withinReadWriteTransaction({ transaction in\r\n try! transaction.write(object: taskResponseDetails, withKey: \"task_responses-\\(taskResponseDetails.id)\")\r\n })\r\n}\r\n```\r\n\r\nThis is throwing a fatal error in \"JSONStandardTypeConversions.swift\" at line 109:\r\n\r\n\"Screen\r\n\r\nPrinting the description of `self`:\r\n\r\n```\r\nPrinting description of self:\r\n▿ Optional\r\n - some : 07/08/2020\r\n```\r\n\r\nIn this case, `self` is a property on the `response` property, which is a custom `jsonb` type. Here's the type alias:\r\n\r\n```\r\npublic typealias jsonb = [String : Any?]\r\n\r\nextension Dictionary: JSONDecodable {\r\n public init(jsonValue value: JSONValue) throws {\r\n guard let dictionary = value as? Dictionary else {\r\n throw JSONDecodingError.couldNotConvert(value: value, to: Dictionary.self)\r\n }\r\n \r\n self = dictionary\r\n }\r\n}\r\n```\r\n\r\nAnd here's the query:\r\n\r\n```\r\nquery ChallengeTaskResponse($taskResponseId: Int) {\r\n challenge_responses(where: {id: {_eq: $taskResponseId}}) {\r\n ...ChallengeTaskResponseDetails\r\n }\r\n}\r\n```\r\n\r\nThe mutation:\r\n\r\n```\r\nmutation InsertTaskResponse($response: jsonb) {\r\n insert_task_responses(objects: {response: $response}) {\r\n returning {\r\n ...TaskResponseDetails\r\n }\r\n }\r\n}\r\n```\r\n\r\nAnd, finally, the fragment that's used by both the query and the mutation:\r\n\r\n```\r\nfragment TaskResponseDetails on task_responses {\r\n id\r\n response // The 'jsonb' custom data type\r\n}\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"The problem definitely seems to be in the fact that the value type in the dictionary is `Optional`, and that's what it's trying to use to create a key. \r\n\r\nDoes it work to typealias it to `[String: JSONDecodable?]` instead?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'll test that here shortly and report back.","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"@nateirwin Were you ever able to get this tested out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd: I started to dive into this, ran into a minor issue (that's project-specific and I just need to push through), then got pulled into another issue altogether. This is still critical for our project and it's next on my list, so I'll get to it soon.\r\n\r\nI'm happy to close this and re-open when I've had the chance to test, if that's helpful.","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Nah, leave it open for now, I'll keep annoying you about it from time to time 😇","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Ok, reporting back :-)\r\n\r\nSwitching the typealias to `public typealias jsonb = [String : JSONDecodable?]` throws an error when loading a query that has a `jsonb` property on it:\r\n\r\n```\r\nPrinting description of error:\r\n▿ GraphQLResultError\r\n ▿ path : communities.0.organization_community_memberships.1.organization.paper_maps.0.paper_map.status\r\n ▿ head : Optional\r\n ▿ some : \r\n ▿ underlying : JSONDecodingError\r\n ▿ couldNotConvert : 2 elements\r\n ▿ value : 24 elements\r\n ▿ 0 : 2 elements\r\n - key : status\r\n - value : Uploading tiles complete\r\n ▿ 1 : 2 elements\r\n - key : min_zoom\r\n - value : 9\r\n ▿ 2 : 2 elements\r\n - key : extent_max_lon\r\n - value : -100.1\r\n ▿ 3 : 2 elements\r\n - key : extent_min_lat\r\n - value : 37.1\r\n ▿ 4 : 2 elements\r\n - key : tileset\r\n - value : tileset_548\r\n ▿ 5 : 2 elements\r\n - key : pdfPath\r\n - value : https://test.xyz/test.pdf\r\n ▿ 6 : 2 elements\r\n - key : updated_at\r\n - value : 2019-07-29T15:04:09.623Z\r\n ▿ 7 : 2 elements\r\n - key : extent_max_lat\r\n - value : 34.1\r\n ▿ 8 : 2 elements\r\n - key : localTilesPath\r\n - value : https://test.xyz/tiles/\r\n ▿ 9 : 2 elements\r\n - key : geotiff_path\r\n - value : /image_georef.tif\r\n ▿ 10 : 2 elements\r\n - key : geotiff_3857_path\r\n - value : /image_georef_3857.tif\r\n ▿ 11 : 2 elements\r\n - key : name\r\n - value : Name Here\r\n ▿ 12 : 2 elements\r\n - key : max_zoom\r\n - value : 15\r\n ▿ 13 : 2 elements\r\n - key : id\r\n - value : 548\r\n ▿ 14 : 2 elements\r\n - key : temp_georefTilesPath\r\n - value : \r\n - super : NSObject\r\n ▿ 15 : 2 elements\r\n - key : ground_control_points\r\n - value : [[1071.640625,2925.1640625,-122.104733996093,37.714753539402],[1355.44921875,2053.29296875,-122.09752430208,37.7391649876836],[1192.0390625,1299.8125,-122.105021746829,37.7592430319794],[669.765625,594.1796875,-122.124813348055,37.7770496273366]]\r\n ▿ 16 : 2 elements\r\n - key : png_path\r\n - value : /final.png\r\n ▿ 17 : 2 elements\r\n - key : page_number\r\n - value : { ... }\r\n ▿ 18 : 2 elements\r\n - key : image_width\r\n - value : 2550\r\n ▿ 19 : 2 elements\r\n - key : created_at\r\n - value : 2019-07-29T14:57:07.796Z\r\n ▿ 20 : 2 elements\r\n - key : georefTilesPath\r\n - value : https://test.xyz/tiles_georef\r\n ▿ 21 : 2 elements\r\n - key : image_height\r\n - value : 3300\r\n ▿ 22 : 2 elements\r\n - key : extent_min_lon\r\n - value : -115.1\r\n ▿ 23 : 2 elements\r\n - key : file_type\r\n - value : pdf\r\n - to : Swift.Dictionary>\r\n```\r\n\r\nI'm guessing maybe it's bonking on the `null` values? Honestly, we've run into so many issues with this custom `jsonb` scalar type that I'm considering trying to back out of using it altogether.","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Hm, shouldn't be bonking on nulls, we've got something that [theoretically should be handling that](https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/JSONStandardTypeConversions.swift#L89). From the underlying error it looks like it's freaking out about the `status` key which is just a String. \r\n\r\nI think a bigger question this brings up is why this data needs to be returned as an arbitrary JSON blob in the first place - why isn't this data returned as something typed? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Well, `status` is the name of the `jsonb` property, which (I think) should be of type `[String: JSONDecodable?]` because of the type alias:\r\n\r\n```\r\npublic typealias jsonb = [String : JSONDecodable?]\r\n\r\nextension Dictionary: JSONDecodable {\r\n public init(jsonValue value: JSONValue) throws {\r\n guard let dictionary = value as? Dictionary else {\r\n throw JSONDecodingError.couldNotConvert(value: value, to: Dictionary.self)\r\n }\r\n \r\n self = dictionary\r\n }\r\n}\r\n```\r\n\r\nThat's why I'm scratching my head about this. Maybe my next step is setting some more breakpoints in JSONStandardTypeConversions.swift?","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Looking at the JSON, `status` seems to be a key and value of the dictionary which isn't getting deserialized - can you throw in a breakpoint and print out the raw JSON string (or use a proxying tool to see it) that's coming through? That might help.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Sure, here you go (sorry about the delay):\r\n\r\n```\r\n{\r\n \"data\": {\r\n \"communities\": [\r\n {\r\n \"organization_community_memberships\": [\r\n {\r\n \"id\": 467,\r\n \"organization\": {\r\n \"paper_maps\": [\r\n {\r\n \"id\": 557,\r\n \"paper_map\": {\r\n \"description\": \"null\",\r\n \"id\": 322,\r\n \"name\": \"Name Here\",\r\n \"status\": {\r\n \"id\": 548,\r\n \"name\": \"Name Here\",\r\n \"status\": \"Uploading tiles complete\",\r\n \"pdfPath\": \"https://test.xyz/test.pdf\",\r\n \"max_zoom\": 15,\r\n \"min_zoom\": 9,\r\n \"png_path\": \"/final.png\",\r\n \"file_type\": \"pdf\",\r\n \"created_at\": \"2019-07-29T14:57:07.796Z\",\r\n \"updated_at\": \"2019-07-29T15:04:09.623Z\",\r\n \"image_width\": 2550,\r\n \"page_number\": null,\r\n \"geotiff_path\": \"/image_georef.tif\",\r\n \"image_height\": 3300,\r\n \"extent_max_lat\": \"34.1\",\r\n \"extent_max_lon\": \"-100.1\",\r\n \"extent_min_lat\": \"37.1\",\r\n \"extent_min_lon\": \"-115.1\",\r\n \"localTilesPath\": \"https://test.xyz/tiles/\",\r\n \"mapbox_tileset\": \"trailheadlabs.paper_map_548\",\r\n \"georefTilesPath\": \"https://test.xyz/tiles_georef\",\r\n \"geotiff_3857_path\": \"/image_georef_3857.tif\",\r\n \"temp_georefTilesPath\": null,\r\n \"ground_control_points\": \"[[1071.640625,2925.1640625,-122.104733996093,37.714753539402],[1355.44921875,2053.29296875,-122.09752430208,37.7391649876836],[1192.0390625,1299.8125,-122.105021746829,37.7592430319794],[669.765625,594.1796875,-122.124813348055,37.7770496273366]]\"\r\n }\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n }\r\n ]\r\n }\r\n}\r\n```","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Ah, ok, `status` is _also_ the name of the property of the dictionary, not just one of the things in the dictionary. \r\n\r\nOne thing it didn't occur to me to ask: Is your `Dictionary` initializer getting hit at all? I wonder if it may need to be constrained to the key and value types you're using","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"It is getting hit, and it's throwing when that same `status` property that holds the dictionary.","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Here's a thought - have you got an extension that implements `JSONEncodable`? It looks like you're only implementing `JSONDecodable` above","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hmm, this is what I get when I start to implement `JSONEncodable`:\r\n\r\n\"Screen","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"Aha, [that is indeed implemented in the library](https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/JSONStandardTypeConversions.swift#L114). \r\n\r\nOK, I'll mess around with this some to try and figure out what's going on here. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks for your help!","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"@nateirwin please try pulling the branch #1317 is opened from and seeing if that fixes your issue. You can put the `typealias` back to `[String: Any?]`. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yep, that fixes the issue!!!","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}},{"__typename":"IssueComment","body":"This has shipped with `0.30.0` - ready to go for SPM and Carthage, in the process of pushing to trunk on Cocoapods. 🎉","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"More generalized types","author":{"__typename":"User","login":"TimBroddin","id":"MDQ6VXNlcjUyODI4Nw==","name":"Tim Broddin"},"body":"Hi,\r\n\r\nI'm kinda new to Apollo iOS, so sorry if my question is kinda stupid. I'm passing a lot of data around in my (SwiftUI) app and the typing kinda drives me crazy. Right now I'm accepting arguments with types like `LetterPartsQuery.Data.ArtistsSplittedInLetterPart.Artist` & `HomePageQuery.Data.Post.Artist` and it's becoming harder and harder to manage this. \r\n\r\nWhat's the quickest way to having easier types to juggle arround (like just `Artist` in my example above).\r\n\r\nThanks a lot!","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I'm a firm believer in \"There's no such thing as a stupid question, only an asshole answer.\" 😇 That said, this is definitely NOT a stupid question. \r\n\r\nOne thing that helps explain the way we generate this code is that for each operation, we only want to make available those properties and types that you've actually requested, rather than all possible properties and types. This means we have some fairly nested structures like the ones you're seeing. \r\n\r\nOne work around for this is to use [GraphQL fragments](https://graphql.org/learn/queries/#fragments). Our codegen will take anyplace that uses a fragment and generate a fragment type that can be reused across multiple operations. \r\n\r\nThey're still more annoying to use than I'd like (this is something I'm working on in Swift Codegen, but that's slightly blocked at the moment), but they are at least the same reusable type. \r\n\r\nDoes that help? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks a lot! This will make my code readable again 😄 ","author":{"__typename":"User","login":"TimBroddin","id":"MDQ6VXNlcjUyODI4Nw==","name":"Tim Broddin"}}]}},{"__typename":"Issue","title":"Serialize or recreate mutation","author":{"__typename":"User","login":"pggawlowski","id":"MDQ6VXNlcjY0OTY2OTU2","name":null},"body":"What I am trying to achieve is mutation archivization. \r\nMy first try was NSKeyedArchiver.archivedData, however currently it is impossible. \r\nSo I decided to try to serialize and store jsonObject and/or variables and later, when back online, recreate mutation query.\r\n\r\n```\r\nlet object = mutation.variables?.jsonObject ?? [:]\r\ndo {\r\n let recreatedMutation = try TestMutation.Data(jsonObject: object, variables: nil)\r\n} catch {\r\n print(error)\r\n}\r\n```\r\n\r\nHowever it results in `Apollo.JSONDecodingError.missingValue`\r\n\r\nAny suggestions how to serialize and store mutations/queries or recreate them from stored data.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It'd probably help for me to understand the use case - why do you need to persist the mutation itself?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"We have to deal with cache sync. So one concept is to introduce some kind of mutations persistency. Currently we are successfully mutating cache but we also have to push it away when connection is restored.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"I think I'm a bit confused - are you talking about persisting the **result** of a mutation, or the mutation itself? \r\n\r\nWhat I think is happening is that you're trying to persist the mutation itself so you can push changes you've made locally up to a server. Is that correct? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Exactly! :) ","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"So part of the problem is that you're trying to use the nested `TestMutation.Data` type - that type is used for recreating the **result** of the mutation, not the mutation itself. \r\n\r\nYou basically have to create the mutation the same way you would have if you weren't making it locally. So if your generated initializer is `TestMutation(parameter: String)`, then you want to persist the value of `parameter` and then send that mutation again. \r\n\r\nWhat you're trying to do is persist the variables JSON object, but there isn't an initializer for queries that takes that JSON object that you can pass what you're saving directly to. You could probably make a throwing initializer (in another file so it doesn't get overwritten by codegen) for the mutation that pulls that JSON back out, then tries to make the appropriate query from the JSON. \r\n\r\nYou'd have to have some notion of what query the JSON was for, though - it might be better to have some custom `Codable` types that can persist information about both the query type and the parameter values you need to persist. \r\n\r\nThere is definitely not a built-in way to do this, though. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@pgawlowski Anything else I can help with here? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"It's fine. Thank you very much! ","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"Cool - I'm going to close this issue out then. Thanks!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"How Can I set authorisation header for Apollo Client?","author":{"__typename":"User","login":"Prathap-iOS","id":"MDQ6VXNlcjU4Mzk2NTI2","name":"Prathap Reddy"},"body":"I am using Apollo Client. I got the access token after login. I have set the access token as authorisation header like this.\r\n\r\nfunc setApolloClient(accessToken: String) {\r\n self.apolloClient = {\r\n let authPayloads = [\"Authorization\": \"Bearer \\(accessToken)\"]\r\n let configuration = URLSessionConfiguration.default\r\n configuration.httpAdditionalHeaders = authPayloads\r\n configuration.requestCachePolicy = .reloadIgnoringLocalCacheData\r\n let endpointURL = URL(string: graphEndpoint)!\r\n return ApolloClient(networkTransport: HTTPNetworkTransport(url: endpointURL))\r\n }()\r\n }\r\n\r\nI am sending this authorisation header to a query to get the user details. It return success. But, I have no idea where it went wrong. I am not getting user details. I am getting Try again later. @designatednerd Is there any other way to set authorisation header?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I suspect \r\n\r\n```swift\r\nlet authPayloads = [\"Authorization\": \"Bearer (accessToken)\"]\r\n``` \r\n\r\nshould be \r\n\r\n```swift\r\nlet authPayloads = [\"Authorization\": \"Bearer \\(accessToken)\"]`\r\n```\r\n\r\nOtherwise you're sending the literal string `(accessToken)` as your access token rather than using string interpolation, which looks like what you want to do. \r\n\r\nIf that's not the issue, let me know and I can dig deeper - other than that your setup seems pretty straightforward. \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I used let authPayloads = [\"Authorization\": \"Bearer \\ (accessToken)\"]. But this one also not working.","author":{"__typename":"User","login":"Prathap-iOS","id":"MDQ6VXNlcjU4Mzk2NTI2","name":"Prathap Reddy"}},{"__typename":"IssueComment","body":"You still need the `\\` before the first paren in `(accessToken)`, otherwise it'll be sent as a string literal. \r\n\r\nAre you able to use a proxy tool like [Charles](https://www.charlesproxy.com/) or [MiTM Proxy](https://mitmproxy.org/) to see what the final headers going out over the network are? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yeah I used \\ before (accessToken). But There is no proper result. I am not using any proxies.","author":{"__typename":"User","login":"Prathap-iOS","id":"MDQ6VXNlcjU4Mzk2NTI2","name":"Prathap Reddy"}},{"__typename":"IssueComment","body":"I was asking if you could try using a proxy to see if you can see what the final headers are - that way you can see exactly what's going over the network. \r\n\r\nI would also double check with your backend that they take the token as a `Bearer` token - that's standard practice, but I've definitely seen a lot of backends that don't adhere to that.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd my backend team is following the same standard. They taken token as **Bearer** token.","author":{"__typename":"User","login":"Prathap-iOS","id":"MDQ6VXNlcjU4Mzk2NTI2","name":"Prathap Reddy"}},{"__typename":"IssueComment","body":"OK I was double checking what you're doing, and I missed the most obvious thing: The `URLSessionConfiguration` is not being passed into anything, so the configuration you're correctly setting up is not being given to anything to be used. Instead of this at the very end: \r\n\r\n```swift\r\nreturn ApolloClient(networkTransport: HTTPNetworkTransport(url: endpointURL))\r\n```\r\n\r\ntry this: \r\n\r\n```swift\r\nlet client = URLSessionClient(sessionConfiguration: configuration)\r\nreturn ApolloClient(networkTransport: HTTPNetworkTransport(url: endpointURL), client: client)\r\n```","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd Thanks. It's working fine. \r\n\r\nHere is my working code for setting up authorization header.\r\n\r\n`func getApolloClient(headerRequired:Bool = true) -> ApolloClient {\r\n let tokenValue = SessionManager.shared.getToken().TokenValue\r\n let authPayloads = [\"Authorization\": \"Bearer \\(tokenValue)\"]\r\n let configuration = URLSessionConfiguration.default\r\n configuration.httpAdditionalHeaders = authPayloads\r\n configuration.requestCachePolicy = .reloadIgnoringLocalCacheData\r\n let client = URLSessionClient(sessionConfiguration: configuration)\r\n let endpointURL = URL(string: graphEndpoint)!\r\n return ApolloClient(networkTransport: HTTPNetworkTransport(url: endpointURL, client: client))\r\n }`","author":{"__typename":"User","login":"Prathap-iOS","id":"MDQ6VXNlcjU4Mzk2NTI2","name":"Prathap Reddy"}},{"__typename":"IssueComment","body":"@Prathap-iOS great! Mind if we close this out?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since @Prathap-iOS has noted that solution works, I'm going to go ahead and close this out. If you're having a similar problem, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"How to use the --passthrough-custom-scalar flag","author":{"__typename":"User","login":"ijl0322","id":"MDQ6VXNlcjE1OTAxNTMx","name":"Isabel Lee"},"body":"Hi, \r\n\r\nI'm trying to use the --passthrough-custom-scalar flag:\r\n\r\n`\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --passthrough-custom-scalar --localSchemaFile=\"schema.json\" API.swift`\r\n\r\nAnd getting this error `Error: Unexpected argument: API.swift`\r\n\r\nI'm using Apollo 0.29.1 and Xcode 11.5. Any help would be appreciated, Thanks!\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It's `--passthroughCustomScalars`, Pascal case instead of kebab case and plural instead of singular. I think that may be causing the parsing to fail.\r\n\r\nIf fixing that doesn't fix it, I'd switch it to after `--localSchemaFile` - that might be looking for multiple arguments but I can't remember off the top of my head. \r\n\r\nLet me know which one (or both) works!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"The Pascal case works !! Thank you so much for your help! ","author":{"__typename":"User","login":"ijl0322","id":"MDQ6VXNlcjE1OTAxNTMx","name":"Isabel Lee"}}]}},{"__typename":"Issue","title":" Getting 'No operations found to generate` error when trying to use `ID` in query","author":{"__typename":"User","login":"dpatel-git","id":"MDQ6VXNlcjY4NDM2NTk1","name":null},"body":"I am working on an iOS application to communicate with our GraphQL backend using Apollo's GraphQL library. With the query below, I am able to generate Swift code that I can use to query backend.\r\n\r\n`query mobileApp {\r\n app(id: \"content/mobileApp\") {\r\n title\r\n } \r\n}`\r\n\r\nI am using the following commands to generate Swift code\r\n\r\n`../../Pods/Apollo/scripts/apollo/bin/run client:codegen --target=swift --includes ../app.graphql --localSchemaFile=./downloaded_schema.json API.swift`\r\n\r\nHowever, if I replace the string literal passed into the app(...) with ID like this\r\n\r\n`query mobileApp {\r\n app(id: ID!) {\r\n title\r\n } \r\n}`\r\n\r\nrunning the same codegen command fails with the following error.\r\n\r\n`Generating query files with 'swift' target\r\n → No operations or fragments found to generate code for.\r\nError: No operations or fragments found to generate code for.\r\n at write (~/Downloads/ios-app/Pods/Apollo/scripts/apollo/lib/commands/client/codegen.js:65:39)\r\n at Task.task (~/Downloads/ios-app/Pods/Apollo/scripts/apollo/lib/commands/client/codegen.js:90:46)`\r\n\r\nIt seems that the script is not able to find a declaration of ID. Hoping that someone can point me in the right direction, thanks","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I'm not sure why it's saying there are no operations rather than there's an error in your declaration, but there's an error in your declaration. \r\n\r\nTo pass in a parameter, you need to declare that parameter in the query's declaration, then pass it into the query itself: \r\n\r\n```graphql\r\nquery mobileApp($id: ID!) { \r\n app(id: $id) {\r\n title\r\n }\r\n}\r\n```\r\n\r\nHope that gets you going!\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I think codegen script could be defaulting to `No Operations ...` error if it's able to come to a conclusion. \r\n\r\nAnyways, making the changes you suggested fixed the error.\r\n\r\nSuper thanks.","author":{"__typename":"User","login":"dpatel-git","id":"MDQ6VXNlcjY4NDM2NTk1","name":null}}]}},{"__typename":"Issue","title":"Fragments imported into multiple graphql queries","author":{"__typename":"User","login":"piv199","id":"MDQ6VXNlcjgyOTMxOTE=","name":"Olexii Pyvovarov"},"body":"Hi, quite new to graphql and trying to establish best practices in the project.\r\n\r\nHave found an article about fragments: https://www.apollographql.com/docs/ios/fragments/\r\n\r\nI wonder whether there is an ability to import Fragment.graphql (which defines fragment only) into another graphql file with query that uses that fragment?\r\n\r\n```\r\nFragment.graphql\r\nfragment A { }\r\n```\r\n\r\n```\r\nQuery.grapqhl\r\nquery {\r\n property {\r\n ...A\r\n }\r\n}\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Yep, as long as they're in the same module you should be able to do that!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"(you won't need to import fragment.graphql, the codegen should be able to see all fragments defined in the module)","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd Thanks! Sorry for opening the issue... I did all right but the problem was in fragment naming - it was the same as model entity thus I had segmentation fault and not found errors... Thanks for help!\r\n","author":{"__typename":"User","login":"piv199","id":"MDQ6VXNlcjgyOTMxOTE=","name":"Olexii Pyvovarov"}}]}},{"__typename":"Issue","title":"Keys with nil values are removed","author":{"__typename":"User","login":"docallag","id":"MDQ6VXNlcjM1MzIzMQ==","name":"David O'Callaghan"},"body":"Hi,\r\nI'm just wondering why keys with nil values are removed on queries/mutations? \r\n\r\nSpecifically the **withNilValuesRemoved** extension method in **GraphQLInputValue.swift**\r\n\r\nThanks,\r\nDave","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Good question! So you can see a little bit of why in [this test](https://github.com/apollographql/apollo-ios/blob/main/Tests/ApolloTests/InputValueEncodingTests.swift#L74) and [this test](https://github.com/apollographql/apollo-ios/blob/main/Tests/ApolloTests/InputValueEncodingTests.swift#L80). \r\n\r\nFor input values, passing `nil` and passing `.some(nil)` have different meanings. Passing `nil` means \"I am not providing a value here.\" Passing `.some(nil)` means \"I am providing a value, and it is explicitly nil.\" The `nil`s are filtered out, the `.some(nil)`s are not.\r\n\r\nThis has effects on the server side: If you send `null` to the server, it will overwrite whatever was already in your server-side database with `null`. If you don't send anything to the server, anything which was already there and isn't explicitly being changed will remain untouched. \r\n\r\nIn the swift Codegen stuff I'm working on there's going to be a [`GraphQLOptional`](https://github.com/apollographql/apollo-ios/blob/main/Sources/ApolloCore/GraphQLOptional.swift#L3) type that should capture this a bit more clearly than the current codegen, but unfortunately that's still a ways out (😭). \r\n\r\nDoes that make more sense? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Oh that's perfect! I can use `.some(nil)` to stop it being filtered out.\r\n\r\nThanks so much for the quick reply 🤩","author":{"__typename":"User","login":"docallag","id":"MDQ6VXNlcjM1MzIzMQ==","name":"David O'Callaghan"}}]}},{"__typename":"Issue","title":"Does every table need an \"id\" or \"","author":{"__typename":"User","login":"joshuarobs","id":"MDQ6VXNlcjUyOTQ2ODgx","name":null},"body":"","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"(closing this in favor of #1326)","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Does every table need an \"id\" or \"_id\" field for its data to be cached properly?","author":{"__typename":"User","login":"joshuarobs","id":"MDQ6VXNlcjUyOTQ2ODgx","name":null},"body":"According to Apollo Client React here: https://www.apollographql.com/docs/react/caching/cache-configuration/#generating-unique-identifiers the way data is identified and if any changes have been made is as described:\r\n\r\n````\r\nTo do so, it combines the object's __typename with its id or _id field (whichever is defined).\r\nThese two values are separated by a colon (:).\r\n````\r\n\r\nThere seems to be an option for React where a different field other than `id` can be used, especially if there is another field set as the primary key on the db.\r\n\r\nIs there a way to do this for Apollo iOS? If not, does that mean we have to make all tables in our database have some sort of `id` or `_id` field?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! This is handled rather differently on iOS at the moment. Here's [a detailed doc about our caching on iOS](https://www.apollographql.com/docs/ios/caching/). \r\n\r\nThe short answer of how to set a custom key is to take a look at the [Controlling Normalization section](https://www.apollographql.com/docs/ios/caching/#controlling-normalization), where you can find information about the `cacheKeyForObject` function you can use to set custom cache keys on iOS. \r\n\r\nDoes that answer your question? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes it does, thanks!","author":{"__typename":"User","login":"joshuarobs","id":"MDQ6VXNlcjUyOTQ2ODgx","name":null}},{"__typename":"IssueComment","body":"@designatednerd Also, forgot to ask one more quick question: is `cacheKeyForObject` set only once throughout the whole Apollo object? That is, if we set it to `id`, does that mean every table that ever gets queried needs to have an `id` field? What about if we have most tables with a unique `id` but some tables don't have it and use other primary keys?","author":{"__typename":"User","login":"joshuarobs","id":"MDQ6VXNlcjUyOTQ2ODgx","name":null}},{"__typename":"IssueComment","body":"There is only one closure per store (set through the client), but you can do some stuff by extracting the value of `__typename` from the JSON you get in order to have it work differently for different things. \r\n\r\nYou also can just return `nil` if `id` is nil, and a default cache key based on the path of the request will be generated. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Inline GQL","author":{"__typename":"User","login":"ericlewis","id":"MDQ6VXNlcjY3NDUwMw==","name":"Eric Lewis"},"body":"This might be old hat and I know it’s not a great issue but need to write down somewhere:\r\n\r\nYou should be able to describe fragments or query’s with inline strings as opposed to colocating with graphql files. \r\n\r\nIt probs seems minor but from a DX perspective the whole co-locating things a big deal. \r\n\r\nCreating more folder structure to organize is less good than just having the query in a used component. This is probably more true of SwiftUI than anything, and I have some SwiftUI stuff to contribute if folks want it. ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! There's definitely some significant obstacles to this at the moment, particularly around how things are ingested for code generation. Right now, we only ingest from `.graphql` files rather than from any arbitrary file, and without having to worry about what is a Swift `String` that contains a GraphQL query or anything like that. \r\n\r\nThis is definitely an enhancement to consider for the long term, but I'll be honest, we've got way bigger problems to solve first. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"don't see this happening to be fair, more likely would be some kind of DSL","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"Thats' an interesting idea - I think the main issues I see with it are a) How would we ensure that queries are valid? and b) How would we generate the classes necessary for parsing the result? \r\n\r\nDefinitely going to think on that when I get back to this issue though. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Swift scripting codegen error: \"Error: Cannot find module './errors/pretty-print'\"","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"},"body":"macOS 10.15.6\r\nXcode 11.6\r\n\r\nWe're using Swift scripting for Codegen in our project. It was working fine until recently. The only change that occurred (that I can think of) is macOS and Xcode updated. I'm getting the following error:\r\n\r\n```\r\n[DEBUG - ApolloCodegenLib:CLIDownloader.swift:43] - Zip file with the CLI is already downloaded!\r\nSHASUM of downloaded file: c2b1215eb8e82ec9d777f4b1590ed0f60960a23badadd889e4d129eb08866f14\r\n[DEBUG - ApolloCodegenLib:CLIExtractor.swift:57] - Binary already extracted!\r\n[ERROR - ApolloCodegenLib:Basher.swift:62] - internal/modules/cjs/loader.js:638\r\n throw err;\r\n ^\r\n\r\nError: Cannot find module './errors/pretty-print'\r\n at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)\r\n at Function.Module._load (internal/modules/cjs/loader.js:562:25)\r\n at Module.require (internal/modules/cjs/loader.js:692:17)\r\n at require (internal/modules/cjs/helpers.js:25:18)\r\n at Object. (/Users/nateirwin/Development/trailheadlabs/outerspatial-ios/Codegen/ApolloCLI/apollo/node_modules/@oclif/errors/lib/handle.js:6:24)\r\n at Module._compile (internal/modules/cjs/loader.js:778:30)\r\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)\r\n at Module.load (internal/modules/cjs/loader.js:653:32)\r\n at tryModuleLoad (internal/modules/cjs/loader.js:593:12)\r\n at Function.Module._load (internal/modules/cjs/loader.js:585:3)\r\n\r\nProgram ended with exit code: 1\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"That's very odd, that shouldn't have changed anything in the path - I did not have any migration issues when I migrated my machine to those versions. \r\n\r\nWhat I'd suggest is deleting the extracted files from the `tar.gz` file and letting it re-extract. I have no idea what could have changed in there, but re-extracting from the zip file is a good way to make sure you've got everything. Let me know if this works.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"That worked, thanks!","author":{"__typename":"User","login":"nateirwin","id":"MDQ6VXNlcjEwNDQz","name":"Nate Irwin"}}]}},{"__typename":"Issue","title":"Apollo 0.29.0 - 0.30.0 failed to build in Travis","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"},"body":"Hi, i have an issue in Travis when build my apps using apollo.\r\n\"Screen\r\nIt's said there is no module `ApolloCore`, but when i run in xcode and archive it using xcode, it went well. No issue arises when using Xcode.\r\n\r\nI tried to downgrade to version `0.28.0` and it works well in Travis. No error occured.\r\nIs there any configuration for Travis to build `Apollo` pod?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! I'm not sure what your build looks like in Travis, but the issue is around a macro that's used by CocoaPods. CocoaPods pulls every sub-spec into a single big library, so we had to add [this macro](https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/Bundle%2BHelpers.swift#L2) to tell the compiler not to try to import the `ApolloCore` module when using CocoaPods. It sounds like that macro is getting properly populated when you build/archive locally. \r\n\r\nWhat's the command you're using to build on Travis? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"This is command from my Travis :\r\n\r\n```\r\nlanguage: swift\r\nosx_image: xcode11.5\r\nxcode_project: Project.xcworkspace\r\n\r\ncache:\r\n - bundler\r\n - cocoapods\r\n\r\nbefore_install:\r\n - gem install bundler\r\n - bundle install\r\n - pod install\r\n\r\njobs:\r\n allow_failures:\r\n - env: code-coverage\r\n include:\r\n - stage: deploy\r\n before_script: curl -sL firebase.tools | upgrade=true bash\r\n script: bundle exec fastlane deploy\r\n after_success: bundle exec fastlane archive\r\n```\r\n\r\nAnd for my fastlane I'm using `Gym` :\r\n```\r\nprivate_lane :ios_build do |options|\r\n scheme = options[:scheme]\r\n export_method = options[:export_method]\r\n output_name = options[:output_name]\r\n key_name = options[:development]\r\n\r\n gym(\r\n workspace: \"Project.xcworkspace\",\r\n scheme: scheme,\r\n configuration: scheme,\r\n silent: true,\r\n clean: true,\r\n suppress_xcode_output: false,\r\n export_method: export_method,\r\n output_name: output_name,\r\n xcargs: \"ARCHIVE=YES\",\r\n skip_profile_detection: true,\r\n codesigning_identity: key_name,\r\n analyze_build_time: true\r\n )\r\n end\r\n```","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"}},{"__typename":"IssueComment","body":"I would maybe look at adding `COCOAPODS=YES` to your `xcargs` via `gym` if nothing else works - i would also check that the configuration that you're passing in to `gym` has that variable set. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I've add `COCOAPOD=YES` to `gym` and it's still fail to build in Travis.\r\n```\r\ngym(\r\n workspace: \"Project.xcworkspace\",\r\n scheme: scheme,\r\n configuration: scheme,\r\n silent: true,\r\n clean: true,\r\n suppress_xcode_output: false,\r\n export_method: export_method,\r\n output_name: output_name,\r\n xcargs: \"ARCHIVE=YES COCOAPODS=YES\",\r\n skip_profile_detection: true,\r\n codesigning_identity: key_name,\r\n analyze_build_time: true\r\n )\r\n```\r\n\r\n","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"}},{"__typename":"IssueComment","body":"IIRC it needs a comma and not a space - what about looking at the configuration you're using - does that have `COCOAPODS=YES` (or 1) set up? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Already add comma in gym `xcargs: \"ARCHIVE=YES, COCOAPODS=YES\"` and in my configuration there is already an argument `COCOAPODS=1`. But it's still give me the same error in travis.\r\n\"Screen\r\n","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"}},{"__typename":"IssueComment","body":"It looks like in the Release scheme there's a space before `COCOAPODS=1` - what happens if you delete that space?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi, we already add several condition in `xcargs` regarding this issue using `COCOAPODS=0`, `COCOAPODS=1` and `COCOAPODS=YES`. but still no luck. any clue @designatednerd ?","author":{"__typename":"User","login":"budioktaviyan","id":"MDQ6VXNlcjIwMzE0OTM=","name":"Budi Oktaviyan"}},{"__typename":"IssueComment","body":"> It looks like in the Release scheme there's a space before `COCOAPODS=1` - what happens if you delete that space?\r\n\r\nThat's not a space, maybe because it's have another config in first line so it's appear like a space.\r\n\"Screen\r\nAnyway for travis build, we use schema `alpha & beta`. And still no luck ","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"}},{"__typename":"IssueComment","body":"Hmmm...I wonder if there's an issue because `$(inherited)` is in there twice. \r\n\r\nHonestly, I'm not sure what to tell you - it's clear that the `#if !COCOAPODS` compile gate isn't working on Travis, but I'm really not sure why. \r\n\r\nIf you run the fastlane script locally, do you see the same errors? That could start to point you in the right direction. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@budioktaviyan @hendyevan Were y'all ever able to figure out what was going on here, or at least get the fastlane script to run locally? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi @designatednerd , I ever run it locally using `fastlane` and got same issue. So basically, we use `gym` action on fastlane to bundle our app. Apart from that, we also trying to build + archive using xcode, and it works!\r\n\r\nIDK why, is it a `fastlane` problem or something else ?","author":{"__typename":"User","login":"budioktaviyan","id":"MDQ6VXNlcjIwMzE0OTM=","name":"Budi Oktaviyan"}},{"__typename":"IssueComment","body":"That indicates there's likely some kind of configuration issue that's being hit by fastlane - the good news is it's a lot easier to debug that when it can be reproduced locally. I would try using some of the tips from [Fastlane's troubleshooting guide](https://docs.fastlane.tools/codesigning/troubleshooting/), particularly the use of the `--verbose` flag that might give you a better indicator of what's going wrong. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@hendyevan Were you able to get the verbose output and see what might be happening? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi @designatednerd, so the issue actually come from fastlane ? What did you expect from `verbose` build ? did you have any clue ?","author":{"__typename":"User","login":"budioktaviyan","id":"MDQ6VXNlcjIwMzE0OTM=","name":"Budi Oktaviyan"}},{"__typename":"IssueComment","body":"Hi, sorry, I was on vacation last week!\r\n\r\nIt seems like Fastlane is using a build configuration that isn't picking up the `COCOAPODS` setting, I was hoping that the `verbose` build would give you more information about what configuration you're using and what settings are set in that configuration. That might help you figure out more info about what you need to pass into Fastlane to get it to use a build configuration that _does_ use the `COCOAPODS` setting. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Were you ever able to figure out what was happening? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi @designatednerd , sorry for slow response. We are still in the middle of project and the deadline is very tight. We will inform you later as soon as possible after we try it in local and using `verbose` as you suggest.","author":{"__typename":"User","login":"hendyevan","id":"MDQ6VXNlcjk4Mjk3Mg==","name":"Hendy Evan"}},{"__typename":"IssueComment","body":"Hi @designatednerd,\r\n\r\nSorry for late response. So, we're just running like this ?\r\n```bundle exec fastlane lane --verbose```\r\n\r\nisn't it ?","author":{"__typename":"User","login":"budioktaviyan","id":"MDQ6VXNlcjIwMzE0OTM=","name":"Budi Oktaviyan"}},{"__typename":"IssueComment","body":"I believe so - there's instructions in the troubleshooting guide I linked earlier that are going to be more accurate than anything I can give you. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey all - I'm going to close this out since I haven't heard back in a few weeks. My best recommendation would be to get things building locally with Fastlane since you can get feedback much more easily than you can from Travis itself. I've generally found in the past that once something is building locally with Fastlane, it's much more likely to succeed on any CI platform if you're building using fastlane on that platform. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Adjusting the reconnection behaviour of `WebSocketTransport`","author":{"__typename":"User","login":"ketenshi","id":"MDQ6VXNlcjY4MDY2OTc=","name":"Eugene Kwong"},"body":"Hello!\r\n\r\nI have a similar setup to https://github.com/apollographql/apollo-ios/pull/1224 but with the caveat of requiring the user to login again in some cases. With an invalid `connectingPayload` the server closes the connection immediately, and `WebSocketTransport` will keep retrying. The `connectingPayload` can be updated with the new authentication token after the user logs in again.\r\n\r\nI would like to add in the ability to either prevent `WebSocketTransport` from reconnecting or be able to pause the websocket. \r\n\r\nIf we go the route of adjusting the reconnection behaviour I was thinking of adding something similar to `HTTPNetworkTransportRetryDelegate` but that kind of goes against the idea of passing `reconnect` as part of the initialization. So maybe having a getter/setter might be best.\r\n\r\nHope that I can get some guidance/feedback on this. Thanks!","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Does `closeConnection` on `WebSocketTransport` do what you need it to? That explicitly sets `reconnect.value` to false. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'd like to keep existing `subscriptions` so unfortunately `closeConnection` isn't viable.","author":{"__typename":"User","login":"ketenshi","id":"MDQ6VXNlcjY4MDY2OTc=","name":"Eugene Kwong"}},{"__typename":"IssueComment","body":"So you're thinking more like this: \r\n\r\n```swift\r\n public func pauseWebSocketConnection() {\r\n self.reconnect.value = false\r\n self.websocket.disconnect()\r\n }\r\n \r\n public func resumeWebSocketConnection(autoReconnect: Bool = true) {\r\n self.reconnect.value = autoReconnect\r\n self.websocket.connect()\r\n }\r\n```\r\n\r\nI think that could work with a sufficient documentation warning that if you call `pause` you have to manually call `resume`. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes that's essentially what I want. Thanks for the suggestion, I'll have something in the next few days.","author":{"__typename":"User","login":"ketenshi","id":"MDQ6VXNlcjY4MDY2OTc=","name":"Eugene Kwong"}},{"__typename":"IssueComment","body":"Eh, if that's all you need i'll just do it and throw in a test 😇","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Ok, thank you so much!","author":{"__typename":"User","login":"ketenshi","id":"MDQ6VXNlcjY4MDY2OTc=","name":"Eugene Kwong"}},{"__typename":"IssueComment","body":"> 好的,非常感谢你!\r\n\r\n你好 我想问下 如果 在 APP 进入后台时,手动断开长连接. APP 重新唤起时连接长连接呢","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null}},{"__typename":"IssueComment","body":"This has shipped with `0.31.0`. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Apollo Codegen generates different Operation IDs than Apollo Server","author":{"__typename":"User","login":"Nickersoft","id":"MDQ6VXNlcjIxMDQxMjk=","name":"Tyler Nickerson"},"body":"Hey all,\r\n\r\nTonight I noticed that the operation ID Apollo Codegen creates when generating Swift code for your schema is slightly different than what the Apollo Server expects, causing APQs to fail and throw a `provided sha does not match query` error. \r\n\r\nBasically the SHA that Apollo Codegen creates adds line breaks between each GraphQL operation before it calculates the SHA of the string (seen [here](https://github.com/apollographql/apollo-tooling/blob/8e78c50a21c17a071f7b6890de446b4582e8d04a/packages/apollo-codegen-core/src/compiler/visitors/generateOperationId.ts#L26)). However, when Apollo iOS sends queries to the server, it does so without any line breaks using Swift's `.appending()` method. Then when the server calculates the SHA, due to the lack of line breaks, the operation ID is different and the error is thrown. Strangely enough, however, I noticed the StarWars API actually [manually adds line breaks](https://github.com/apollographql/apollo-ios/blob/06c357b7e98fb7abcddc02ca8aeb96cc8475d263/Sources/StarWarsAPI/API.swift#L1051) in its generated code, which mine doesn't. \r\n\r\nI believe I'm using the latest version of Apollo Codegen and Apollo iOS. I'm happy to patch a fix – it's just a matter of what needs to be changed. I'm afraid touching `apollo-tooling` would affect more repos that might depend on it, so I thought it'd be safer to open an issue here and propose adding the line breaks to the generated Swift.\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Closing, as it looks like the `apollo-tooling` upstream does add a line break during Swift Codegen, but the CLI on my system may be out of date. Will reopen if cannot find a resolution.","author":{"__typename":"User","login":"Nickersoft","id":"MDQ6VXNlcjIxMDQxMjk=","name":"Tyler Nickerson"}},{"__typename":"IssueComment","body":"@Nickersoft I would strongly recommend using the version the SDK downloads - it's set up to make sure you don't have to fight with node and mess with \"which version of the CLI works with which version of the SDK?\". You can check out the most recent version of our [installation docs](https://www.apollographql.com/docs/ios/installation/) or our new [Swift scripting docs](https://www.apollographql.com/docs/ios/swift-scripting/) to see how to set this up. \r\n\r\nI'd also recommend using version `0.29.x` of the iOS SDK - this includes some fixes that ensure the hash that you get from your iOS operation matches what's generated by the CLI, even with Fragments.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd Hey, thanks for the comment despite me opening an issue a little prematurely haha – I didn't realize the Apollo version set in the Codegen `Package.swift` affects the version of the CLI it downloads, and sure enough, I was on 0.28.x when the newline fix was pushed on 0.30.x. Updating it to download the new CLI fixed the problem :) ","author":{"__typename":"User","login":"Nickersoft","id":"MDQ6VXNlcjIxMDQxMjk=","name":"Tyler Nickerson"}},{"__typename":"IssueComment","body":"Yeah you bet - thought it would be helpful for anyone who stumbles across this via google :P","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Cache: Transaction write object results in no change.","author":{"__typename":"User","login":"pggawlowski","id":"MDQ6VXNlcjY0OTY2OTU2","name":null},"body":"```\r\n do {\r\n var response = try transaction.readObject(ofType: Package.self, withKey: packageId)\r\n response.status = entry.status\r\n \r\n try transaction.write(object: response, withKey: packageId) \r\n let confirmChange = try transaction.readObject(ofType: Package.self, withKey: packageId)\r\n print(confirmChange)\r\n } catch {\r\n print(error)\r\n }\r\n\r\n```\r\n\r\nI digged down until ApolloStore -> `func mergePromise(records: RecordSet)`.\r\nResult is giving me succes `fulfill(cacheKey)` with cacheKey \"123.status\" which is correct packageId and correct field I was trying to manipulate. \r\n\r\nHowever confirmChange object has unchanged status. My `cacheKeyForObject` for both store and client are set. \r\nIs it sth I am doing wrong or writeObject is not working the way I think?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"The issue is that the transactions aren't guaranteed to be synchronous, so `transaction.write` may not have finished before `transaction.read` is called. \r\n\r\nYou'd need to use [`withinWriteTransaction`](https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/ApolloStore.swift#L149) in order to validate the change. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Actual problem was: invalid cacheKeys. Sorry for wasting Tour time.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"No worries - thanks for following up with what actually happened! I'm gonna go ahead and close this issue out. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"长连接手动断开和重连","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null},"body":"你好\r\n如何在 APP 进入后台时,手动断开长连接,从新打卡 APP 时再重新连接长连接?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Via Google Translate since I don't speak Chinese: \r\n\r\n> Hello there\r\n> How to manually disconnect the long connection when the APP enters the background, and then reconnect the long connection when the APP is newly clocked in?\r\n\r\nAre you asking about subscriptions or some other kind of long connection? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"你好.订阅消息. WebSocketTransport\r\n\"WeChat67a3558698ad0ab1125ec3110a335a58\"\r\n如果使用方法.我想在 APP 进入后台时,断开.在 APP重新打开的时候重新连接?\r\n初学者请多见谅!\r\n","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null}},{"__typename":"IssueComment","body":"> Hello. Subscribe to news. WebSocketTransport\r\n\r\n[Here's Apple's documentation on handling lifecycle changes](https://developer.apple.com/documentation/uikit/app_and_environment/managing_your_app_s_life_cycle) - The short answer is that you will probably want to call `closeConnection` on the `webSocketTransport` in your App Delegate's `applicationWillResignActive` method and restart the susbcription in `applicationDidBecomeActive`. \r\n\r\nNote that names are different in the Scene delegate if you're using that, but I don't think you are since you're using a singleton rather than per-scene instances of `Network`. \r\n\r\nLet me know if that helps!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"是的,这个地方使用的是单例.多个订阅消息在这里接受,然后进行分发处理.\r\n需要在 UIApplicationWillResignActiveNotification 时,断开订阅连接\r\n UIApplicationDidBecomeActiveNotification 重新连接订阅\r\n\r\n是通过 self.webSocketTransport.closeConnection() 断开订阅么","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null}},{"__typename":"IssueComment","body":"你好.我通过 调用 self.webSocketTransport.closeConnection() ,已经可以断开连接了. 在 UIApplicationDidBecomeActiveNotification 的时候怎么重新建立连接呢?\r\n![image](https://user-images.githubusercontent.com/10558372/89000672-86b02780-d32a-11ea-8df8-59fee24addf6.png)\r\n","author":{"__typename":"User","login":"tanchendong1992","id":"MDQ6VXNlcjEwNTU4Mzcy","name":null}},{"__typename":"IssueComment","body":"Google translated: \r\n\r\n> Hello. I can disconnect by calling self.webSocketTransport.closeConnection(). How to re-establish the connection when UIApplicationDidBecomeActiveNotification?\r\n\r\nAh, because `addSubscribe` won't work if the web socket isn't connected, and right now there's not a way to tell the websocket to reconnect non-automatically. \r\n\r\nThe good news is #1335 will add the ability to reconnect more easily. Until then you'll probably need to hack it by using either `updateHeaderValues` or `updateConnectingPayload` to force a reconnection. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"#1335 is merged to `main` if you want to use it immediately, it'll come out probably sometime later this week in an official release. I'm going to close this out. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"RFC: Networking Updates","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"},"body":"This is the technical outline of a proposal to make major changes to our primary networking interface from the current `HTTPNetworkTransport` to a `RequestChainNetworkTransport` which uses a chain of interceptor objects to set up and process the results of network requests.\r\n\r\nNote that this is going to be a **🎉 Spectacularly 🎉** breaking change - while very surface level APIs will remain basically the same, if you're doing anything remotely advanced, this will necessitate some changes, but the idea is to break it now so we don't have to break it way worse later.\r\n\r\nI would **REALLY** love feedback on this before I start working towards making this the default option. You can see the code changes in-place in [this PR](https://github.com/apollographql/apollo-ios/pull/1341). I will be updating this RFC with feedback as it is received. \r\n\r\n## Why The Change?\r\n\r\n`HTTPNetworkTransport` allows you to hook into various delegates to accomplish various things. There are several limitations to this approach: \r\n\r\n- Users can only do things that are specifically supported by delegates.\r\n- Asynchronous use of delegates without callbacks is basically impossible.\r\n- Any time we want to add a new feature, we need to add a new delegate method and handle it, creating additional complexity.\r\n- There is no flexibility in terms of order of operations, particularly around whether data should be returned to the UI before being written to the cache.\r\n\r\nThe other major issue driving this update is that the current networking stack is *deeply* tied to the current cache architecture. This isn't ideal for many reasons, the biggest of which is that the cache likely to change in relation to the [Swift Codegen Rewrite](https://github.com/apollographql/apollo-ios/issues/939). \r\n\r\n## What is proposed? \r\n\r\nThe proposed new architecture uses the Interceptor pattern to create a customizable request chain. This means users can hook into the system at any point during the request creation or data processing process. \r\n\r\nThis also means that the pieces which will need to be swapped out for the Swift Codegen Rewrite are more clearly defined, and less tied to the actual parsing operation. \r\n\r\nFinally, this also opens the opportunity for different patterns than we already support, such as writing to the cache *after* returning data to the UI instead of before, or creating an array of interceptors which hit the network first, then hit the cache if nothing was returned. \r\n\r\n### New Protocols\r\n\r\n- **`FlexibleDecoder`**: This is mostly going to be helpful for the `Codable` implementation down the line, but this will allow anything conforming to `Decoder` to be used to decode data.\r\n- **`Parseable`**: This is a wrapper that allows us to continue to support non-`Codable` parsing alongside `Codable` parsing, while keeping us able to constrain and construct things generically. A default implementation for `Codable` will be provided.\r\n- **`ApolloInterceptor`**: This is an interface which allows you to add an asynchronous handler to perform any necessary work, such as fetching credentials and reading or writing from the cache, asynchronously. \r\n \r\n ```swift\r\n public protocol ApolloInterceptor: class {\r\n \r\n /// Called when this interceptor should do its work.\r\n ///\r\n /// - Parameters:\r\n /// - chain: The chain the interceptor is a part of.\r\n /// - request: The request, as far as it has been constructed\r\n /// - response: [optional] The response, if received\r\n /// - completion: The completion block to fire when data needs to be returned to the UI.\r\n func interceptAsync(\r\n chain: RequestChain,\r\n request: HTTPRequest,\r\n response: HTTPResponse?,\r\n completion: @escaping (Result, Error>) -> Void)\r\n }\r\n ```\r\n \r\n Default implementations of `ApolloInterceptor` for both Legacy (ie, non Swift Codegen) networking and Swift Codegen networking will be provided.\r\n- **`InterceptorProvider`** This protocol will be used to quickly create a new array of interceptors for a given request:\r\n\r\n ```swift\r\n public protocol InterceptorProvider {\r\n \r\n /// Creates a new array of interceptors when called\r\n ///\r\n /// - Parameter operation: The operation to provide interceptors for\r\n func interceptors(for operation: Operation) -> [ApolloInterceptor]\r\n }\r\n ```\r\n This design allows for both flexibility (you can return different interceptors for different types of requests, for instance) and isolation (each request will have its own unique set of interceptors, reducing the possibility of different requests stomping on each other). \r\n \r\n Two default interceptor providers are set up: \r\n - **`LegacyInterceptorProvider`** will provide interceptors mimicking the current stack \r\n - **`CodableInterceptorProvider`** will provide interceptors for the forthcoming Swift Codegen Rewrite's network stack. \r\n- **`ApolloErrorInterceptor`** will allow you to have additional checks whenever an error is about to be returned. This will be optional to implement, and no default implementation is provided.\r\n\r\n ```swift\r\n /// Asynchronously handles the receipt of an error at any point in the chain.\r\n ///\r\n /// - Parameters:\r\n /// - error: The received error\r\n /// - chain: The chain the error was received on\r\n /// - request: The request, as far as it was constructed\r\n /// - response: [optional] The response, if received\r\n /// - completion: The completion closure to fire when the operation has completed. Note that if you call `retry` on the chain, you will not want to call the completion block in this method.\r\n func handleErrorAsync(\r\n error: Error,\r\n chain: RequestChain,\r\n request: HTTPRequest,\r\n response: HTTPResponse?,\r\n completion: @escaping (Result, Error>) -> Void)\r\n ```\r\n \r\n### New Classes\r\n\r\n- **`HTTPRequest`** This object will hold all the information related to a request before it hits the network, with the `toURLRequest()` method creating an actual `URLRequest` based on all the information in the request. This is subclass-able (and will mostly be using subclasses). \r\n\r\n ```swift\r\n open class HTTPRequest {\r\n\r\n open var graphQLEndpoint: URL\r\n open var operation: Operation\r\n open var contentType: String\r\n open var additionalHeaders: [String: String]\r\n open var clientName: String? = nil\r\n open var clientVersion: String? = nil\r\n open var retryCount: Int = 0\r\n public let cachePolicy: CachePolicy\r\n\r\n public init(graphQLEndpoint: URL,\r\n operation: Operation,\r\n contentType: String,\r\n additionalHeaders: [String: String],\r\n cachePolicy: CachePolicy = .default)\r\n \r\n open func toURLRequest() throws -> URLRequest\r\n\r\n open func addHeader(name: String, value: String)\r\n }\r\n ```\r\n \r\n - **`JSONRequest`** subclass of `HTTPRequest` will handle creating requests with JSON, which will be the vast majority of requests with operations. This is where handling of auto-persisted queries is also layered in: \r\n\r\n ```swift\r\n public class JSONRequest: HTTPRequest {\r\n \r\n public let requestCreator: RequestCreator\r\n \r\n public let autoPersistQueries: Bool\r\n public let useGETForQueries: Bool\r\n public let useGETForPersistedQueryRetry: Bool\r\n public var isPersistedQueryRetry = false\r\n \r\n public let serializationFormat = JSONSerializationFormat.self\r\n\r\n public init(operation: Operation,\r\n graphQLEndpoint: URL,\r\n additionalHeaders: [String: String] = [:],\r\n cachePolicy: CachePolicy = .default,\r\n autoPersistQueries: Bool = false,\r\n useGETForQueries: Bool = false,\r\n useGETForPersistedQueryRetry: Bool = false,\r\n requestCreator: RequestCreator = ApolloRequestCreator())\r\n }\r\n ```\r\n \r\n - **`UploadRequest`** subclass of `HTTPRequest` will handle multipart file uploads:\r\n\r\n ```swift\r\n public class UploadRequest: HTTPRequest {\r\n \r\n public let requestCreator: RequestCreator\r\n public let files: [GraphQLFile]\r\n public let manualBoundary: String? \r\n public let serializationFormat = JSONSerializationFormat.self\r\n \r\n public init(graphQLEndpoint: URL,\r\n operation: Operation,\r\n additionalHeaders: [String: String] = [:],\r\n files: [GraphQLFile],\r\n manualBoundary: String? = nil,\r\n requestCreator: RequestCreator = ApolloRequestCreator()) \r\n }\r\n ```\r\n\r\n- **`HTTPResponse`** will represent the objects returned and/or parsed from the server:\r\n\r\n ```swift\r\n /// Designated initializer\r\n ///\r\n /// - Parameters:\r\n /// - response: The `HTTPURLResponse` received from the server.\r\n /// - rawData: The raw, unparsed data received from the server.\r\n /// - parsedResponse: [optional] The response parsed into the `ParsedValue` type. Will be nil if not yet parsed, or if parsing failed.\r\n public class HTTPResponse {\r\n public var httpResponse: HTTPURLResponse\r\n public var rawData: Data\r\n public var parsedResponse: GraphQLResult?\r\n }\r\n ```\r\n\r\n- **‌`RequestChain`** will handle the interaction with the network for a single operation. \r\n\r\n ```swift\r\n public class RequestChain: Cancellable {\r\n\r\n /// Creates a chain with the given interceptor array\r\n public init(interceptors: [ApolloInterceptor])\r\n \r\n /// Kicks off the request from the beginning of the interceptor array.\r\n ///\r\n /// - Parameters:\r\n /// - request: The request to send.\r\n /// - completion: The completion closure to call when the request has completed.\r\n public func kickoff(\r\n request: HTTPRequest, \r\n completion: @escaping (Result) -> Void)\r\n \r\n /// Proceeds to the next interceptor in the array.\r\n /// \r\n /// - Parameters:\r\n /// - request: The in-progress request object\r\n /// - response: [optional] The in-progress response object, if received yet\r\n /// - completion: The completion closure to call when data has been processed and should be returned to the UI.\r\n public func proceedAsync(\r\n request: HTTPRequest, \r\n response: HTTPResponse?,\r\n completion: @escaping (Result) -> Void)\r\n \r\n /// Cancels the entire chain of interceptors.\r\n public func cancel()\r\n \r\n /// Restarts the request starting from the first inteceptor.\r\n ///\r\n /// - Parameters:\r\n /// - request: The request to retry\r\n /// - completion: The completion closure to call when the request has completed.\r\n public func retry(\r\n request: HTTPRequest,\r\n completion: @escaping (Result) -> Void)\r\n }\r\n ```\r\n- **`RequestChainNetworkTransport`** provides an implementation of `NetworkTransport` which uses an `InterceptorProvider` to create a request chain for each request. \r\n ```swift\r\n public class RequestChainNetworkTransport: NetworkTransport {\r\n \r\n public init(interceptorProvider: InterceptorProvider,\r\n endpointURL: URL,\r\n additionalHeaders: [String: String] = [:],\r\n autoPersistQueries: Bool = false,\r\n cachePolicy: CachePolicy = .default,\r\n requestCreator: RequestCreator = ApolloRequestCreator(),\r\n useGETForQueries: Bool = false,\r\n useGETForPersistedQueryRetry: Bool = false)\r\n }\r\n ```\r\n\r\n### Changes to existing Protocols and Classes\r\n\r\n- **`ApolloStore`** will no longer require a `GraphQLQuery` explicitly for fetching data from the store. It will instead return an error if the `GraphQLOperationType` is not `.query`. This change is necessary to avoid going down an enormous rabbit hole with generics since `GraphQLOperation` has an associated type. \r\n- The **`NetworkTransport`** protocol will get a new method to be implemented: \r\n\r\n ```swift\r\n func sendForResult(operation: Operation,\r\n completionHandler: @escaping (Result, Error>) -> Void) -> Cancellable\r\n ```\r\n \r\n This will avoid the double-wrapping of `GraphQLResponse` around the `GraphQLResult` so that only the `GraphQLResult` is actually returned. The `send` method will eventually be deprecated and removed. \r\n- **`ApolloClient`** will get a new `sendForResult` method which calls into the `sendForResult` method added to `NetworkTransport`.\r\n\r\n## How will this work in practice? \r\n\r\nInstantiating a new legacy client manually will look like this: \r\n\r\n```swift\r\nlazy var legacyClient: ApolloClient = {\r\n let url = URL(string: \"http://localhost:8080/graphql\")!\r\n \r\n let store = ApolloStore(cache: InMemoryNormalizedCache())\r\n let provider = LegacyInterceptorProvider(store: store)\r\n let transport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: url)\r\n \r\n return ApolloClient(networkTransport: transport)\r\n}()\r\n```\r\n\r\nIdeally I'll be able to transparently swap out the existing `HTTPNetworkTransport` for this so that this would be the under-the-hood setup on `ApolloClient`, but this may involve a transition period. \r\n\r\nCalls to the client will look like this: \r\n\r\n```swift\r\nlegacyClient.fetchForResult(query: HeroNameQuery()) { result in\r\n switch result {\r\n case .success(let graphQLResult):\r\n print(graphQLResult.data?.hero?.name ?? \"Name not found\")\r\n case .failure(let error):\r\n print(\"Unexpected error: \\(error)\")\r\n }\r\n}\r\n```\r\n\r\nNote that this is VERY similar to how they look on the surface at the moment, which is intentional. \r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Overall this looks great. I only have 2 small questions: \r\n- Do you think it is possible to add an `ErrorType: Error` generic type to the signature of `handleErrorAsync` in the `ApolloErrorInterceptor`? I would love to be able to return typed errors, and this generic parameter could simply default to `Error` itself if not specified.\r\n- Do you have any plan to add an official `ApolloCombine` module?","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"1. I'll have to mess around with this and see how it works - my recollection is that it would cause much more complex typing issues, but I'll see what we can do. \r\n2. Eventually, but it's going to be after all the codegen rewrites. There is a [community Combine package](https://github.com/joel-perry/ApolloCombine) if you're looking for something immediately","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> Instantiating a **new legacy** client\r\n\r\nHeh, this was kinda funny to me.\r\n\r\n---\r\n\r\n> `public let requestCreator: RequestCreator`\r\n\r\nShould the request creator live on _all_ requests? Said another way, what's the rationale behind only allowing `JSONRequests` to have this property?\r\n\r\n> Do you think it is possible to add an `ErrorType: Error` generic type to the signature of` handleErrorAsync`\r\n\r\n+1 to this, but definitely not critical for the context of this RFC. I feel like typed errors could be it's own whole RFC/PR too!\r\n\r\n\r\n> **ApolloStore will no longer require a GraphQLQuery explicitly for fetching data from the store**. It will instead return an error if the GraphQLOperationType is not .query. This change is necessary to avoid going down an enormous rabbit hole with generics since GraphQLOperation has an associated type.\r\n\r\nI'm a little bit fuzzy on what this change is. If not a `GraphQLQuery`, what will the input for data fetching from the store be? Can you clarify for me?\r\n\r\n---\r\n\r\nAll told, this seems solid! One of our big use cases in the GitHub app for the current delegate implementation of this is to logout on HTTP 401 status codes, so it seems like that should make this a little simpler (just need an interceptor to throw an error when those responses come back).\r\n\r\nHoller if you want some feedback directly on https://github.com/apollographql/apollo-ios/pull/1341 as well!","author":{"__typename":"User","login":"eliperkins","id":"MDQ6VXNlcjEwNTE0NTM=","name":"Eli Perkins"}},{"__typename":"IssueComment","body":">> Instantiating a new legacy client\r\n\r\n> Heh, this was kinda funny to me.\r\n\r\nHa, that's what I get for working on this doc for so long, I completely glossed that over 🙃\r\n\r\n>> public let requestCreator: RequestCreator\r\n\r\n> Should the request creator live on all requests? Said another way, what's the rationale behind only allowing JSONRequests to have this property?\r\n\r\nMy thought that was only `HTTPRequest` subclasses that actually need to use it should have access to it - `JSONRequest` and a forthcoming `UploadRequest` would be the places I'm thinking. At this point both of those subclasses would need it, but I don't know that it makes sense to tie that to the base class at this time. Would be interesting to hear your thoughts on that.\r\n\r\n>> ApolloStore will no longer require a GraphQLQuery explicitly for fetching data from the store. It will instead return an error if the GraphQLOperationType is not .query. This change is necessary to avoid going down an enormous rabbit hole with generics since GraphQLOperation has an associated type.\r\n\r\n> I'm a little bit fuzzy on what this change is. If not a GraphQLQuery, what will the input for data fetching from the store be? Can you clarify for me?\r\n\r\nBasically, we have the `GraphQLOperation` protocol, with an associated type of `Data`, and its three sub-protocols, `GraphQLQuery`, `GraphQLMutation`, and `GraphQLSubscription`. Previously, we were limiting what operations could read from the cache to `GraphQLQuery`, since in theory that's the only place getting something from the cache would matter. \r\n\r\n`HTTPRequest` only requires a specification of `GraphQLOperation`, but when making a call into the cache, we can't use the `Blah is GraphQLQuery` method of figuring out whether a `GraphQLOperation` is a query because of the `associatedType` on `GraphQLOperation`. \r\n\r\nI tried about 15 different workarounds for this and this is the only one that wasn't monstrously over-complicated - everything else involved some mild-to-completely bizarre type erasure strategies. I'm not totally against those, but I think in this case the benefits of going that way were vastly outweighed just changing the gating of this a bit.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"and if you have specific feedback on #1341 I'd love to hear it - just be aware that there's definitely a lot that's WIP (thus the TODOs)","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"OK, I've done some poking around on the request for a typed error parameter, and I don't think it's going to be doable at the interceptor level.\r\n\r\nWhen I tried to add this in, any existing `Error` I tried to return would cause a \"Cannot convert value\" build failure: \r\n\"Screen\r\n\"Screen\r\n\r\nIt'd make the interceptors a lot harder to keep independent if they all had to have exactly the same type of error. It also wouldn't be possible for me to have default implementations return errors without having `TypedError` conform to some other protocol that allows me to return an underlying arbitrary error. Ultimately, I think that adds too much complexity for general use cases.\r\n\r\nI think if you want to write your own typed wrapper that takes whatever's returned and feeds it into something with an `underlying` error that's easier to switch on, that could work. But I think requiring everything have to be the same type at a protocol level is going to lead to a hell of a lot more confusion than it solves. \r\n\r\nWould love to hear feedback on this finding.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"One of the things that's nice about the `ApolloLink` abstraction used for the web version of Apollo Client is that the link chain is more like a linked list, rather than an array, with each link deciding how to forward the request on to the rest of the chain (and how to process the response), without needing an overarching `RequestChain` to manage the list of links.\r\n\r\nConcretely, this kind of approach would probably mean the `InterceptorProvider` would return a single `ApolloInterceptor` (analogous to `ApolloLink`), representing the head of the linked list, rather than a `[ApolloInterceptor]` array. The last interceptor in the chain (the tail of the list) would be responsible for performing the actual HTTP request, in most cases—but not always!\r\n\r\nSometimes you want to terminate the chain with something that makes an HTTP request, but other times the terminal link might provide its own data (for example, mock data during tests). Sometimes you might want to split a request between multiple downstream links, or choose among several servers that can handle different kinds of requests (or load-balance the same type of request between multiple servers, entirely on the client). It's hard to represent branching structures like that as an array, because it's no longer really a list, but a dynamic tree. But if each interceptor gets to make its own decisions about how it passes requests to the rest of the chain (and how it handles the responses), the branching can be hidden as an implementation detail, with each interceptor abstracting over everything downstream from it.\r\n\r\nI don't know enough Swift to anticipate specific ways in which this approach might be tricky, but it seems like it should be possible to give the interceptor chain more of a recursive, potentially tree-like structure. That's worked pretty well on the web, in the sense that I haven't had to worry very much about the `ApolloLink` system, even as I've changed large portions of the rest of the library.\r\n\r\nFor reference, here's an overview of `ApolloLink` concepts that I've found useful in the past: https://www.apollographql.com/docs/link/overview/","author":{"__typename":"User","login":"benjamn","id":"MDQ6VXNlcjU3NTA=","name":"Ben Newman"}},{"__typename":"IssueComment","body":"I think one huge, huge difference is that things like cancellation, retry, and thread management can be handled through javascript's `Observable` reactive system. \r\n\r\nThat just isn't doable without either using Combine (which would require dropping everything below iOS 12, and is unfortunately a non-starter with a number of our larger users) or adding some kind of Reactive library as a dependency (which I am loathe to do because of the *massive* number of dependency conflicts it could introduce). \r\n\r\nHowever, I think you're right that splitting out methods for request setup vs response handling is a good idea - this could at least help reduce the number of things that need to be optional on `HTTPResponse`. \r\n\r\nWill futz with this tomorrow. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I'm glad you brought that up!\r\n\r\nWhile I agree that `Observable`s are an easier pill to swallow in JavaScript, and they do figure prominently in the `ApolloLink` API, I specifically do not think it's necessary to replicate their behavior here.\r\n\r\nI should also mention that `Observable` is not implemented natively in JS, so you still need some sort of library, and (if I'm being honest) the API doesn't fully deliver on any of those benefits you mentioned, so I think it's fair to say the acceptance of `Observable` in JS (compared to the resistance to Combine in iOS) is a matter of culture/taste/evangelism.\r\n\r\nOn the topic of cancellation, one approach that does work is to pass some sort of context object explicitly down through the chain (and back up), so that each link/interceptor can check whether the request has been cancelled at points where aborting would be safe. `Observable`s don't provide any useful notion of context, even if you wanted it, but you can design a pipeline/interceptor/chain system like this to provide a strongly typed context object everywhere it's needed, I believe.\r\n\r\nOn the topic of retrying, the [`RetryLink`](https://github.com/apollographql/apollo-client/blob/master/src/link/retry/retryLink.ts) subclass of `ApolloLink` has been successful in part because the retry logic can be hidden behind the same abstraction that any other `ApolloLink` provides. From the perspective of links earlier in the chain, a request that succeeded after several retries looks exactly like one that succeeded on the first try, except that it might have taken a bit longer. If retrying was something you could implement in a perfectly generic way for all interceptors, it might make sense to hoist it to a higher layer of the system (maybe into `RequestChain`), but in practice retrying tends to be sensitive to application concerns (different logic for different queries, even), so I think it makes sense to push it down into a part of the system that can be customized by application developers.\r\n\r\nI think we can agree it's important for interceptors to be able to perform any kind of async work as an implementation detail, which requires a uniformly asynchronous API. Both `Observable` and Combine provide that kind of API, but they are both probably overkill, or at the very least they would need to earn their way into a system like this. I believe you that Combine is not worth it for iOS, but then again I'm not sure `Observable` is totally defensible for JS applications, either.","author":{"__typename":"User","login":"benjamn","id":"MDQ6VXNlcjU3NTA=","name":"Ben Newman"}},{"__typename":"IssueComment","body":"> When I tried to add this in, any existing `Error` I tried to return would cause a \"Cannot convert value\" build failure:\r\n\r\nfrom this error it looks like you changed the signature of `handleErrorAsync` to:\r\n```swift\r\nfunc handleErrorAsync(\r\n error: TypedError,\r\n chain: RequestChain,\r\n request: HTTPRequest,\r\n response: HTTPResponse,\r\n completion: @escaping (Result) -> Void)\r\n```\r\n\r\nwhile I was thinking something like: \r\n```swift\r\nfunc handleErrorAsync(\r\n error: Error, // keep this one untyped so that you can pass anything you need\r\n chain: RequestChain,\r\n request: HTTPRequest,\r\n response: HTTPResponse,\r\n completion: @escaping (Result) -> Void) // but allow users to wrap the internal errors in their own custom types\r\n```\r\nso that you can give a default implementation that does not wrap the error type: \r\n```swift \r\nextension ApolloErrorInterceptor where TypedError == Error {\r\n// default interceptor with a untyped completionHandler\r\n```\r\n\r\nsorry I wasn't clear with the previous message. Thank you for fiddling with this!\r\n\r\n> +1 to this, but definitely not critical for the context of this RFC. I feel like typed errors could be it's own whole RFC/PR too!\r\n\r\n@designatednerd would you prefer to move this conversation in a separate issue?","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"@TizianoCoroneo Yeah if I left it with `Error` as the incoming error, I got that same `Cannot convert value` problem in the method in question - I'll take a look at your suggestion later today though","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@benjamn I think one thing that's helpful context to understand is that the basis for this architecture is the [`ApolloInterceptor` type in Android](https://github.com/apollographql/apollo-android/tree/master/apollo-runtime/src/main/java/com/apollographql/apollo/interceptor). This itself is based on [`OkHttp` library's `Interceptor` type](https://square.github.io/okhttp/interceptors/) that's used very widely throughout the Android ecosystem for networking.\r\n\r\nIn `OkHttp`, there's a chain that takes an array of interceptors. Each interceptor in the array needs to call `proceed` before it can keep going, and then each one calls `intercept` to handle the result. There's a few issues with that architecture as-is (mostly around things being implicitly asynchronous instead of explicitly asynchronous), which are generally dealt with by `ApolloInterceptor`'s changes to the architecture.\r\n\r\nStill futzing around, but I thought that'd be useful context.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@TizianoCoroneo I've pushed some stuff to a branch ominously named `nope/typed-errors` if you want to take a look - basically, what you're looking for is not possible without associated types which sends this wholllllllllle mess down a huge rabbit hole. This is a huge piece of why the generic constraint is on the function rather than set up as an `associatedType` in the first place. If you see a better way please definitely feel free to open a PR to that branch!\r\n\r\nAll: I did make some improvements that make it easier to reason about what data's coming back through (basically: Got rid of the need for `Parseable` and moved to `GraphQLResult` as the type being returned in the completion closure), I'll update the RFC tomorrow or Monday to match the updated implementation details. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I tried to play around with it, and I confirm that the ominous name of the branch is accurate. I found no way to avoid having the `TypedError` bubble up to the `RequestChain`, and from there going everywhere else.\r\nThanks for trying this anyway 😄 ","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"Still looking at some of the stuff @benjamn and I were talking about, but I've updated the issue to match what's in the code at the moment.\r\n\r\nTL;DR - I was able to simplify by constraining to `Operation.Data` on `GraphQLOperation` instead of to the more generic `Parseable`. In the end, the result of a GraphQL operation is actually what we handle, so making it even more generic didn't really anything (and in fact made it harder to real with errors that are within `GraphQLResult`, which is part of what a lot of folks want to be able to do. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"More updates:\r\n- Moved `HTTPResponse` to being optional on the interceptor and related methods rather than having its properties be optional. This makes it way clearer whether a response has been received from the network or not. \r\n- Moved error declaration within each individual interceptor for clarity\r\n\r\n@benjamn: While I think the linked-list idea is more flexible, I don't know the additional flexibility it provides gets you much more than what we have in \"This interceptor can be async and take as long as it pleases to do stuff, so you can fire off a bunch of additional network requests and wait for them to call `proceed` if you feel like it.\" \r\n\r\nI think the overwhelming majority of interceptors are not going to do that, and I think the simplicity, especially from a retry standpoint, of \"Here's a list of interceptors in the order they should be executed, GO!\" is a lot better fit for the way this is used on iOS than a linked list would be. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"More updates are up - I don't think any fundamentally change anything already in here, but I do have a couple questions: \r\n\r\n1. Is there anyone using the `context: UnsafeMutableRawPointer?` on the various send/fetch methods for `ApolloClient` _in a way that could not be replaced by this change_? I took it out for now but I figured It's worth asking.\r\n2. I'm extremely tempted to rip out the current `HTTPNetworkTransport` that `RequestChainNetworkTransport` is replacing altogether, largely because I would need to keep a whole bunch of knotted code in `ApolloClient` around that facilitates caching longer than I'd like to. However, I'd like to hear y'all's thoughts about ripping the band-aid in a single release (with a migration guide) vs. doing a bridge release that still has `HTTPNetworkTransport` and its associated ick with a bunch of deprecation warnings. \r\n\r\n For what it's worth I've updated all the tests that aren't specifically _for_ the `HTTPNetworkTransport` to use either a `RequestChainNetworkTransport`, or a `MockNetworkTransport` which inherits from it, and everything is back to passing. I don't think that fully captures the extent to which this would create work for developers using the more advanced delegate features, but I do think for people using less advanced features it shows that everything *should* work the same. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> 1. Is there anyone using the `context: UnsafeMutableRawPointer?` on the various send/fetch methods for ApolloClient in a way that could not be replaced by this change? I took it out for now but I figured It's worth asking.\r\n\r\nNot using it here 🤷‍♂️ feels like a pretty cumbersome API to use effectively right now, so removing it seems alright, as long as we don't think others are using it.\r\n\r\n> I'm extremely tempted to rip out the current ` that RequestChainNetworkTransport is replacing altogether, largely because I would need to keep a whole bunch of knotted code in ApolloClient around that facilitates caching longer than I'd like to. However, I'd like to hear y'all's thoughts about ripping the band-aid in a single release (with a migration guide) vs. doing a bridge release that still has HTTPNetworkTransport and its associated ick with a bunch of deprecation warnings.\r\n\r\nI think it's alright to remove this in favor of `RequestChainNetworkTransport`. Is there a way to deprecate it, and replace it's impl with `RequestChainNetworkTransport`? If it feels like more overhead to maintain, API-wise, I think it's fine to force consumers over to use `RequestChainNetworkTransport` instead, since it solves the same problems that supplying a custom `HTTPNetworkTransport` was doing.","author":{"__typename":"User","login":"eliperkins","id":"MDQ6VXNlcjEwNTE0NTM=","name":"Eli Perkins"}},{"__typename":"IssueComment","body":"> feels like a pretty cumbersome API to use effectively right now,\r\n\r\nWholeheartedly agreed, I want to come up with something way better (and that does not involve the word `Unsafe`)\r\n\r\n> replace it's impl with`RequestChainNetworkTransport`\r\n\r\nI don't think it's a great idea because there's a bunch of stuff with delegates that would be a bit of a hot mess to handle. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm going to close out this RFC as I'm getting ready to beta off of #1341 - I just updated the [client initialization documentation](https://deploy-preview-1341--apollo-ios-docs.netlify.app/docs/ios/initialization/), which hopefully will give a good idea of how this should all be working.\r\n\r\nIn terms of differences from what's outlined in the RFC, at this time the main difference is that I moved retry counting off the `HTTPRequest` itself and onto the `MaxRetryInterceptor`. \r\n\r\nFurther comments should be left on #1341 - thank you all for the feedback!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"getting \"The network connection was lost\" sometimes, while Calling API's","author":{"__typename":"User","login":"guru-mtech","id":"MDQ6VXNlcjY0NjU4ODQw","name":null},"body":"I cannot get the grapgql responces sometimes and getting following messages in console. Though My Internet connection completely normal and and speed is about 10MBps, I am getting follwing error sometimes!!\r\n\r\n\r\n2020-08-02 01:07:00.435742+0530 Dwell[16526:884485] Task <080DA3DA-F4E7-4F5C-9DE3-D2B77A55F81B>.<8> HTTP load failed, 159275/0 bytes (error code: -1005 [4:-4])\r\n2020-08-02 01:07:00.461811+0530 Dwell[16526:884303] Task <080DA3DA-F4E7-4F5C-9DE3-D2B77A55F81B>.<8> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 \"The network connection was lost.\" UserInfo={_kCFStreamErrorCodeKey=-4, NSUnderlyingError=0x6000014c4300 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 \"(null)\" UserInfo={NSErrorPeerAddressKey={length = 16, capacity = 16, bytes = 0x10021f9b12da60e20000000000000000}, _kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <080DA3DA-F4E7-4F5C-9DE3-D2B77A55F81B>.<8>, _NSURLErrorRelatedURLSessionTaskErrorKey=(\r\n \"LocalDataTask <080DA3DA-F4E7-4F5C-9DE3-D2B77A55F81B>.<8>\"\r\n), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://localhost:8091/graphql, NSErrorFailingURLKey=https://localhost:8091/graphql, _kCFStreamErrorDomainKey=4}\r\nThe operation couldn’t be completed. (Apollo.URLSessionClient.URLSessionClientError error 2.)\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! That error is coming from Apple's URL loading system, not from Apollo. I've got no idea why that would be happening with `localhost` - that shouldn't even be going out of your local network. \r\n\r\nI don't _think_ it's `http` vs `https` since that would theoretically be a different error, but it might be worth giving it a shot since most of the time `localhost` doesn't have SSL set up. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since I haven't heard anything back here in a couple weeks, I'm going to close this issue out. @guru-mtech if you're still having problems, feel free to reopen. Anyone else having similar problems, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Error \"Variable \"$id\" is never used\" not fail build process","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"},"body":"when generate API.swift with graphql file that has unuse variables.\r\nan error `Variable \"xxx\" is never used in operation \"xxx\"` is log but build process is success and run an app normally\r\n```\r\nquery Repo($id: ID!) {\r\n currentuser {\r\n id\r\n }\r\n}\r\n\r\n```\r\n\r\n\r\nbut on other error, the build process will fail \r\n\r\nEx. generate API.swift with below graphql result an error \r\n\r\n`error: Cannot query field \"something\" on type \"Query\". Did you mean \"setting\"?` \r\n\r\nand build process is fail\r\n```\r\nquery Repo {\r\n currentuser {\r\n id\r\n }\r\n something\r\n}\r\n```\r\n\r\nPS: Apollo version 0.27.1","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I would first recommend updating to a more recent version of the SDK - IIRC this was a bug in the underlying CLI that has since been addressed. If that doesn't help, let me know. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"update to Apollo 0.30.0 doesn't help. ","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"```\r\nVariable \"$id\" is never used in operation \"Repo\".\r\n\r\nCommand PhaseScriptExecution emitted errors but did not return a nonzero exit code to indicate failure\r\n```\r\n\r\n\r\nError from log when build with\r\n\r\n```\r\nquery Repo($id: ID!) {\r\n currentuser {\r\n id\r\n }\r\n}\r\n```","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"OK - are you using the shell script or the Swift Scripting method to run your codegen? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm not sure about that.\r\n\r\nI add a run script phase on Build Phase that has script below with shell = sh \r\n```\r\nPATH=$PATH:/usr/local/opt/node@8/bin\r\nSCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\n\r\nif [ -z \"${XCS_BOT_NAME}\" ]; then\r\n\r\ncd \"${SRCROOT}/${TARGET_NAME}\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./GraphQL/**/*.graphql --localSchemaFile=\"GraphQL/Generated/schema.json\" GraphQL/Generated/API.swift --customScalarsPrefix=GraphQL\r\nfi\r\n\r\n```","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"Yep that's the shell script method. Can you confirm that in your schema `currentuser` requires a non-optional `id`, meaning an `ID!`? If it only requires an `ID` (without the exclamation point) then that might be the source of the issue. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"`currentuser ` does not require any variables.`$id: ID!` is just unuse variable that i forgot to remove. it can change to any variable Ex. `Repo($abcd: String!)` or ` Repo($test: Int!)`\r\n\r\nif RepoQuery never called or called with given variable Ex. `RepoQuery(abcd: \"a\")` it'll build success with error that mention before but will throw an `Variable $abcd is never used in operation \"Repo\"` from the server","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"> `currentuser` does not require any variable\r\n\r\nI'm almost positive this is why it's not exiting, then. When the error is more of a \"Hey, you forgot to remove this, but there are no real consequences to not using this\" rather than a \"Nope, this is not a valid query\", we don't want to fail the entire build. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I understand that it's not a fatal error for an entire app. but if the query is sent to graphql server it'll always fail due to graphql default validation rule(if I understand it correctly). \r\nSo, I think it's not different from invalid query because the query always fails if sends to server","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"Hm...what server are you using? I think that might be a server implementation detail, but I could be wrong. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"`apollo-server-express` from https://github.com/apollographql/apollo-server/tree/main/packages/apollo-server-express\r\n","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"`GraphQL operation is only valid if all variables defined by an operation are used `\r\nfrom graphql-js [line](https://github.com/graphql/graphql-js/blob/80471134f1152c69da2cc27518a127991cc801b9/src/validation/rules/NoUnusedVariablesRule.d.ts#L7\r\n)\r\n\r\nI'm not sure that the server can choose to enable/disable this rule but I think it enable by default.","author":{"__typename":"User","login":"Mangese","id":"MDQ6VXNlcjIxNTEyNTI4","name":"Mangese"}},{"__typename":"IssueComment","body":"Ahhh got it. OK, will talk to some tooling folks on this.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"(FYI that team is super backed up, so it may take some time)","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"So our tooling folks are working on a new Rust-based parsing and validation of schema + queries, it will have to land with that. \r\n\r\nI believe the reason it's not in there right now is because it would cause errors when people were using it in watch mode (mostly useful for JS) and it got disabled for that. However, I'm going to be working to make sure there's at least a mode that can be selected in new Rust stuff to bomb out on errors like this. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Crashlytics reported: \"Crashed: com.apollographql.DataLoader\"","author":{"__typename":"User","login":"Kharauzov","id":"MDQ6VXNlcjE4MjQzNTI1","name":"Serhii Kharauzov"},"body":"Hi 👋, We have a version of iOS Apollo SDK: 0.27.0\r\n\r\nWe've got many crashes:\r\n\r\nURLSessionClient.swift line 85\r\nURLSessionClient.sendRequest(_:rawTaskCompletionHandler:completion:)\r\n\r\nCrashed: com.apollographql.DataLoader\r\nEXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000\r\n\r\nWill be thankful for any suggestion or help 🙏🏼\r\n\r\nIt happened for different iOS versions and different devices.\r\nHere is a stack trace:\r\n```\r\nApollo\r\nURLSessionClient.swift - Line 85\r\nURLSessionClient.sendRequest(_:rawTaskCompletionHandler:completion:) + 85\r\n2\r\nApollo\r\nHTTPNetworkTransport.swift - Line 159\r\nHTTPNetworkTransport.send
(operation:isPersistedQueryRetry:files:completionHandler:) + 159\r\n3\r\nApollo\r\nApolloClient.swift - Line 70\r\nApolloClient.send(operation:shouldPublishResultToStore:context:resultHandler:) + 70\r\n4\r\nApollo\r\nApolloClient.swift - Line 287\r\nFetchQueryOperation.fetchFromNetwork() + 287\r\n5\r\nApollo\r\nApolloClient.swift - Line 282\r\nclosure #1 in FetchQueryOperation.start() + 282\r\n6\r\nApollo\r\nApolloStore.swift - Line 193\r\nclosure #2 in ApolloStore.load(query:resultHandler:) + 193\r\n7\r\nApollo\r\nPromise.swift - Line 142\r\nclosure #1 in closure #1 in Promise.catch(_:) + 142\r\n8\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n9\r\nApollo\r\n - Line 4351234200\r\nclosure #1 in Promise.resolve(_:) + 4351234200\r\n10\r\nApollo\r\n - Line 4351232104\r\nPromise.resolve(_:) + 4351232104\r\n11\r\nApollo\r\nPromise.swift - Line 213\r\nPromise.reject(_:) + 213\r\n12\r\nApollo\r\nPromise.swift - Line 122\r\nclosure #1 in closure #1 in Promise.andThen(_:) + 122\r\n13\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n14\r\nApollo\r\n - Line 4351234200\r\nclosure #1 in Promise.resolve(_:) + 4351234200\r\n15\r\nApollo\r\n - Line 4351232104\r\nPromise.resolve(_:) + 4351232104\r\n16\r\nApollo\r\nPromise.swift - Line 213\r\nPromise.reject(_:) + 213\r\n17\r\nApollo\r\nPromise.swift - Line 165\r\nclosure #1 in closure #1 in Promise.map(_:) + 165\r\n18\r\nApollo\r\npartial apply for closure #1 in closure #1 in Promise.map(_:) + 4351241932\r\n19\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n20\r\nApollo\r\n - Line 4351234200\r\nclosure #1 in Promise.resolve(_:) + 4351234200\r\n21\r\nApollo\r\n - Line 4351232104\r\nPromise.resolve(_:) + 4351232104\r\n22\r\nApollo\r\nPromise.swift - Line 213\r\nPromise.reject(_:) + 213\r\n23\r\nApollo\r\nPromise.swift - Line 142\r\nclosure #1 in closure #1 in Promise.catch(_:) + 142\r\n24\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n25\r\nApollo\r\n - Line 4351234200\r\nclosure #1 in Promise.resolve(_:) + 4351234200\r\n26\r\nApollo\r\n - Line 4351232104\r\nPromise.resolve(_:) + 4351232104\r\n27\r\nApollo\r\nPromise.swift - Line 213\r\nPromise.reject(_:) + 213\r\n28\r\nApollo\r\nPromise.swift - Line 122\r\nclosure #1 in closure #1 in Promise.andThen(_:) + 122\r\n29\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n30\r\nApollo\r\n - Line 4351234200\r\nclosure #1 in Promise.resolve(_:) + 4351234200\r\n31\r\nApollo\r\n - Line 4351232104\r\nPromise.resolve(_:) + 4351232104\r\n32\r\nApollo\r\nPromise.swift - Line 213\r\nPromise.reject(_:) + 213\r\n33\r\nApollo\r\nPromise.swift - Line 142\r\nclosure #1 in closure #1 in Promise.catch(_:) + 142\r\n34\r\nApollo\r\nPromise.swift - Line 238\r\nclosure #1 in Promise.whenResolved(_:) + 238\r\n35\r\nApollo\r\nPromise.swift - Line 4351205536\r\nPromise.whenResolved(_:) + 4351205536\r\n36\r\nApollo\r\nPromise.swift - Line 136\r\npartial apply for closure #1 in Promise.catch(_:) + 136\r\n37\r\nApollo\r\nPromise.swift - Line 68\r\nPromise.init(_:) + 68\r\n38\r\nApollo\r\nPromise.swift - Line 135\r\nclosure #1 in closure #1 in Promise.flatMap(_:) + 135\r\n39\r\nApollo\r\npartial apply for closure #1 in closure #1 in Promise.map(_:) + 4351241932\r\n40\r\nApollo\r\n - Line 4351240464\r\npartial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351240464\r\n41\r\nApollo\r\nspecialized closure #1 in Promise.resolve(_:) + 4351233008\r\n42\r\nApollo\r\nspecialized Promise.fulfill(_:) + 4350994784\r\n43\r\nApollo\r\n - Line 4350998216\r\npartial apply for specialized Promise.fulfill(_:) + 4350998216\r\n44\r\nApollo\r\nPromise.swift - Line 163\r\nspecialized closure #1 in closure #1 in Promise.map(_:) + 163\r\n45\r\nApollo\r\npartial apply for specialized closure #1 in closure #1 in Promise.map(_:) + 4351244372\r\n46\r\nApollo\r\n - Line 4351244132\r\npartial apply for specialized thunk for @escaping @callee_guaranteed (@in_guaranteed Result) -> () + 4351244132\r\n47\r\nApollo\r\n - Line 4351232400\r\nspecialized closure #1 in Promise.resolve(_:) + 4351232400\r\n48\r\nApollo\r\nPromise.swift - Line 4350994980\r\nspecialized Promise.fulfill(_:) + 4350994980\r\n49\r\nApollo\r\n - Line 4351012708\r\npartial apply for specialized thunk for @escaping @callee_guaranteed (@in_guaranteed B) -> () + 4351012708\r\n50\r\nApollo\r\nDataLoader.swift - Line 53\r\nspecialized closure #3 in closure #1 in DataLoader.dispatch() + 53\r\n51\r\nApollo\r\n - Line 4351012380\r\npartial apply for specialized thunk for @escaping @callee_guaranteed (@guaranteed [B]) -> (@error @owned Error) + 4351012380\r\n52\r\nApollo\r\nPromise.swift - Line 122\r\nspecialized closure #1 in Promise.andThen(_:) + 122\r\n53\r\nApollo\r\nDataLoader.swift - Line 4351009748\r\nspecialized closure #1 in DataLoader.dispatch() + 4351009748\r\n54\r\nApollo\r\n - Line 4350967396\r\nthunk for @escaping @callee_guaranteed () -> () + 4350967396\r\n```\r\n\r\n\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hello, this was addressed in [0.27.1](https://github.com/apollographql/apollo-ios/blob/main/CHANGELOG.md#v0271), I recommend updating your client. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd , hello👋 Roger that. We've already updated to the latest version 0.30.0. \r\nWe'll see soon if it solves the issue.\r\nThanks.","author":{"__typename":"User","login":"Kharauzov","id":"MDQ6VXNlcjE4MjQzNTI1","name":"Serhii Kharauzov"}},{"__typename":"IssueComment","body":"OK great - I'm going to close this since it was a known issue with 0.27.0. If you're still seeing problems with this on 0.30.0, please open a new issue and we'll figure it out. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Getting \"The request timed out.\" sometimes while calling query and mutation.","author":{"__typename":"User","login":"DiwakarThapa","id":"MDQ6VXNlcjI5OTE3Nzk5","name":"diwakar thapa"},"body":"Hello!!! \r\nSometimes when I open the app I cannot get the **response of the first query** it requests rather I get the following **timeout error message** on Xcode debug console. I tried every possible solution found on StackOverflow but could find any effective solution and also could not figure out why **\"The request timed out.\"** has occurred in the first place. Our Android team is also experiencing similar issues. On the **server-side**, the timeout interval is **65 seconds**. so, I set request timeout interval **65 seconds** but it didn't work. \r\n\r\n**Console Error**\r\n```\r\nError Domain=NSURLErrorDomain Code=-1001 \"The request timed out.\" UserInfo={_kCFStreamErrorCodeKey=-2103, NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <1874F8BE-FA0F-45E1-8A51-96F290D85883>.<2>, NSURLErrorRelatedURLSessionTaskErrorKey=(\r\n \"LocalDataTask <1874F8BE-FA0F-45E1-8A51-96F290D85883>.<2>\"\r\n), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=https://example.graphql, NSErrorFailingURLKey=https://example.graphql, _kCFStreamErrorDomainKey=4}\r\n```\r\n**Is this apollo-ios terminating the request itself or server-side error?** ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"This is an error from Apple's URL loading system, the timeout is happening there. Are you saying that the timeout is happening before the 65 seconds that you set it to? Or just that it's still happening? The fact that your Android app is also having a similar problem points pretty squarely at your server.\r\n\r\nAlso am I correct in assuming that the url string here `https://example.graphql` is a placeholder for your real URL? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd `https://example.graphql` is a placeholder for our real URL? timeout is happening at 65 seconds.","author":{"__typename":"User","login":"DiwakarThapa","id":"MDQ6VXNlcjI5OTE3Nzk5","name":"diwakar thapa"}},{"__typename":"IssueComment","body":"Yeah that sounds like the request timeout is working as expected and the issue is that the request is, in fact, timing out, and that the issue is most likely going to be on your server side. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"thank you @designatednerd ","author":{"__typename":"User","login":"DiwakarThapa","id":"MDQ6VXNlcjI5OTE3Nzk5","name":"diwakar thapa"}},{"__typename":"IssueComment","body":"@designatednerd I forget to mention one thing, on **graphql playground** if we request the same query or mutation multiple times the response arrives without \"The request timed out. \" error but on the app side sometimes \"The request timed out. \" error appears. why is that?","author":{"__typename":"User","login":"DiwakarThapa","id":"MDQ6VXNlcjI5OTE3Nzk5","name":"diwakar thapa"}},{"__typename":"IssueComment","body":"GraphQL playground generally runs on your the same server as your endpoint, so in theory it's just making local calls. It's also possible that there's some kind of credential that is available through the web that's not going through to mobile. I wish I could narrow it down for you but unfortunately there are about a zillion things that could go wrong here. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@DiwakarThapa did you find a solution for your Problem? In our application, we have the same behaviour. Sometimes we run into a timeout, but the GraphQL Playground is always working.","author":{"__typename":"User","login":"DaTebe","id":"MDQ6VXNlcjEyOTY3MzA1","name":"DaTebe"}}]}},{"__typename":"Issue","title":"extensions property on GraphQLResult","author":{"__typename":"User","login":"paulkite","id":"MDQ6VXNlcjQwOTMwMDc=","name":"Paul Kite"},"body":"Hello! Curious if there are any plans to implement the `extensions` hash map support on `GraphQLResult`. I see the Android implementation has this and would love to be able to have the same ability to use this as well.\r\n\r\nThanks!","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"This [is implemented on `GraphQLError`](https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/GraphQLError.swift#L33) on our end. Are you using it in a non-error capacity? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes. Our team sends non-error information through `extensions`.","author":{"__typename":"User","login":"paulkite","id":"MDQ6VXNlcjQwOTMwMDc=","name":"Paul Kite"}},{"__typename":"IssueComment","body":"OK - looking at [the spec](https://spec.graphql.org/June2018/#sec-Response-Format) it does appear `extensions` is allowed at the root of the response. \r\n\r\nI'm somewhat swamped at the moment - if you want to make a PR you're more than welcome to (just make sure to add tests!) but I'll try to get to it as I can if not. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thank you so much for the response!","author":{"__typename":"User","login":"paulkite","id":"MDQ6VXNlcjQwOTMwMDc=","name":"Paul Kite"}},{"__typename":"IssueComment","body":"@designatednerd Just curious, what's the usual turnaround on PRs from the community to getting into a release?","author":{"__typename":"User","login":"paulkite","id":"MDQ6VXNlcjQwOTMwMDc=","name":"Paul Kite"}},{"__typename":"IssueComment","body":"Usually fairly quick if they're small. It'd almost certainly be faster than waiting for me to have bandwidth 😛 ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"This shipped as part of 0.32.0!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"GraphQLQueryWatcher - fetch and watch flow.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null},"body":"Let's discuss watchers, cache and their flow.\r\n\r\nCold start of application - no cache at all. \r\n**Here are my debug logs:**\r\n```\r\nisReachable true //Reachability change\r\nUser: nil //No user logged in \r\napollo.watch(query: SyncManagerQuery(), cachePolicy: .returnCacheDataDontFetch) \r\nWatch SyncManagerQuery // We are interested ONLY in cached data.\r\nWatch SyncManagerQuery error //Error cache is empty. It's ok\r\nMissing value //Error description - missing value. Because cache is empty. \r\n\r\n```\r\n\r\nHere everything seems to be fine. We are starting application for the first time. Cache is empty. Query watcher is being triggered and is returning error because of lack of data in cache.\r\n\r\nNow let's move forward and log in.\r\n\r\n```\r\nOptional() //Now we've got user\r\nfetch. apollo.fetch(query: SyncManagerQuery(), cachePolicy: .fetchIgnoringCacheData) \r\nFetch Sync FETCH //Ignoring cache data is still creating cache am I right?\r\nSync Fetch success //Fetch is successful \r\nBUT NOTHING IS HAPPENING :(\r\n```\r\n\r\n**Question 1:** Why watcher is not reacting? It is being stored in a parent object. \r\n`private var syncWatcher: GraphQLQueryWatcher?`\r\nand is initialized before fetch trigger.\r\n\r\nOk let's start over again. Close the application and start again with already existing cache. \r\n\r\n```\r\nisReachable true //We've got internet\r\nOptional() //We've got user\r\nFetch Sync FETCH //Above conditions are triggering FETCH\r\nWatch SyncManagerQuery //Hmm watch is also starting? Not that scary ok, it is just executing for the first time?\r\nWatch SyncManagerQuery success //Success - because we already have cache so it's ok\r\nSync Fetch success //In the meantime FETCH just finished\r\nWatch SyncManagerQuery // **1*** So it is triggering watch. Not sure why.\r\nWatch SyncManagerQuery error //Error :(The operation couldn’t be completed. (Apollo.URLSessionClient.URLSessionClientError error 2.) **2**\r\nWatch SyncManagerQuery // But hey it is trying once again \r\nWatch SyncManagerQuery success // And this time we've got a success.\r\n```\r\n\r\n**Question 2:** - Fetch result had no changes at all. It was exactly the same. Is watcher reacting to just cache update or is it verifying actual changes?\r\n**Question 3:** - Why it fails? And the retry is normal behavior after failure or is it a side effect of sth else?\r\n\r\n\r\nOk let's start over again. Exactly same conditions. We already have cache.\r\n```\r\n\r\nisReachable true //We've got internet\r\nOptional() //We've got user\r\nFetch Sync FETCH //Starting fetch\r\nWatch SyncManagerQuery \r\nWatch SyncManagerQuery success //Watching cache successful\r\nSync Fetch success //Fetching data successful, cache is being refreshed\r\nWatch SyncManagerQuery //And this is probably triggering watch \r\nWatch SyncManagerQuery success //Watch is successful\r\nWatch SyncManagerQuery //**1** But what is happening? Why it is triggering once again?\r\nWatch SyncManagerQuery success\r\n\r\n```\r\n**Question 4:** - why my watch query seems to be triggering twice after fetch? ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! I renumbered your questions so it would be clearer which one i'm responding to once I get more information here. Some things that would be helpful to understand: \r\n\r\n- Are you using the SQLite cache or the in-memory cache? \r\n- In the second code block (just before question 1), you are still running the watcher which was started in the first code block, and that's what you're expecting to get hit when you've added \"But nothing is happening\", correct?\r\n- After Question 1, you say \"close the application and start again\" - do you mean that you just exit the application then go back into it, or that you force-quit the application? \r\n- For the 3rd and 4th sets of logs, are you specifying a cache policy or using the default `.returnCacheDataElseFetch`? \r\n- Where in the application lifecycle are you setting up your watcher? Is it possible that the watcher could be getting set up multiple times? \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"1. SQLite cache\r\n2. That is the same app session. So yeah watcher is still up and running.\r\n3. Reset the application. New session. SQLite cache already exists. Just wanted to check how watcher is going to act with existing cache and initializing once again.\r\n4. Watch is always using returnCacheDataDontFetch, fetch is alwasy using fetchIgnoringCacheData\r\n5. Not possible in that case. My AppDelegate is starting the whole FlowControlAgent which is Singleton here.\r\n\r\nAll problems seems to be similar to \"cold start\" problem described here \r\nhttps://github.com/apollographql/apollo-ios/issues/99 \r\n","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"Yeah, this from @martijnwalraven in #99 definitely seems to explain why your first watcher isn't called:\r\n\r\n> Because your watch uses `.returnCacheDataDontFetch`, and the cache is initially empty, it will never get a valid response in that case.\r\n\r\nIs there a chance you could send me a small repro project? I should at least be able to try to figure out why the `watch` is getting called twice, but it'd be pretty hard to do without something to debug. You can email it to ellen at apollographql dot com. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'll do my best to prepare some sample however now I'm out of time. Hopefully will send you sth around weekend. \r\nRight now, well, I can live with double watcher :) ","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"@pgawlowski Were you ever able to get a sample together? If not, do you mind if we close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey @designatednerd \r\n\r\nSorry for not providing my sample code. It's still on my personal ToDo however I am totally sucked into other work. Let's close this issue right now. Hope I will provide some sample that will be helpful to validate this issue in some time - maybe during my vacations :) \r\n\r\nThanks for everything!","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}}]}},{"__typename":"Issue","title":"Cache and queries, unable to fetch record by ID.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null},"body":"So let's start with sth like this. Fetch and cache using SQLite normalized cache.\r\n```\r\nquery Sync {\r\n\tviewer {\r\n\t\tthings {\r\n\t\t\tnodes {\r\n\t\t\t\tid\r\n }\r\n }\r\n }\r\n}\r\n\r\n```\r\nHere is our cacheKeyForObject\r\n\r\n ```\r\n client.cacheKeyForObject = { (object) in\r\n if\r\n let id = object[\"id\"] as? String,\r\n let type = object[\"__typename\"] as? String {\r\n return [id, type]\r\n }\r\n // No id or typename, don't do caching\r\n return nil\r\n } \r\n\r\n```\r\nI also tried the basic one \r\n`client.cacheKeyForObject = { $0[\"id\"] }`\r\n\r\nWe've got (or at least out backend claims that we've got) unique ID's.\r\nNext I want to perform query with cachePolicy: `.returnCacheDataDontFetch`.\r\n\r\n```\r\nquery ThingActionConnection($thingId: ID!) {\r\n thing: node(id: $thingId) {\r\n ...on Thing {\r\n id\r\n }\r\n }\r\n} \r\n```\r\n\r\nResult is `GraphQLResultError(path: thing, underlying: Apollo.JSONDecodingError.missingValue)`\r\nThe more I dig down into apollo and caching the less I know how exactly this supposed to work. \r\n\r\nNetwork call is giving us correct results. What is more I checked local sqliteDB and there is a results with this particular `$thingId`. \r\n\r\nAndroid developer is getting results with ease. On our side, JSONDecodingError. \r\nI am nearly 100% sure that the problem is with cacheKeyForObject or ios apollo is unable to handle nodes here?\r\n\r\n@edit\r\nSame goes for \r\n```\r\n\r\nquery ThingActionTest($thingId: ID!) {\r\n viewer {\r\n thing(id: $thingId) {\r\n id\r\n }\r\n }\r\n}\r\n\r\n```\r\n\r\n@edit 2:\r\n\r\nInteresting fact is - direct cache access with same id works totally fine.\r\n\r\n```\r\n apolloClient.store.withinReadTransaction({ transaction in\r\n do {\r\n let variables = [\"isReady\": false]\r\n let data = try transaction.readObject(ofType: ThingAction.self, withKey: actionId, variables: variables)\r\n print(data)\r\n } catch {\r\n print(error.localizedDescription)\r\n }\r\n })\r\n```\r\nThis is only giving me more confusion about query execution on cache.\r\n\r\nI also noticed that direct cache access using query is giving me some confusing error.\r\n`Error at path \"thing)\": missingValue`\r\nWhy it is printing ')' character there? \r\n@edit ok it's just a typo in GraphqlExecutor.swift line 36.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"> The more I dig down into apollo and caching the less I know how exactly this supposed to work.\r\n\r\nWelcome to my last year, my friend 🙃. And also to why I'm planning to simplify a bunch of stuff in the Cache as part of phases 2-3 of the swift codegen rewrite if it's at all possible.\r\n\r\nI can tell you for sure that iOS and Android have no cache compatibility guarantees right now, and that I *think* the issue is that you're using a fragment on a node, and that you don't have the `id` on the node itself - that means that the node won't have an ID, and it won't go into the cache. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I finally figured it out. The problem was missing variables. \r\n\r\nHowever what I noticed is that sometimes when I am asking for data one by one I am getting\r\n`GraphQLResultError(path: lock.id, underlying: Apollo.JSONDecodingError.missingValue)` without any particular reason. Because starting exactly the same `withinReadTransaction` few seconds later is giving me correct response.\r\n","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"Is it giving you that error maybe because the data has not yet been populated? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Data is populated. \r\nI am executing exactly the same load and it can give a results like:\r\n\"I've got data.\"\r\n\"I've got data.\"\r\n\"I've got data.\"\r\nGraphQLResultError(path: lock.id, underlying: Apollo.JSONDecodingError.missingValue)\r\nGraphQLResultError(path: lock.id, underlying: Apollo.JSONDecodingError.missingValue)\r\n\"I've got data.\"\r\n\r\nNo fetching or repopulating cache in between.\r\nUser is offline and no cache manupulations are happening. I just wondered if there is a chance of some sort data access race here?\r\n\r\nI digged down ino the sql file and found that when I am getting this error the reference ID of one object is missing and right after getting data back there is a new one, different than previous (before missing value) one.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}},{"__typename":"IssueComment","body":"There is definitely a possibility of a data race, there are some known issues with threading in the cache at the moment.\r\n\r\nI'd really need to see your exact code to figure out what's going on with your references - the reference ID should be stable, but any number of things could be happening here to mess that up. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@pgawlowski Were you ever able to resolve this issue? Anything I can do to help here or do you mind if I close this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey @designatednerd \r\nActually yes. The main problem was old cache + messed id's. \r\nThank you for your help.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null}}]}},{"__typename":"Issue","title":"How to download schema.json with apollo client for an endpoint with url params and multi headers?","author":{"__typename":"User","login":"XiaoxiaYao","id":"MDQ6VXNlcjIyODk5MDk2","name":"MichaelYao"},"body":"Hi,\r\n\r\nI am trying to download a schema.json file from an endpoint. However, I don't know how to config the the url params and multi headers? Please check the pic below:\r\n![image](https://user-images.githubusercontent.com/22899096/89851786-e5de2980-dbbf-11ea-9a36-1c3499af4dc2.png)\r\nI am able to use graphql in graphiql. But don't know how to config in terminal. I tried:\r\n`apollo client:download-schema --endpoint=https://xxxxxxxxxxx/graphql/ --header='xxxxx-API-Key:xxxx;xxxxx-k:xxxxxx' --data='co=US'`\r\nHowever still no luck. Can anyone help me with this? I did not any doc about this ...so I am here. I don't know how to specify co=US and how to separate the headers with ,(comma) or ; (semi comma) Thank you in advance. Thanks.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! Each header must be passed in separately like so: `--header=\"Header-Key: Header Value\" --header=\"Header-Key-2: Header Value 2\"`\r\n\r\nThere is also a way to set this up using the [Swift Scripting lib](https://www.apollographql.com/docs/ios/swift-scripting) using the [`ApolloSchemaDownloader`](https://www.apollographql.com/docs/ios/swift-scripting/#downloading-a-schema). ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> Hi! Each header must be passed in separately like so: `--header=\"Header-Key: Header Value\" --header=\"Header-Key-2: Header Value 2\"`\r\n> \r\n> There is also a way to set this up using the [Swift Scripting lib](https://www.apollographql.com/docs/ios/swift-scripting) using the [`ApolloSchemaDownloader`](https://www.apollographql.com/docs/ios/swift-scripting/#downloading-a-schema).\r\n\r\nThank you. Sorry, one more thing. Do you know how to deal with url params? co=US? How should I set it?","author":{"__typename":"User","login":"XiaoxiaYao","id":"MDQ6VXNlcjIyODk5MDk2","name":"MichaelYao"}},{"__typename":"IssueComment","body":"URL params should just be the same as a normal URL - `https://example.com?paramName=paramValue¶m2name=param2Value`","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Cool. I will have a try. Thank you @designatednerd. Have a nice day!","author":{"__typename":"User","login":"XiaoxiaYao","id":"MDQ6VXNlcjIyODk5MDk2","name":"MichaelYao"}},{"__typename":"IssueComment","body":"@XiaoxiaYao Mind if we close this issue out then? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm gonna close this out - @XiaoxiaYao if you have further problems please reopen. Anyone else experiencing similar problems, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Changing converting logic for custom objects","author":{"__typename":"User","login":"Shiaulis","id":"MDQ6VXNlcjEzNjAxNzQ4","name":"Andrius Shiaulis"},"body":"Hey awesome Apollo team. I have a question related to custom scalar objects.\r\nWe are moving towards using GraphQL and I'm trying to adapt it for our requests. The problem occurs whenever I'm trying to convert custom objects from our response.\r\nOur backend is using `JSON` type for legacy information. Codegen is trying to convert it to a string:\r\n![image](https://user-images.githubusercontent.com/13601748/90020057-f8d42500-dcb7-11ea-8132-dc3b28699b36.png)\r\n\r\nIs there any way to specify that we don't want that object to be converted to a string?\r\nFor now I know only one solution: pass `--passthroughCustomScalars` key, but the downside of this approach is that I need to create global typealias or type for with `JSON` name for the whole project. Is there any way to not convert the object at all so it can convert ANY type or some more specific name like `ApolloJSON` so in that case name would be more specific?\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Okay I found codegen Readme file :) At least I can make prefix for custom scalars by passing it with codegen option:\r\n```\r\n--customScalarsPrefix=\"Apollo\"\r\n```","author":{"__typename":"User","login":"Shiaulis","id":"MDQ6VXNlcjEzNjAxNzQ4","name":"Andrius Shiaulis"}},{"__typename":"IssueComment","body":"Yep, there's also a `namespace` option that wraps all your stuff in a big `enum` to namespace it. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"HTTPNetworkTransport's URLSessionClient possible [ lost calls / memory leak ]","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null},"body":"Hi team!\r\nFirst of all, thanks for an awesome framework that makes the lives of so many of us that much easier 😄\r\n\r\nWe have run into a [lost calls / memory leak] issue.\r\nWe believe it is closely linked to issue https://github.com/apollographql/apollo-ios/issues/1292.\r\n\r\n### SETUP\r\nDependency manager: SPM\r\nApollo-iOS version: 0.30.0\r\nSetup: Instanced (not a Singleton)\r\n\r\nAlso we provide a `URLSessionClient` that runs on a background callbackQueue to the `HTTPNetworkTransport`:\r\n```\r\nURLSessionClient(\r\n sessionConfiguration: URLSessionConfiguration.background(withIdentifier: \"background\"),\r\n callbackQueue: .some(operation)\r\n)\r\n```\r\n\r\n### INTENDED OUTCOME\r\nWe expect that the calls of all instanced ApolloClients return successfully.\r\nWe also expect that ApolloClients that are not retained in our code get deallocated from the system memory.\r\n\r\n### ACTUAL OUTCOME\r\nWe first noticed that for some reason, new instances of `ApolloClient` (those created after the first instance is not retained in our code anymore) never return from their calls This has made us notice that the created `URLSessionClient`s, `HTTPNetworkTransport`s and `ApolloClient`s are never deallocated properly causing a memory leak.\r\n\r\n### REPRODUCTION STEPS\r\n1 - Make a call with the setup described above.\r\n2 - Remove the retained instance of the ApolloClient.\r\n3 - Create a new ApolloClient and make a new call.\r\n4 - Call does not come back / memory leak occurs.\r\n5 - Repeat from step 2 to create a new unwanted retained instance of `URLSessionClient`, `HTTPNetworkTransport` and `ApolloClient`.\r\n\r\n### OUR CONCLUSIONS\r\nThis part should be taken with a grain of salt as we are not Apollo experts. That said, it is the only conclusion that survived our tests. Having found this https://stackoverflow.com/questions/62612056/why-dispatchqueue-global-still-alive-after-deinit on StackOverflow, we think that the problem stems from the queue keeping alive the instance of the `URLSession` created in `URLSessionClient` in some fashion.\r\n\r\nThis causes multiple retains climbing up the dependence graph of:\r\n- URLSession\r\n- URLSessionClient\r\n- HTTPNetworkTransport\r\n- ApolloClient\r\n- Objects in our code that calls ApolloClient ...\r\n\r\n### OUR SOLUTION\r\nAdding the following to `HTTPNetworkTransport` fixes both our issues:\r\n```\r\ndeinit {\r\n self.client.session.invalidateAndCancel()\r\n}\r\n```\r\n\r\nWe understand that this is most probably not the solution you will want to implement but it might help as a starting point to formulate something that will not jeopardize others that use your framework.\r\n\r\n### OUR INVESTIGATION\r\nIt should be said that we took the liberty to try this as there was code in the `URLSessionClient` for `deinit` that clears all tasks. We surmised that clearing the tasks in that situation did not cause a problem for calls in progress, meaning that clients of the framework should not expect the calls to complete if they stop holding their instance of `ApolloClient`.\r\n\r\nBut we noticed that the `deinit` in the `URLSessionClient` was never called even when its parent `HTTPNetworkTransport` `deinit` was called. We then noticed that the `HTTPNetworkTransport` was never deallocated even though its `deinit` was called.\r\n\r\nThat made us realize that something further down the line was probably holding things recursively. Implementing our solution, everything gets deallocated and for some reason, further ApolloClients return their calls successfully.\r\n\r\n### CONCLUSION\r\nAdvice on how to go forward from here would be greatly appreciated.\r\nThanks in advance for your help. We stand ready to answer any of your questions should you have some.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! Thanks for the extremely detailed report. Very, very odd that `deinit` would get called without the `HTTPNetworkTransport` actually being deallocated - usually the telltale sign of a memory leak is that `deinit` never gets called at all. \r\n\r\nIs this only happening with background sessions, or is it also happening with normal sessions? Or are you using a background configuration for all sessions? \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi again!\r\n\r\nTo answer your question, we are using a background configuration for all sessions. As for normal sessions, we do see some memory leaks but they do not impede calls. Maybe the following will be useful.\r\n\r\nWe tried many configurations, mainly:\r\n- not using a URLSessionClient\r\n- using a URLSessionClient with a `.background` configuration and a callbackQueue `.main`\r\n- using a URLSessionClient with a `.background` configuration and a callbackQueue `.some`\r\n\r\nOnly the configuration of `.background` with a callbackQueue `.some` is suitable for us. Otherwise, some computations happen on the main thread when Apollo decodes our objects which brings the application to a crawl. (This is probably due to a specific situation in our code).\r\n\r\n### OUR TESTS\r\nHere are our results with those configurations in both instance setup and singleton setup. The main things we got out of it are that with an instance setup:\r\n- Calls do not come back if we provide a URLSessionClient\r\n- We always see URLSessionClients being kept in memory. In instruments, some are identified as leaks, some are not.\r\n\r\nWe hope this is clear and it did not confuse you to what's happening. As always, we are here if you need more info 😃.\r\n\r\nNo URLSessionClient\r\n---\r\n\r\n#### Instance\r\n✅ Calls come back\r\n✅ Does not retain objects holding ApolloClient instance in our code\r\n🛑 Retain orphaned UrlSessionClients and shows a leak in instruments\r\n\r\n#### Singleton\r\n✅ Calls come back\r\n✅ Does not retain objects holding ApolloClient instance in our code\r\n✅ Does not retain orphaned UrlSessionClients\r\n\r\n\r\nURLSessionClient with callback queue .main\r\n---\r\n\r\n#### Instance\r\n🛑 Calls do not come back\r\n🛑 Retains objects holding ApolloClient instance in our code\r\n🛑 Retains orphaned UrlSessionClients but does not show a leak in instruments\r\n\r\n#### Singleton\r\n✅ Calls come back\r\n✅ Does not retain objects holding ApolloClient instance in our code\r\n✅ Does not retain orphaned UrlSessionClients\r\n\r\n\r\nURLSessionClient with callback queue .some\r\n---\r\n\r\n#### Instance\r\n🛑 Calls do not come back\r\n🛑 Retains objects holding ApolloClient instance in our code\r\n🛑 Retains orphaned UrlSessionClients but does not show a leak in instruments\r\n\r\n#### Singleton\r\n✅ Calls come back\r\n✅ Does not retain objects holding ApolloClient instance in our code\r\n✅ Does not retain orphaned UrlSessionClients","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null}},{"__typename":"IssueComment","body":"I'm going to take a look deeper at this on Monday but one thing to be aware of is that there is no such thing as \"No `URLSessionClient` - a default one will be created for you if you're using `HTTPNetworkTransport`. It uses `.main` as its default queue, so I'm not sure what would be different between that and passing in your own. \r\n\r\nAdditionally: How are you setting up the instances? Is it possible that ARC is clobbering them because they are not properly retained somewhere and one of the assorted `weak self` calls winds up being nil? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks!\r\n\r\nFor the `URLSessionClient`, we figured that one was created on the Apollo framework side if not provided. Seeing the disparity in behaviour, we thought of sending you our observations on that as well. Maybe the difference between providing ours compared to the one by default is that we always put a `URLSessionConfiguration.background` instead of the `.default` one provided by Apollo.\r\n\r\nAs for how we retain instances, if you are talking about the `URLSessionClient`, we create it and give it to the `HTTPNetworkTransport`. It is all done in the same method and we do not retain either the `URLSessionClient` or the `HTTPNetworkTransport`. If you are talking about the `ApolloClient`, we tested swapping the `ApolloClient` for a mock that implements the same methods. We see no retain on our side.","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null}},{"__typename":"IssueComment","body":"So where do you retain the `ApolloClient` which you've handed the `HTTPNetworkTransport` to? Basically, I have a suspicion that the whole stack is getting hammered by ARC before the call returns if the instance is not being held onto somewhere. That would explain why in the `Instance` case listed above calls don't come back.\r\n\r\nAgain, if you have some sample code to share, that would be most helpful.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"The `ApolloClient` is retained by a **repo** object. When the object is instantiated it is injected with a new `ApolloClient` instance and uses it to make its calls.\r\n\r\nThe first time a user navigates to where a call is needed, we create a repo and start a call, it comes back correctly. The second time a user navigates to where a call is needed, we create a new repo and start a call, it never comes back. We keep those instances alive until they are not needed anymore or the user navigates away. In any case, when we create the second `ApolloClient` instance, nothing returns from the call even if held for over 10 minutes.\r\n\r\nI was able to confirm that calls not coming back happens if we provide a `URLSessionConfiguration` that is `.background`.\r\n\r\nAlso, sorry about the late notice but in debug environment, if we provide a `URLSessionConfiguration` that is `.background`, we often hit line 225 of the `URLSessionClient`:\r\n`assertionFailure(\"No data found for task \\(dataTask.taskIdentifier), cannot append received data\")`\r\n","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null}},{"__typename":"IssueComment","body":"I was able to replicate easily with the iOSTutorial project. What is the easiest way to send you that project amended to reproduce?","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null}},{"__typename":"IssueComment","body":"Email! ellen at apollographql dot com. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@EggYoke The sample you sent was very helpful, thank you. The underlying problem was a retain cycle as outlined in #1366. \r\n\r\nThe secondary problem is that you're attempting to create multiple background sessions with the same identifier at the same time, which the system won't let you do. I found that after the changes in #1366 were applied, I was able to get things to work with a background session by just using `UUID().uuidString` as the identifier, as this prevents any collisions in session name. \r\n\r\nHonestly, I wouldn't really recommend using background sessions for everything as it's kind of overkill, but if you need to for reasons I'm missing, that should at least unblock you.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"This has shipped with `0.31.0` - if you're still having issues with that version, please open a new issue and we'll try to figure it out. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thank you very much for the fast response.\r\nOur calls come back successfully and none of our objects are retained anymore.\r\nThis fixed all our issues, awesome job! 👍 ","author":{"__typename":"User","login":"EggYoke","id":"MDQ6VXNlcjY5NjM3NTc4","name":null}}]}},{"__typename":"Issue","title":"Cannot load underlying module for 'Apollo' for unit test target","author":{"__typename":"User","login":"dpatel-git","id":"MDQ6VXNlcjY4NDM2NTk1","name":null},"body":"Hello folks,\r\n\r\nI have following setup.\r\n\r\nXcode 11.3.1 (also tried on 11.6 without success)\r\nApollo 0.29.1\r\nCocoapods 1.9.2\r\n\r\nI am able to compile and run my application, but get the following error when I try to compile the unit test target\r\n\r\n```:0: error: cannot load underlying module for 'Apollo'```\r\n\r\nHere is how I have declared the app and test targets in podfile\r\n\r\n```\r\ntarget 'MyApp' do\r\n pod 'Apollo', Apollo\r\n target 'MyAppTests' do\r\n pod 'OHHTTPStubs', OHHTTPStubs\r\n end\r\nend\r\n```\r\nI have set `MyApp` as host application for the test target\r\n\r\nAny help is appreciated, thanks\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It looks like your `MyAppTests` is missing an `inherit! :search_paths`. See the 2nd example [in the Podfile docs](https://guides.cocoapods.org/using/the-podfile.html). ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks, that fixed the issue.","author":{"__typename":"User","login":"dpatel-git","id":"MDQ6VXNlcjY4NDM2NTk1","name":null}}]}},{"__typename":"Issue","title":"GraphQLQueryWatcher doesn't update its dependent keys","author":{"__typename":"User","login":"teodorpenkov","id":"MDQ6VXNlcjU2MjIyODg=","name":"Teodor Penkov"},"body":"With the `0.23.0` release Apollo changed the way it stores keys in the `QueryWatcher` https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/GraphQLQueryWatcher.swift#L73-L83\r\n\r\nThe problem with this is that the watcher doesn't update its `dependentKeys` like it should. There is a commit that does that but I couldn't follow why it was changed:\r\nhttps://github.com/apollographql/apollo-ios/commit/2b07e69e71a0621795b7089fda84c0ca744ba202\r\n\r\nThe problem that we are experiencing is that we are updating a query in the store with `ReadWriteTransaction` and in the previous versions the updated query captured the newly dependent keys, therefore when a change occured it was propagated to the result handler and now it's not.\r\n\r\nWhat's the reason behind this change and how can we workaround this? Was there a problem with the previous implementation in 0.22.0 https://github.com/apollographql/apollo-ios/blob/0.22.0/Sources/Apollo/GraphQLQueryWatcher.swift#L66-L68","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi, the commit you referenced was part of #1156 which went out with `0.28.0`, not `0.23.0`. You can see a detailed explanation of the bug in #1155. \r\n\r\nWhat version are you actually on right now? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"hey @designatednerd thanks for reaching out.\r\n\r\nI'm using `0.28.0` but I think the problem that I experience is on every version after `0.23.0`.\r\n\r\nOur use case is pagination using the Apollo cache.\r\nWe are doing one `main` query followed by 0 or more `fetch more` queries (based on page info and scroll events) each `fetch more` query updates the main one with its nodes and page info. We've been using this method for a while and it worked pretty well, the reason for that is that the \"main\" query was updating its dependent keys (the nodes from the fetch more queries) and after the commits I mentioned it stopped working.\r\n\r\nMutation values gets to the store correctly but after `didChangeKeys` gets called this results in a watcher's result handler being called with the old values rather than the updated values from the mutation.\r\n\r\nI will run through the commits and PR's that you mentioned and will try to figure out what the problem with the previous behavior was.","author":{"__typename":"User","login":"teodorpenkov","id":"MDQ6VXNlcjU2MjIyODg=","name":"Teodor Penkov"}},{"__typename":"IssueComment","body":"So I know some stuff changed around `0.22.0` that was the motivation for these changes that went out with `0.28.0`, but otherwise I'm not really seeing anything that changed. If you have any suggestions or a PR, I'm more than happy to try them out!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'd either suggest reverting to `0.22.0`'s implementation https://github.com/apollographql/apollo-ios/blob/0.22.0/Sources/Apollo/GraphQLQueryWatcher.swift#L66-L68\r\n\r\nor adding `self.dependentKeys = graphQLresult.dependentKeys` before this line https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/GraphQLQueryWatcher.swift#L79\r\n\r\nIf you don't see problem with that I'm happy to open a PR.","author":{"__typename":"User","login":"teodorpenkov","id":"MDQ6VXNlcjU2MjIyODg=","name":"Teodor Penkov"}},{"__typename":"IssueComment","body":"@designatednerd thanks for the links that you shared. I've checked them and I found the root cause of the problem.\r\n\r\n\"Screen\r\n\r\nI'm pretty sure that if we bring back those lines it wouldn't break anything.","author":{"__typename":"User","login":"teodorpenkov","id":"MDQ6VXNlcjU2MjIyODg=","name":"Teodor Penkov"}},{"__typename":"IssueComment","body":"Hi! Sorry, I was on vacation last week. \r\n\r\nI read [your explanation](https://github.com/apollographql/apollo-ios/pull/1156#discussion_r476476875) here and I think I get it. I'll take a look at this today or tomorrow and see what I can figure out. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Primary Maintainer Out Of Office August 23-30","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"},"body":"I will be taking a break in a place that (not coincidentally) has terrible internet connectivity the week of August 24th. \r\n\r\nKeep opening issues and PRs while I'm out, but please be aware that they will not be addressed until August 31st or thereafter. Thank you for your patience!","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I'm back! ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Ambiguous for type lookup in this context error","author":{"__typename":"User","login":"Shiaulis","id":"MDQ6VXNlcjEzNjAxNzQ4","name":"Andrius Shiaulis"},"body":"Hey hey! Another question from my side :) \r\nIn our backend response contains 2 data fields `userCompanies` and `userCompany` that share type. \r\n![image](https://user-images.githubusercontent.com/13601748/90987179-b81abc80-e591-11ea-9e96-ded615f5630e.png)\r\nThe problem is that code generation creates 2 totally equal structures:\r\n![image](https://user-images.githubusercontent.com/13601748/90987269-573fb400-e592-11ea-8292-1a365a37b737.png)\r\n\r\nIn documentation explorer in GraphiQL I don't see any issues:\r\n![image](https://user-images.githubusercontent.com/13601748/90987304-9837c880-e592-11ea-9f5f-af004aa50ca8.png)\r\n\r\nSo should I still look for a fix on backend side? Is there any way to explain that these data fields share type?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Im getting the exact same problem.\r\n\r\n```swift\r\npublic struct Author: GraphQLSelectionSet {\r\n public static let possibleTypes: [String] = [\"Staff\", \"Customer\"]\r\npublic struct Author: GraphQLSelectionSet {\r\n public static let possibleTypes: [String] = [\"ArticleAuthor\"]\r\n```","author":{"__typename":"User","login":"kylebrowning","id":"MDQ6VXNlcjExMzAyMw==","name":"Kyle Browning"}},{"__typename":"IssueComment","body":"Yeah - this is where the depluralization for type names we're using in the typescript codegen kind of falls apart. The workaround is to use field aliases:\r\n\r\n```graphql\r\nquery MyQuery {\r\n user {\r\n id\r\n userCompany: company // <-- alias\r\n userCompanies\r\n }\r\n}\r\n```\r\n\r\nThis way what's called `userCompany` on your server will be called `company` locally, making the type for that property `Company` and the type for `userCompanies` will be `UserCompany`. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd, thanks for the clarification 👍 ","author":{"__typename":"User","login":"Shiaulis","id":"MDQ6VXNlcjEzNjAxNzQ4","name":"Andrius Shiaulis"}},{"__typename":"IssueComment","body":"@Shiaulis did that work? If so, can we close this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Worked for us. ","author":{"__typename":"User","login":"kylebrowning","id":"MDQ6VXNlcjExMzAyMw==","name":"Kyle Browning"}},{"__typename":"IssueComment","body":"Thanks, let's close it","author":{"__typename":"User","login":"Shiaulis","id":"MDQ6VXNlcjEzNjAxNzQ4","name":"Andrius Shiaulis"}}]}},{"__typename":"Issue","title":"Error: Unable to read file › schema.json. ENOENT: no such file or directory, open 'schema.json'","author":{"__typename":"User","login":"fatma95","id":"MDQ6VXNlcjEyMTc1NDE3","name":"Fatma Mohamed"},"body":"I followed all the correct steps in the document, schema.json and graphql files are on the right places however I always get this error and build fails please help.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! So I'll need a bit more information to help diagnose this. Can you answer a few questions: \r\n\r\n- Have you confirmed that `schema.json` is downloaded and exists where you think it is on your filesystem? \r\n- Are you using the Swift Scripting wrapper or the shell script? \r\n- Can you paste a link to the set of instructions you are following? \r\n\r\nThank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi! I haven't heard back on this issue in over a week so I'm going to close it out - @fatma95 please reopen if you still need help, anyone else with a similar problem, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"No data found for task x, cannot append received data","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"},"body":"One of our tests hitting assert in `URLSessionClient.swift:230` in on CI after updating to latest version (0.31.0).\r\nIt's not networking stack test so don't think we doing anything specific to hit that assert. Looking at code that would indicate some kind race condition...","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Weird! Is it possible it's something leaking over from an older test? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"can't see anything relevant, also it don't happen every run","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"```swift\r\npublic func invalidate() {\r\n self.clearAllTasks()\r\n self.session?.invalidateAndCancel()\r\n self.session = nil\r\n }\r\n```\r\n\r\nshouldn't `self.session?.invalidateAndCancel()` be before `self.clearAllTasks()`? Will try change and see if our tests passes more reliably ","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"Hi! Yeah flipping the cleanup order likely wouldn't help since some tasks are still in-flight, I suspect I need to actually cancel all the in-flight tasks. Thanks for the heads up on this!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Haha damn it, looks like there's a key piece of info about `invalidateAndCancel` that's only in the docs docs and not in the headerdoc: \r\n\r\n\"Screen\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Shipped with version `0.32.1`!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi @designatednerd,\r\n\r\nI am encountering this issue in `0.33.0`, looking at #1383 I'm not quite certain it addressed the root issue given the shared `URLSession` isn't being used in `URLSessionClient`? I have a fairly reproducible case where this `invalidate` logic is getting hit but I'm still encountering this assertion error afterwards, confirmed with some debugging its definitely the same instance floating around. \r\n\r\nThat all said, it does seem that the issue is resolved by calling `invalidateAndCancel` prior to calling the `clear` block (as is currently done in the else branch). I've tested this quite a bit and have been unable to trigger the assertion failure anymore. I'll go ahead and open a PR for you to take a look, hopefully it helps!","author":{"__typename":"User","login":"philfi","id":"MDQ6VXNlcjM5NTY0NjE1","name":null}},{"__typename":"IssueComment","body":"Can confirm that it's not solved in 0.33.0. Just got assert while running tests on iOS12\r\n\r\n\"Screenshot\r\n","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"still happening in 0.36.0 (iOS12 simulator)","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}}]}},{"__typename":"Issue","title":"Crash at runtime when upgrading to 0.31.0 on URLSessionClient.swift, line 95","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"},"body":"Hey guys,\r\n\r\nSo I have an app that works perfectly with 0.30.0 but when upgrading to 0.31.0 I get a crash soon after the app launches:\r\n\r\n```\r\nFatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file /Users/XXX/Library/Developer/Xcode/DerivedData/XXX-bzyicfzsqzelixabxktyzmboxbaj/SourcePackages/checkouts/apollo-ios/Sources/Apollo/URLSessionClient.swift, line 95\r\n```\r\n\r\nThe issue is one this line :\r\n\r\n```\r\nlet task = self.session.dataTask(with: request)\r\n```\r\n\r\nhere `session` is nil.\r\n\r\nLet me know if you need anything else as I can reproduce the crash 100% of the time. Many thanks","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! That's awfully weird, since the session is instantiated in the initializer. Can you share the code you're using to create your client, as well as where in the app lifecycle that's happening? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Something that occurred to me is that in `0.31.0` we added a mechanism to make sure the `URLSession` is properly terminated so as not to create a retain cycle - you can probably throw a breakpoint in [here](https://github.com/apollographql/apollo-ios/blob/d95b4463f78a15fba7e3de2017817a391e9714f0/Sources/Apollo/URLSessionClient.swift#L63) to see if that's getting hit before you get to whatever's creating the data task.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey @designatednerd !\r\n\r\nFirst, thank you very much for answering so quickly, appreciate it :)\r\n\r\nI think your guess of adding a breakpoint into the `invalidate` method of `URLSessionClient` was a good idea. It turns out that when our app starts, we are initializing an `HTTPNetworkTransport` to use into a `SplitNetworkTransport` without any authentication, and when we authenticate (a few seconds after the app starts) we replace that `HTTPNetworkTransport` with a new one, simply by dereferencing the old one and keeping a pointer on a new `SplitNetworkTransport` that contains this new client.\r\n\r\nI think that what may happen is that the first client may have started some work in background, and when it gets destroyed this work hasn't finished, leading to this crash as the `session` is already nil. Could that be possible? ","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"That's possible - I've added some code in #1383 that should cancel any inflight operations on a `URLSessionClient` when `invalidate()` gets called, but I'm not sure if it'll address this crash since it's happening before the task is even added, which means `invalidate` has probably been called on a different thread.\r\n\r\nDefinitely sounds like a race condition is happening here - out of curiosity why are you fully replacing the client rather than using one of the delegate methods to handle authentication?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd Just tested, still crashing.\r\n\r\nI'm not 100% sure why we are replacing the client as I'm not the one who wrote that code, but as far as I understand it's because we are using `SplitNetworkTransport` and we are recreating the websocket so we need to also recreate the http client.","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"From here, I see a couple of workaround options: \r\n\r\n- Hanging on to the instance of `HTTPNetworkTransport` and using that when you have to recreate the web socket rather than creating a fully new transport\r\n- Taking a look at recent changes to the web socket transport, particularly around disconnecting and reconnecting, and seeing if any of those will prevent you from having to recreate. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I took the first option which works, so ok for me now but I guess you still have a race condition somewhere. Thank you very much for your help","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"Yeah for sure - I'm going to have to dig deeper into this but a lot of things are changing with the updated networking stack, so I'd like to get that out before digging back into this.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@benoitletondor We've just shipped something that will allow you to delay starting the websocket after initialization, which in theory should allow you to not have to replace the `SplitNetworkClient`. Do you mind pulling `0.36.0` and letting me know if that gets you to where you need to be? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey @designatednerd ,\r\n\r\nThank you for your help on that. Indeed, it would work for my use case as we can avoid starting the websocket until we have a proper authentication. As I said last time I already followed your advice of keeping the `HTTPNetworkTransport` instance so it's not really needed anymore on my side.\r\n\r\nThanks","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"@benoitletondor Do you mind if I close out this issue then? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Be my guest ;) ","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}}]}},{"__typename":"Issue","title":"ApolloCodegen.run does not throw error when validation of GraphQL query document fails","author":{"__typename":"User","login":"michaelxbarrett","id":"MDQ6VXNlcjMzODIyNjEz","name":null},"body":"From the tutorial:\r\n```\r\ndo {\r\n // Actually attempt to generate code.\r\n try ApolloCodegen.run(from: targetRootURL,\r\n with: cliFolderURL,\r\n options: codegenOptions)\r\n} catch {\r\n // This makes the error message in Xcode a lot more legible.\r\n exit(1)\r\n}\r\n```\r\n\r\nWhen there is an error in the query, the message `Validation of GraphQL query document failed` is logged and outputted to the console with a stacktrace, but no error is thrown in this case.\r\n\r\n\r\nStack trace:\r\n```\r\nValidation of GraphQL query document failed\r\n at Object.validateQueryDocument (Codegen/ApolloCLI/apollo/node_modules/apollo-language-server/lib/errors/validation.js:35:38)\r\n at Object.generate [as default] (Codegen/ApolloCLI/apollo/lib/generate.js:23:18)\r\n at write (Codegen/ApolloCLI/apollo/lib/commands/client/codegen.js:84:54)\r\n at Task.task (Codegen/ApolloCLI/apollo/lib/commands/client/codegen.js:104:46)\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"To clarify: Do you mean that the `exit(1)` is not called because no error is thrown from `run` itself, or that `exit(1)` does not constitute throwing an error? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Also, what version of the SDK are you using? I think there was an issue a couple versions back with our JS CLI where it wouldn't throw errors properly on failure, which should be resolved now.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@michaelxbarrett Were you able to address this by updating? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since I haven't heard back in 3 weeks, I'm going to close this out. @michaelxbarrett Please reopen if you're still experiencing problems. Anyone else with similar problems, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Query watcher not being called when cache is updated on an element of a collection that is added after calling watch","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"},"body":"Hi everyone,\r\n\r\nI've been trying a lot of things on that one and wasn't able to find a way to fix my problem. So in my app I'm having a list of conversations, so I'm creating a `watch` on a query that returns the list of conversations, this is something like that:\r\n\r\n```\r\nuser {\r\n uuid\r\n firstName\r\n lastName\r\n conversations {\r\n uuid\r\n unreadMessagesCount\r\n }\r\n}\r\n```\r\n\r\n> In the app we use the `uuid` key to handle cache, so we make sure to always pass `uuid` in our queries to automatically handle cache update.\r\n\r\nSo the role of the watcher I'm talking about is both to update existing conversations and also be able to catch when a new conversation is created (it can happen and not be initiated by the user, we then trigger an event from the backend that is listen from a subscription in the app). When this event happens it returns something like that\r\n\r\n```\r\nevent {\r\n newConversation {\r\n conversation {\r\n uuid\r\n unreadMessagesCount\r\n // This is the part that adds the new conversation to the existing ones of the users in the cache\r\n user {\r\n uuid\r\n conversations {\r\n uuid\r\n unreadMessagesCount\r\n }\r\n } \r\n }\r\n }\r\n}\r\n```\r\n\r\nIt works great, meaning that when this event happens, the watcher is being called with the newly created conversation, but the issue is that any new cache update for that specific conversation doesn't trigger the watcher again.\r\n\r\nAfter investigating a bit, I realised that the cache is being updated because if I'm adding 3 new messages into the new conversation (setting the `unreadMessagesCount` to 3), the watcher doesn't get called but then if I add 1 new message into an old one, the watcher is being called with both the new message on the old conversation and the 3 new on the new one. \r\n\r\nSo it really seems like `watch` is not being called again for changes on an item that wasn't in a collection when the `watch` was initially made. I've also take a look at https://github.com/apollographql/apollo-ios/issues/281 and making a `fetch` on the same query again after the event doesn't fix the issue.\r\n\r\nLet me know if I'm not clear on something as the whole thing is a bit complicated to explain.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! Can you take a look at v0.32.0 - I fixed something in query watchers in terms of updating dependent keys that I *think* should help with this. If it doesn't, let me know. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hey @designatednerd \r\n\r\nSure, if #1377 is resolved too I will be able to test that tomorrow. If that's not the case I guess I won't be able","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"Hey @designatednerd \r\n\r\nI tested and I can confirm 0.32.0 fixes the issue, thank you very much for your help.","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"Reopening this one as the bug seems to be back with 0.34.0 :/ Let me know if you need help on my side","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"@designatednerd I haven't tested 0.33.0 so I'm not sure when the regression happened","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"That's odd, because the test added is passing - I actually spent quite a bit of time making it pass. 🙃 Do you mind opening a new issue with a link to this one since it's in a different version? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Sure","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}}]}},{"__typename":"Issue","title":"Availability of framework with Xcode 12 and iOS version 8","author":{"__typename":"User","login":"novinfard","id":"MDQ6VXNlcjYxMTYwNw==","name":"Soheil Novinfard"},"body":"Is it possible to use the framework with Xcode 12 and iOS version 8? Currently it asks me to upgrade to iOS version 9 with Xcode 12","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"iOS 9 is our minimum supported version regardless of Xcode version. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@novinfard Any further questions or do you mind if I close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Crash while checking graphQLResult with 0.32 and 0.32.1","author":{"__typename":"User","login":"jsm174","id":"MDQ6VXNlcjExOTcxMzc=","name":"Jason Millard"},"body":"Hello. Yesterday I upgraded to 0.32 and immediately started getting crashes anytime one of our services is checking a `graphQLResult`:\r\n\r\n```\r\ncase let .success(graphQLResult):\r\n```\r\n\r\nI downgraded to 0.31 and it started working again. I saw that 0.32.1 was released and figured I'd give it a try, but I'm seeing the same behavior.\r\n\r\nI know this isn't much to go on, but:\r\n\r\n![Screen Shot 2020-09-11 at 9 36 16 AM](https://user-images.githubusercontent.com/1197137/92932578-14476280-f413-11ea-9b8a-02df220cfcfd.png)\r\n\r\n(FWIW, that first preflight is just refreshing oauth tokens if necessary)\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"So, I apologize but I think it is working after all. \r\n\r\nI think maybe after I did a pod update, it never actually rebuilt apollo.\r\n\r\nI will close this. ","author":{"__typename":"User","login":"jsm174","id":"MDQ6VXNlcjExOTcxMzc=","name":"Jason Millard"}},{"__typename":"IssueComment","body":"No worries, that can definitely happen. Thanks for the update!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"codegen produces Swift code that doesn't compile","author":{"__typename":"User","login":"rlimberger","id":"MDQ6VXNlcjQ4NDEyNDI=","name":"Rene Limberger"},"body":"My scheme defines a GQL query named ```shipmentETAs``` and a type ```shipmentETA```. Codegen generates Swift code which incorrectly changes parts of the query and type name to lowercase. As a result, the Swift code generated by codegen doesn't compile.\r\n\r\nSchema:\r\n```\r\n {\r\n \"name\": \"shipmentETAs\",\r\n \"description\": \"\",\r\n \"args\": [\r\n {\r\n \"name\": \"params\",\r\n \"description\": \"\",\r\n \"type\": {\r\n \"kind\": \"NON_NULL\",\r\n \"name\": null,\r\n \"ofType\": {\r\n \"kind\": \"INPUT_OBJECT\",\r\n \"name\": \"QueryShipmentETAParams\",\r\n \"ofType\": null\r\n }\r\n },\r\n \"defaultValue\": null\r\n }\r\n ],\r\n \"type\": {\r\n \"kind\": \"NON_NULL\",\r\n \"name\": null,\r\n \"ofType\": {\r\n \"kind\": \"LIST\",\r\n \"name\": null,\r\n \"ofType\": {\r\n \"kind\": \"OBJECT\",\r\n \"name\": \"ShipmentETA\",\r\n \"ofType\": null\r\n }\r\n }\r\n },\r\n \"isDeprecated\": false,\r\n \"deprecationReason\": null\r\n }\r\n```\r\n\r\nResulting Swift code:\r\n```\r\n public var shipmentEtAs: [ShipmentEta?] {\r\n get {\r\n return (resultMap[\"shipmentETAs\"] as! [ResultMap?]).map { (value: ResultMap?) -> ShipmentEtA? in value.flatMap { (value: ResultMap) -> ShipmentEtA in ShipmentEtA(unsafeResultMap: value) } }\r\n }\r\n set {\r\n resultMap.updateValue(newValue.map { (value: ShipmentEtA?) -> ResultMap? in value.flatMap { (value: ShipmentEtA) -> ResultMap in value.resultMap } }, forKey: \"shipmentETAs\")\r\n }\r\n }\r\n\r\npublic struct ShipmentEta: GraphQLSelectionSet {\r\n...\r\n```\r\n\r\nCompiler error:\r\n`Cannot find type 'ShipmentEtA' in scope`\r\n\r\nSwift 5.3\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Urgh, this is one of the things I'm working on getting rid of with Swift Codegen - this is all handled under the hood in the Typescript codegen in a way that's really, really opaque. Unfortunately for now the only real way to work around it is to alias the name of the field to not have multiple uppercase characters in a row. \r\n\r\nI don't know your schema but here's a general stab at what I think an updated query would look like: \r\n\r\n```query\r\nquery ShipmentArrives($id: ID!) {\r\n shipment(id: $id) {\r\n id\r\n shipmentETA: shipmentEstimate\r\n }\r\n}\r\n```\r\n\r\nLet me know if that works!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks so much @designatednerd ! The alias worked! \r\n```\r\nquery ShipmentEstimates($siteId: ID!) {\r\n shipmentEstimates: shipmentETAs(params: {siteId: $siteId}) {\r\n ...\r\n }\r\n}\r\n```","author":{"__typename":"User","login":"rlimberger","id":"MDQ6VXNlcjQ4NDEyNDI=","name":"Rene Limberger"}},{"__typename":"IssueComment","body":"Woot! Mind if we close this out - I'm already tracking the casing stuff in other tickets. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Fix Apple Silicon on Xcode 12 GM","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"},"body":"Related to #1280. In testing for the Xcode 12 GM everything's working swimmingly via my Intel mac but the DTK is throwing fits that I can't seem to solve at the moment, mostly related to `unable to load standard library` issues. ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"OK well it turns out I am both less dumb than I originally thought for not being able to get this to work, _and_ dumber than I thought for not realizing I shouldn't download the GM on the DTK. \r\n\r\nThe Apple Silicon stuff was not included with the GM since that ships to the public, and AS stuff should still be using the beta track (still Xcode 12b6 for now, probably a 12.1 beta sometime soon). \r\n\r\nClosing this out since everything still works on the most recent version of Xcode to support Apple Silicon, 12.0b6. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Apollo 0.33.0 + Xcode 11.7. Use of unknown directive '#filePath'.","author":{"__typename":"User","login":"Hazeaze","id":"MDQ6VXNlcjgzNTE4NzQ=","name":null},"body":"Hi.\r\nI use SPM for the third-party libraries, updated Apollo from 0.32.1 to 0.33.0, and on the app build, I faced with the problem in the `FileFinder.swift`, where received an error `Use of unknown directive '#filePath'`.\r\n\r\n![image](https://user-images.githubusercontent.com/8351874/93308812-91fcdb00-f824-11ea-9050-275be2b39282.png)\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I got the same error","author":{"__typename":"User","login":"Parilar","id":"MDQ6VXNlcjgxNTk2NDY=","name":"Lars Hallek"}},{"__typename":"IssueComment","body":"`#filePath` is new in Swift 5.3, which ships with Xcode 12. You will need to use Xcode 12 for versions `0.33.0` and higher.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm going to close this out since this is intended behavior. Enjoy Xcode 12!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Exclude Apollo Playground from the main project file to make Carthage faster","author":{"__typename":"User","login":"manicmaniac","id":"MDQ6VXNlcjE2NzIzOTM=","name":"Ryosuke Ito"},"body":"Apollo Playground, which introduced in Apollo 0.33.0 as [a scheme in Apollo.xcoderpoj](https://github.com/apollographql/apollo-ios/blob/0.33.0/Apollo.xcodeproj/xcshareddata/xcschemes/Apollo%20Playground.xcscheme), makes Carthage build slower, and to make matters worse, building Apollo Playground fails in Xcode older than 12 (https://github.com/apollographql/apollo-ios/issues/1391).\r\n\r\nI guess most Apollo users don't want to build Apollo Playground at the time they install dependencies.\r\nHowever, Carthage doesn't provide a convenient way to exclude a specific scheme as discussed in https://github.com/Carthage/Carthage/issues/2529.\r\n\r\nSo to solve this problem, could you exclude Apollo Playground scheme from Apollo.xcodeproj and move it to another xcodeproj or another repo?\r\n\r\n```sh\r\n$ carthage bootstrap --platform iOS --no-use-binaries --cache-builds\r\n*** Checking out ApolloDeveloperKit at \"ce9fd3e1c75c074ae77632a8fe21be635219401b\"\r\n*** Checking out apollo-ios at \"0.33.0\"\r\n*** No cache found for apollo-ios, building with all downstream dependencies\r\n*** xcodebuild output can be found in /var/folders/tm/wy8sj46s6yq4rlfgsxyvd1l80000gn/T/carthage-xcodebuild.Plidos.log\r\n*** Building scheme \"Apollo\" in Apollo.xcodeproj\r\n*** Building scheme \"ApolloCore\" in Apollo.xcodeproj\r\n*** Building scheme \"Apollo Playground\" in Apollo.xcodeproj\r\nld Failed\r\n Task failed with exit code 65:\r\n /usr/bin/xcrun xcodebuild -project /Users/manicmaniac/Projects/manicmaniac/ApolloDeveloperKit/InstallTests/Carthage/Checkouts/apollo-ios/Apollo.xcodeproj -scheme Apollo\\ Playground -configuration Release -derivedDataPath /Users/manicmaniac/Library/Caches/org.carthage.CarthageKit/DerivedData/11.5_11E608c/apollo-ios/0.33.0 -sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/tm/wy8sj46s6yq4rlfgsxyvd1l80000gn/T/apollo-ios SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in /Users/manicmaniac/Projects/manicmaniac/ApolloDeveloperKit/InstallTests/Carthage/Checkouts/apollo-ios)\r\n\r\nThis usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/tm/wy8sj46s6yq4rlfgsxyvd1l80000gn/T/carthage-xcodebuild.Plidos.log\r\nmake: *** [carthage] Error 1\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Have you tried using the [`carthage-build-workaround` script outlined in the release notes?](https://github.com/apollographql/apollo-ios/releases/tag/0.33.0) There's some other nonsense going on with Carthage that I think may be causing the build failures rather than this scheme. \r\n\r\nAs for time reduction, the problem is that if that scheme isn't shared, the playgrounds won't build because it needs different sub-libraries than any of the other schemes. \r\n\r\nI can't for the life of me figure out why Carthage is so against excluding schemes. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> Have you tried using the carthage-build-workaround script outlined in the release notes?\r\n\r\nAh, my bad 😓 \r\nWith the workaround script and Xcode 12, I confirmed it works.\r\n\r\n```sh\r\n$ ./carthage-build-workaround.sh\r\n/tmp/static.xcconfig.hvN4SB\r\n*** Fetching apollo-ios\r\n*** Checking out apollo-ios at \"0.33.0\"\r\n*** xcodebuild output can be found in /var/folders/tm/wy8sj46s6yq4rlfgsxyvd1l80000gn/T/carthage-xcodebuild.6GUdYX.log\r\n*** Building scheme \"Apollo\" in Apollo.xcodeproj\r\n*** Building scheme \"ApolloCodegenLib\" in Apollo.xcodeproj\r\n*** Building scheme \"Apollo Playground\" in Apollo.xcodeproj\r\n*** Building scheme \"ApolloSQLite\" in Apollo.xcodeproj\r\n*** Building scheme \"ApolloCore\" in Apollo.xcodeproj\r\n*** Building scheme \"ApolloWebSocket\" in Apollo.xcodeproj\r\n```","author":{"__typename":"User","login":"manicmaniac","id":"MDQ6VXNlcjE2NzIzOTM=","name":"Ryosuke Ito"}},{"__typename":"IssueComment","body":"Cool - do you mind if we close this out with the answer as \"No\" for removing the `Apollo Playground` scheme? I understand it's inconvenient, but it's not inconvenient that often. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes, let me close this issue and thank you very much for your support 👍 ","author":{"__typename":"User","login":"manicmaniac","id":"MDQ6VXNlcjE2NzIzOTM=","name":"Ryosuke Ito"}}]}},{"__typename":"Issue","title":"Looking for recommendation for Pagination + Watching flow","author":{"__typename":"User","login":"bharath2020","id":"MDQ6VXNlcjkwMzUzNg==","name":null},"body":"_(Have this question [posted ](https://spectrum.chat/apollo/apollo-ios/looking-for-recommendation-to-perform-pagination-watch-in-ios-and-android-clients~a15afb8b-21fb-49a6-a80c-dd2ef097c8ad) in Spectrum chat as well, Adding here for better reach. Apologize for noise.)_\r\n\r\n# Problem\r\n\r\nWe have done some experiments in adopting pagination and encountered a few issues. I am looking for a recommendation on how to extract paginated results that do achieve two of my main goals. For the context, we have a mobile application that has screens that show paginated content that allows infinite vertical scrolling.\r\n\r\n1. Perform pagination in a responsible manner without any lag on the UI\r\n2. Ability to watch any changes to the items retrieved across all pages\r\n\r\nFor example, assume the following schema\r\n\r\n```\r\ntype PageResult {\r\n cursor: String\r\n hasMore: Bool\r\n items: [String]\r\n}\r\nquery {\r\n getItems(cursor: String): PageResult\r\n}\r\n```\r\n\r\nHere are the approaches we tried:\r\n\r\n## Approach 1: Follow the suggestion as per the [Apollo iOS tutorial blog](https://www.apollographql.com/docs/ios/tutorial/tutorial-pagination/)\r\n\r\n1. Load the first page with no cursor with cache policy that writes data back to the cache\r\n2. Load the second page with the cursor and follow the same for the next pages with cache policy that writes data back to the cache\r\n\r\n### Issues with Approach 1\r\n\r\n#### 1. Zombie records:\r\n\r\nFollowing the query path approach to generate cache key, the First page will be written under cache key \"QUERY\\_ROOT.getPage-cursor\", while subsequent pages will hold the items under the cache key \"QUERY\\_ROOT.getItems-cursor-page2cursor\", \"QUERY\\_ROOT.getItems-cursor-page3cursor\", and so on..\r\n\r\nIn our case, The page cursors are generated run time and only valid until the first page is refreshed again to get a new cursor. Following this approach, We notice that all the pages that were previously fetched will never be deleted after re-fetching the first page and hence get accumulated as the user fetches more pages and re-fetches leading to larger cache size over time. Not to mention the more number of records, the higher the read time.\r\n\r\n#### 2. Cannot watch updates to items from the second page onwards:\r\n\r\nWe want to set up a GraphQLQueryWatcher on the paginated query, such that any changes to the items, including items from all the pages retrieved so far. However, Looking at the implementation of the GraphQLQueryWatcher, it appears that with this approach, Watcher will notify only for the items returned from the first page since dependent keys for the watcher includes only keys from the first page.\r\n\r\n## Approach 2: Manually merge data from subsequent pages into the first page\r\n\r\nIn order to solve the Approach #1 Issue #2, We took inspiration from [Apollo react Pagination](https://www.apollographql.com/docs/react/data/pagination/#cursor-based) which does the following:\r\n\r\n1. Load the first page with no cursor with cache policy that writes data back to the cache\r\n2. Load the second page, and so on, with `fetchIgnoringCacheCompletely` cache policy and manually write the data into the First-page query.\r\n\r\n### Issues with Approach 2\r\n\r\n#### 1. Writes are slow\r\n\r\nAs we can notice in Step #2, we merge the previous page with data pulled from the next page and re-write the entire data back. As we fetch more pages, the write latency increases.\r\n\r\n#### 2 Latency of reading the first page exponentially increases\r\n\r\nSince we merge data from all pages into the first page, reading the first page exponentially increases based on the number of items present in the cache. This is more evident with queries that have an increasing number of attributes that are non-scalar data types in the query as the batch loader does round trip to the database for each attribute. With our sample of data, the read time for a query with medium complex schema has clocked 10 seconds to read 150 items on an iPhone XS device.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hey @bharath2020 - just a heads up that I'm bogged down at the moment but this is a *very* good question that I need to work on a better answer to (and that we should have a *way* better answer to overall for mobile), and I think messing around with the tutorial is probably a good place to start with it. And you are very correct that 10 seconds to read 150 items is 🤮. \r\n\r\nIn terms of what you can try while I'm digging out from under what I'm dealing with now, there's the `cacheKeyForObject` closure that you can use to generate a custom cache key. For most items you should be able to cache by ID, and that should avoid having to rewrite all the data if it's not necessary. \r\n\r\nI'm going to leave this open for the community to respond more - I know this has been done well, but my knowledge of details isn't there because I'm focused on other parts of the SDK at the moment. \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks, @designatednerd for the response.\r\n\r\n> For most items you should be able to cache by ID, and that should avoid having to rewrite all the data if it's not necessary.\r\n\r\nInteresting. In approach #2, Given that I am appending items from `morePage` back to `firstPage` and issuing a re-write of data for the first-page query, I am curious how would the store understand to not overwrite data referencing items in the first page? In other words, I understand `cacheKeyForObject` would reduce the number of records written to the database, but even with normalized cache, there would be unnecessary overwrites (in this case the items in the first page) that would add to the write latency. Please correct me If I am wrong.\r\n\r\nP.S. I have cacheKeyForObject enabled in my sample, and timings were taken after. The only part where I would not be able to generate a cache key is for the `PageResult` type, as `cacheKeyForObject` does not expose the variables (or field arguments) used to generate the type, in this case, it is the `cursor` provided for `getItems(cursor:)` query.","author":{"__typename":"User","login":"bharath2020","id":"MDQ6VXNlcjkwMzUzNg==","name":null}},{"__typename":"IssueComment","body":"Again, my knowledge of the cache is not as deep as it should be, but my understanding is you'd be rewriting the references with IDs rather than the entire object and its entire tree of changes. This almost certainly has some unnecessary work, but it would likely constitute a lot *less* unnecessary work than without the `cacheKeyForObject`. \r\n\r\nAnd again, this is not working as well as we want it to. We have some changes to the cache slated for [phases 2 and 3 of the ongoing Swift codegen rewrite](https://github.com/apollographql/apollo-ios/issues/939), and making things less annoying for pagination is one of the major things I want to do within that work. \r\n\r\nWish I had a better answer for you. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Got it. I played a little bit with batch reading objects from the database. I will give it a try to see if we can do the batch updates within a transaction. Right now, each roundtrip to the SQLite database is in its own transaction and I am guessing that is causing the reads to slow down. I have in the past read a huge number of items from SQLite and latency was fine.\r\n\r\nI will see if it makes any difference in the same and post it back.","author":{"__typename":"User","login":"bharath2020","id":"MDQ6VXNlcjkwMzUzNg==","name":null}},{"__typename":"IssueComment","body":"OK - do you mind if we close out this issue? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Ok","author":{"__typename":"User","login":"bharath2020","id":"MDQ6VXNlcjkwMzUzNg==","name":null}}]}},{"__typename":"Issue","title":"It expected a JSON schema introspection result, but got an HTML response instead.","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null},"body":"Hello,\r\n\r\nI am trying to run a script first time but i am receiving below error. \r\n\r\n**Unexpected token < in JSON at position 0\r\n Error: Apollo tried to introspect a running GraphQL service at \r\n http://10.10.10.10/graphql\r\n It expected a JSON schema introspection result, but got an HTML response \r\n instead.\r\n You may need to add headers to your request or adjust your endpoint url.**\r\n\r\nHere is my Script\r\n\r\n # Type a script or drag a script file from your workspace to insert its path.\r\n # Go to the build root and search up the chain to find the Derived Data Path where the source packages are checked out.\r\n DERIVED_DATA_CANDIDATE=\"${BUILD_ROOT}\"\r\n\r\n while ! [ -d \"${DERIVED_DATA_CANDIDATE}/SourcePackages\" ]; do\r\n if [ \"${DERIVED_DATA_CANDIDATE}\" = / ]; then\r\n echo >&2 \"error: Unable to locate SourcePackages directory from BUILD_ROOT: '${BUILD_ROOT}'\"\r\n exit 1\r\n fi\r\n\r\n DERIVED_DATA_CANDIDATE=\"$(dirname \"${DERIVED_DATA_CANDIDATE}\")\"\r\n done\r\n\r\n # Grab a reference to the directory where scripts are checked out\r\n SCRIPT_PATH=\"${DERIVED_DATA_CANDIDATE}/SourcePackages/checkouts/apollo-ios/scripts\"\r\n\r\n if [ -z \"${SCRIPT_PATH}\" ]; then\r\n echo >&2 \"error: Couldn't find the CLI script in your checked out SPM packages; make sure to add the framework to your project.\"\r\n exit 1\r\n fi\r\n\r\n #cd \"${SRCROOT}/${TARGET_NAME}\"\r\n #\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" API.swift\r\n\r\n SCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\n cd \"${SRCROOT}/${TARGET_NAME}\"\r\n \"${SCRIPT_PATH}\"/run-bundled-codegen.sh schema:download --endpoint=http:///graphql schema.json\r\n\r\nXCode Version : 11.3.1\r\nApollo : 0.24.1\r\nInstalled Apollo pod.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi, it looks like the endpoint hasn't had the `` placeholder replaced yet - the `http:///graphql` in your error message makes it look like that's just being stripped out entirely by the CLI. \r\n\r\nUnrelated to your immediate issue, I would strongly recommend running `schema:download` before running `codegen:generate` since codegen uses the result of downloading the schema. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"As of now i am trying to download schema.json from CLI with the following command.\r\n\r\n`apollo schema:download --endpoint=http:///graphql schema.json\r\n`\r\n\r\nBut still i am getting the same error. I didnt get placeholder (in your comment, can you please clarify)\r\n\r\nI have updated my question where i written down a dummy server url","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}},{"__typename":"IssueComment","body":"Hey I am able to download schema.json file from other public graphql url.\r\n\r\nBut now i am facing another error. I am using POD for apollo now.\r\n\r\nRun Script : \r\n\r\n`SCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\ncd \"${SRCROOT}/${TARGET_NAME}\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" API.swift\r\n`\r\n\r\nError :\r\n\r\nLoading Apollo Project [started]\r\nLoading Apollo Project [completed]\r\nGenerating query files [started]\r\nGenerating query files with 'swift' target [title changed]\r\nGenerating query files with 'swift' target [failed]\r\n→ Apollo does not support anonymous operations\r\n GraphQLError: Apollo does not support anonymous operations\r\nCommand PhaseScriptExecution failed with a nonzero exit code\r\n\r\n\r\nIf its not legal then can i raise new issue with this error and close this one","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}},{"__typename":"IssueComment","body":"You need to make sure you give your query a name - otherwise the codegen won't know what name to give the class containing the query. \r\n\r\nSo it has to look like this: \r\n\r\n```graphql\r\nFetchUser($id: ID!) {\r\n user(id: $id) {\r\n name\r\n [etc]\r\n }\r\n}\r\n```\r\n\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks.. this works.","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}},{"__typename":"IssueComment","body":"Hello, \r\n\r\nI am receiving this error right now.\r\n\r\nERROR : Received error response: Field \"country\" argument \"code\" of type \"ID!\" is required, but it was not provided.\r\n\r\nGraphQL : https://countries.trevorblades.com/graphql\r\n\r\nQuery : \r\n\r\n query AllCountry {\r\n country {\r\n name\r\n }\r\n }\r\n\r\niOS Swift Code : \r\n\r\n NetworkClient.sharedInstance().apollo.fetch(query: AllCountryQuery()) { result in\r\n \r\n switch result {\r\n case .success(let GraphQLResult) :\r\n print(GraphQLResult.data?.country as Any)\r\n \r\n \r\n \r\n case .failure(let error) :\r\n print(\"ERROR :\", error.localizedDescription)\r\n }\r\n }\r\n","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}},{"__typename":"IssueComment","body":"I think the error is telling you exactly what the problem is: `Field \"country\" argument \"code\" of type \"ID!\" is required, but it was not provided.` You need to make sure you're passing in a country code for this query.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Fixed. Thanks","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}}]}},{"__typename":"Issue","title":"Swift Package Manager + Xcode 12.0: Target 'arm64-apple-ios-simulator' missing","author":{"__typename":"User","login":"jzeisweiss","id":"MDQ6VXNlcjQyNjEyNTg=","name":"Jimmy Zeisweiss"},"body":"Hello,\r\n\r\nI can no longer use \"Preview\" for SwiftUI or build to a simulator due to the following error.:\r\n\r\n```\r\nerror: could not find module 'Apollo' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64\r\nimport Apollo\r\n```\r\n**Xcode Version**: 12.0 (12A7209)\r\n**Apollo Version**: 33.0\r\n\r\n_Note: I am having no problem building to a device._","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"@jzeisweiss Hi, what package manager are you using? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd - Hey Ellen, I am using Swift Package Manager.","author":{"__typename":"User","login":"jzeisweiss","id":"MDQ6VXNlcjQyNjEyNTg=","name":"Jimmy Zeisweiss"}},{"__typename":"IssueComment","body":"Are you using it on the Developer Transition Kit (I ask since it's looking for the `arm64-apple-ios-simulator` slice)? They took all the Apple Silicon stuff out of 12.0 and put it back in the 12.2 beta, so you'd need to use that if you are. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I am not using the Silicon ARM-Based prototype Mac from the Developer Transition Kit. I am using a 2018 Mac Mini and a 2018 MacBook Pro. However, I did find a workaround. I went in and changed the project settings to:\r\n\"Build Settings\" > \"Build Active Architecture Only\" > Set to \"YES\". This fixed my issue and I can now see the SwiftUI previews as well as build to simulators. Thank you for the speedy responses!\r\n\r\n**Source**: https://stackoverflow.com/questions/56957632/could-not-find-module-for-target-x86-64-apple-ios-simulator","author":{"__typename":"User","login":"jzeisweiss","id":"MDQ6VXNlcjQyNjEyNTg=","name":"Jimmy Zeisweiss"}},{"__typename":"IssueComment","body":"Ah yeah, that'll do it for sure - thank you for sharing your fix! Do you mind if we close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Networking Beta: Convenience constructors for HTTPRequest and JSONRequest","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"},"body":"In my use case i have to append to the `URLRequest.query` before a request is actually sent and that was fairly straight forward with the old network stack using `HTTPNetworkTransportPreflightDelegate.networkTransport(_:willSend:)` \r\n\r\nWith the new network stack things have gotten a bit more complex but i was able to come up with a solution involving a custom `ApolloInterceptor` that turns a given `JSONRequest` into a custom subclass which overrides `toURLRequest()`.\r\n\r\nSo to make implementation of custom HTTPRequests more easy i suggest you to add some convenience constructors for `HTTPRequest` and `JSONRequest` that take a single argument of their own type. This would let me get rid of this bunch of constructor arguments like this:\r\n\r\n```\r\n let customRequest = CustomJSONRequest(jsonRequest)\r\n```\r\n\r\ninstead of this:\r\n``` \r\n let customRequest = CustomJSONRequest(\r\n operation: jsonRequest.operation,\r\n graphQLEndpoint: jsonRequest.graphQLEndpoint,\r\n contextIdentifier: jsonRequest.contextIdentifier,\r\n clientName: jsonRequest.additionalHeaders[\"apollographql-client-name\"] ?? \"\",\r\n clientVersion: jsonRequest.additionalHeaders[\"apollographql-client-version\"] ?? \"\",\r\n additionalHeaders: jsonRequest.additionalHeaders,\r\n cachePolicy: jsonRequest.cachePolicy,\r\n autoPersistQueries: jsonRequest.autoPersistQueries,\r\n useGETForQueries: jsonRequest.useGETForQueries,\r\n useGETForPersistedQueryRetry: jsonRequest.useGETForPersistedQueryRetry,\r\n requestCreator: jsonRequest.requestCreator\r\n )\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"The override is the correct way of doing this - I'm not quite clear why the `super init`, which has a bunch of default parameters, isn't the way you're doing this, though. Can you go into a bit more detail on that? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"When looking for a way to get my `CustomHTTPRequest` with its overriden `toURLRequest()` into place i learned about the concept of `ApolloInterceptor` in the new network stack architecture.\r\n\r\nTherefore i have implemented a custom interceptor to replace the original `HTTPRequest` instance with one of `CustomHTTPRequest` as a substitution. Basically what i'm trying to do here is to create a copy of the request _with whatever particular values its properties have_ but extend its original functionality.\r\n\r\nIf there is something i have misunderstood or a better approach to achive this i'm glad to get enlighted.","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"}},{"__typename":"IssueComment","body":"OK! I think I see what the problem is here: While the `RequestChain` can take an arbitrary subclass of `HTTPRequest`, there's no way to say \"You should use this specific subclass\" from the level of the `RequestChainNetworkTransport`, so as of right now you're having to recreate the request at the interceptor level. \r\n\r\nIt sounds like the issue is that there needs to be a way to specify the request type that's customizable at that level, so that you can actually use the custom type you've created. \r\n\r\nDoes that sound accurate? I'm gonna poke at some ideas on this. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Indeed, if subclassing `HTTPRequest` is the intended way to go, a more simple way to place that type into the processing is greatly appreciated.","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"}},{"__typename":"IssueComment","body":"@knox Please see #1405 . You may have opened a trapdoor to a bigger change but it's a good one 😄 ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Wow i didn't mean to ask for moving mountains but opening `RequestChainNetworkTransport` and `constructRequest(for:cachePolicy:contextIdentifier:)` seems to perfectly fit my needs.","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"}},{"__typename":"IssueComment","body":"Haha, this worked as designed: You pointed out that I hadn't provided an access point to something, so I added it. Then by adding it I realized something else that was annoying me could change. 😇","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"With 0.34.0-rc.2 i was able to implement a clean and simple solution to my use case.","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"}}]}},{"__typename":"Issue","title":"Download Schema.json but server has CSRF Token protection","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null},"body":"Hello,\r\n\r\nI want to download a schema.json file but our server is protected with CSRF Token so which command i need to use to download a schema file and how can i send --header with CSRF token (From where i can get CSRF token means from our server guy or is apollo-client give/generate for downloading schema & passing in --header) ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! Please check out the instructions for [doing this in Bash](https://www.apollographql.com/docs/ios/downloading-schema/) and/or [doing this with the Swift Scripting tools](https://www.apollographql.com/docs/ios/swift-scripting/#downloading-a-schema). Do those docs answer your questions? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi! Since this is pretty clearly documented and I haven't heard anything back in a week, I'm going to close this out - @tapannathvani if you're still having problems please reopen. Anyone else having similar problems, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"is apollo provide internet check class?","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null},"body":"I am trying to check internet connection in my project.. and looking in apollo-ios library also like if you guys providing any reachability type class so without adding any other library or framework i can use your class to check connection\r\n\r\nIf yes then please provide documentation link and if not then please let me know how can i achieve this? and can i check internet connectivity in HTTPNetworkTransportPreflightDelegate (will send) method or in should send method? ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"We do not provide an internet check class, nor do we have plans to do so. \r\n\r\nIf you're using iOS 12 and above, the recommend way of doing things is [using `NWPathMonitor`](https://medium.com/@rwbutler/nwpathmonitor-the-new-reachability-de101a5a8835). If you're storing the most recent result from `NWPathMonitor` the preflight delegate would be a reasonable place to check it. \r\n\r\nPlease note that the Preflight delegate will be going away with `0.34.0` - you can check out the updated networking beta in #1386, and the PR has links to updated documentation. It would probably be fairly easy to add an interceptor that does that network check in the new networking stack. \r\n\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Can we know when can we have 0.34.0?","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}},{"__typename":"IssueComment","body":"Release candidate 2 is available now, gonna let it bake over the weekend and put it out monday night (US-Central time) if I don't hear any major showstoppers.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks for the quick response.","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}}]}},{"__typename":"Issue","title":"No such file or directory: run-bundled-codegen.sh","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null},"body":"I imported via cocoa pods the Apollo, actually it installed 0.30. \r\n\r\nI added exactly the same script as here:\r\nhttps://www.apollographql.com/docs/ios/installation/#troubleshooting \r\nschema.json is under project folder, under the target folder name.\r\nBut I keep receiving:\r\n![image](https://user-images.githubusercontent.com/6308120/94440933-75588f80-01a2-11eb-8095-c1d6862880b1.png)\r\nActually there is no data on SourcePackages folder about Apollo scripts.\r\n\r\nCould you help me?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi, it looks like you're using the Swift Package Manager run script rather than the CocoaPods run script [outlined in this step of the setup instructions](https://www.apollographql.com/docs/ios/installation/#adding-a-code-generation-build-step), because the CocoaPods script should be looking in `Pods/apollo-ios/scripts` rather than doing the weird dance of diving through derived data that the SPM script has to do.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"OMG!!! True. Wee can close the ticket!!!! ","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null}}]}},{"__typename":"Issue","title":"How to inject HTTP headers before fetching a query","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null},"body":"Do you know a mechanism to do that?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"This is covered in the [Advanced Client Creation](https://www.apollographql.com/docs/ios/initialization/) section of our docs. \r\n\r\nFair warning that this will be changing significantly very soon with the release of what's now in RC for #1386 (which I'm hoping to release tonight). The PR has a link to the updated docs for advanced client creation as well. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Error not parsed","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null},"body":"Hi,\r\n\r\nI have a GraphQL which is returning the following:\r\n![image](https://user-images.githubusercontent.com/6308120/94543867-da67c000-024a-11eb-803f-e76731c18064.png)\r\nBut the generated code is not parsing the error, but just giving data:\r\n![image](https://user-images.githubusercontent.com/6308120/94543972-fa977f00-024a-11eb-8689-7fa93a3d05f9.png)\r\nCould you help to identify how to get the errors?\r\n\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Weird - that does look like properly formatted JSON for the error - can you confirm what version of the SDK, Xcode, and Swift you're using here? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"SDK 0.33.0\r\nXcode 11.5 \r\nSwift 5","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null}},{"__typename":"IssueComment","body":"I've got no idea why that's not parsing the error - I put a test together and this is passing (different `\"data\"` key name since I'm using a local type for this test): \r\n\r\n```swift\r\nfunc testGH1415() throws {\r\n let json = \"\"\"\r\n{\r\n \"data\": {\r\n \"hero\": null\r\n },\r\n \"errors\": [\r\n {\r\n \"message\": \"Exception while fetching data (lastViewedProducts) : Customer not logged in\",\r\n \"locations\": [\r\n {\r\n \"line\": 2,\r\n \"column\": 3\r\n }\r\n ],\r\n \"path\": [\r\n \"lastViewedProducts\"\r\n ],\r\n \"extensions\": {}\r\n }\r\n ]\r\n}\r\n\"\"\"\r\n let data = try XCTUnwrap(json.data(using: .utf8),\r\n \"Couldn't create json data\")\r\n \r\n let deserialized = try JSONSerializationFormat.deserialize(data: data)\r\n let jsonObject = try XCTUnwrap(deserialized as? JSONObject)\r\n let response = GraphQLResponse(operation: HeroNameQuery(), body: jsonObject)\r\n \r\n let result = try response.parseResultFast()\r\n XCTAssertNil(result.data)\r\n XCTAssertNotNil(result.errors)\r\n \r\n let error = try XCTUnwrap(result.errors?.first)\r\n XCTAssertEqual(error.message, \"Exception while fetching data (lastViewedProducts) : Customer not logged in\")\r\n XCTAssertEqual(error.locations, [\r\n GraphQLError.Location(line: 2, column: 3),\r\n ])\r\n XCTAssertNotNil(error.extensions)\r\n}\r\n```","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Overwrite whole cache after fetch.","author":{"__typename":"User","login":"pgawlowski","id":"MDQ6VXNlcjk4NDUwMjQ=","name":null},"body":"Hello again.\r\n\r\nMy application is trying to archive offline first mode.\r\nWe are using BigQuery to fetch all the data required for app to be usable and focus on offline cache mutations with custom made syc feature. \r\n\r\nThe problem is that after synchronization we are trying to refresh whole cache data. Some of our tasks can fail, most will be successful.\r\nTo avoid too much noise with cache handling, right after syc we are refetching BigQuery once again. \r\nAnd here is our problem. Mutations we performed in offline mode are still present, no matter the fact of success of failure during sync it is because backend is creating it's own unique ID's here and we are just generating UUID as a placeholder. The source of truth is server. So in case of BigQuery fetch I would like to totally teardown current cache and recreate it with BigQuery result.\r\n\r\nCalling clearCache before BigQuery seems to be a little bit risky. I mean there is a risk of loosing data if sth goes wrong with BigQuery.\r\n\r\nAny ideas how to handle?\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Oof, that's a tough one. This is part of why sync is so hard (and frankly why I have zero interest in handling it on our end). \r\n\r\nThe first thing that jumps to mind is making a second instance of whatever cache you're using, swapping in a store with that cache, and then putting the old one back if things fail. I won't say that won't be a giant pain, but off the top of my head that's at least something that will keep the old data in case your `BigQuery` fails. \r\n\r\nLike I said though, sync is really hard. I don't think there's going to be a simple, straightforward solution to this problem. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@pgawlowski Anything else I can help with here or do you mind if I close this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since I haven't heard back in a week, I'm going to close this out. @pgawlowski feel free to reopen if you have more questions - anyone else with similar problems, please open a separate issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Question about ApolloInterceptor","author":{"__typename":"User","login":"dchohfi","id":"MDQ6VXNlcjUwODYzNg==","name":"Diego Chohfi"},"body":"Hey, amazing rewrite of the http architecture, good naming and nice usage of open/close principles.\r\n\r\nJust one stuff, I'm not sure how many times the `interceptAsync` method gets called, as it receives both request and an option response, I think this will be called twice, I'm correct?\r\n\r\nIf this is correct, talking about an interceptor that adds authentication token to the request, might be better to check if we don't have the response yet? Should I only add the token if the response is nil?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Each interceptor is called once - they're called in sequence based on the order of the array passed in from the `InterceptorProvider`. So if you want to put a token in, you can probably just add the token adding interceptor to the beginning of that array. \r\n\r\nYou can see an example of this in the [updated tutorial here](https://www.apollographql.com/docs/ios/tutorial/tutorial-mutations/#add-authentication-handling).","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"So the interceptor isn't called before each request and after each response?","author":{"__typename":"User","login":"dchohfi","id":"MDQ6VXNlcjUwODYzNg==","name":"Diego Chohfi"}},{"__typename":"IssueComment","body":"Thank your for your response! Now I get it, sorry about that.","author":{"__typename":"User","login":"dchohfi","id":"MDQ6VXNlcjUwODYzNg==","name":"Diego Chohfi"}}]}},{"__typename":"Issue","title":"JSONRequest losing headers when useGETForQueries is true","author":{"__typename":"User","login":"dchohfi","id":"MDQ6VXNlcjUwODYzNg==","name":"Diego Chohfi"},"body":"## Bug report\r\n\r\nAfter migrating my project to the new version, I'm not able to use a service that has authentication via header.\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.0\r\n- Xcode version: 12.0.1\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nCreate an interceptor that adds a header to the request, the NetworkTransporter must have `useGETForQueries=true`.\r\n\r\n## Further details\r\n\r\nWhen the method `toURLRequest` gets called, the request gets recreated and all headers are lost, including the defaults added by apollo. After digging into the code, I found that the library is instantiating a new `URLRequest` instead of just changing the URL.\r\n\r\nhttps://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/JSONRequest.swift#L101","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I would love to send a PR to fix it, just want to confirm first if this is what is happening.","author":{"__typename":"User","login":"dchohfi","id":"MDQ6VXNlcjUwODYzNg==","name":"Diego Chohfi"}}]}},{"__typename":"Issue","title":"Massive API.swift file ","author":{"__typename":"User","login":"RomanTysiachnik","id":"MDQ6VXNlcjMxNjUyMjY1","name":"Roman Tysiachnik"},"body":"## Feature request\r\n\r\nGenerate each query, mutation, fragment and scalar type in a separate file.\r\n\r\n## Motivation\r\n\r\nWe use Apollo in production on a pretty large project.\r\nRight now our generated `API.swift` file is almost 10 Mb and it has 255,000+ lines of code.\r\nAfter we create a new query/mutation, the file may be overwritten completely, that it is impossible to understand anything in git. \r\nMoreover, Xcode freezes for about a minute when we try to open that single file.\r\n\r\n| Code | Git mess |\r\n| :--: | :--: | \r\n| \"Screen | \"Screen |\r\n\r\n\r\n## Proposed solution\r\n\r\nAs far as all requests and types are public classes, it shouldn't be hard to put each of them in a separate file.\r\nAll those files can also be sorted in folders to make it much easier to navigate through the API.\r\nAPI ->\r\n--Scalars ->\r\n----Upload.swift\r\n--Fragments ->\r\n----UserFragment.swift\r\n--Queries ->\r\n----UserQuery.swift ->\r\n--Mutations ->\r\n----CreateUserMutation.swift\r\n\r\n#### Benefits\r\n\r\n- Each request/type in a separate file and it is easy to navigate among them;\r\n- No freezes when you accidentally open an API file and it freezes Xcode for minutes.\r\n- Only new updates of the API in source control. \r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"If you provide a folder path instead of a file path to the generate command, it will do exactly this: a separate file for everything.","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"@TizianoCoroneo \r\n\r\nCould you share an example, please? ","author":{"__typename":"User","login":"RomanTysiachnik","id":"MDQ6VXNlcjMxNjUyMjY1","name":"Roman Tysiachnik"}},{"__typename":"IssueComment","body":"This is the script as is in [the docs](https://www.apollographql.com/docs/ios/installation/):\r\n```bash\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" API.swift\r\n```\r\n\r\nIf you make a folder named `API` just next to your `API.swift` file, and then remove the `.swift` extension from the last argument of the script, it should work:\r\n```bash\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" API/\r\n```","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"I'm using Swift scripting to generate API from this [doc](https://www.apollographql.com/docs/ios/swift-scripting/):\r\n```swift\r\nApolloCodegen.run(\r\n from: queriesURL,\r\n with: apolloCLIURL,\r\n options: Options.codegen\r\n )\r\n```\r\n\r\nAnd I couldn't find a way to get rid of that massive file.","author":{"__typename":"User","login":"RomanTysiachnik","id":"MDQ6VXNlcjMxNjUyMjY1","name":"Roman Tysiachnik"}},{"__typename":"IssueComment","body":"Ok. I guess I've managed how to handle that, there's another `init` that allows you to specify output format:\r\n\r\n```swift\r\nlet operationIDsURL = outputURL\r\n .appendingPathComponent(\"operationIDs.json\")\r\n\r\nlet schemaURL = outputURL\r\n .appendingPathComponent(\"schema.json\")\r\n\r\n ApolloCodegenOptions(\r\n codegenEngine: .default,\r\n operationIDsURL: operationIDsURL,\r\n outputFormat: .multipleFiles(inFolderAtURL: outputURL),\r\n urlToSchemaFile: schemaURL\r\n )\r\n```\r\n\r\nClosing the issue :) ","author":{"__typename":"User","login":"RomanTysiachnik","id":"MDQ6VXNlcjMxNjUyMjY1","name":"Roman Tysiachnik"}},{"__typename":"IssueComment","body":"So, I'm noticing we're getting massive differences in file sizes from the generated output depending on if we use the `apollo codegen:generate` command through the NPM installed CLI vs. the **SwiftCodegenLib**.\r\n\r\nLike... one of our files is almost 20mb from **SwiftCodegenLib** but 224kb from the NPM CLI.\r\n\r\nWhat could be causing such as massive difference?","author":{"__typename":"User","login":"Mordil","id":"MDQ6VXNlcjM1MDY3NzY=","name":"Nathan Harris"}},{"__typename":"IssueComment","body":"I just compared the commands, and it looks like the default `mergeInFieldsFromFragmentSpreads: true` is the source of the \"bloat\".\r\n\r\nWhat is the cost/benefit of having that set to `true`, as it is by default?","author":{"__typename":"User","login":"Mordil","id":"MDQ6VXNlcjM1MDY3NzY=","name":"Nathan Harris"}},{"__typename":"IssueComment","body":"I'm very surprised to hear it's causing that big a jump. `mergeInFieldsFromFragmentSpreads` ensures that fields in spreads (the `...BlahFragment` operator) are actually on the returned object. It basically is the difference between calling `object.propertyFromFragment` and `object.fragment.propertyFromFragment` on literally everything, which can get REAL old. \r\n\r\n@Mordil you've got my email, can you send me before/after of your API.swift so i can validate assumptions? \r\n\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"In our codebase adding the `mergeInFieldsFromFragmentSpreads` option causes 220k+ lines of code to appear, mostly:\r\n- getter/setters for each property in the fragment\r\n- memberwise initializers that are omitted if a type contains a fragment (I found this behavior quite surprising; I would prefer to always have `init`s for testing purposes)\r\n\r\n(I have to admit that we overuse fragments, and that's the main culprit.)\r\n\r\nMight be interesting to use [dynamic member lookup with keypaths](https://www.avanderlee.com/swift/dynamic-member-lookup/) to reduce code bloat, so that the enclosing type can refer dynamically to the properties of the enclosed fragment. I guess this road will be explored in the context of the new Swift Codegen though, right?","author":{"__typename":"User","login":"TizianoCoroneo","id":"MDQ6VXNlcjE1MzQwMzgy","name":"TizianoCoroneo"}},{"__typename":"IssueComment","body":"Yes. Also representing fragments as protocols means that you can have the properties straight on the object without duplication. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Query watcher not being called when cache is updated on an element by another query/subscription/mutation","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"},"body":"## Bug report\r\n\r\nQuery watcher not being called when cache is updated on an element of a collection that is added after calling watch\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.0\r\n- Xcode version: 12.0.1\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nI've been trying a lot of things on that one and wasn't able to find a way to fix my problem. So in my app I'm having a list of conversations, so I'm creating a `watch` on a query that returns the list of conversations, this is something like that:\r\n\r\n```\r\nuser {\r\n uuid\r\n firstName\r\n lastName\r\n conversations {\r\n uuid\r\n unreadMessagesCount\r\n }\r\n}\r\n```\r\n\r\n> In the app we use the `uuid` key to handle cache, so we make sure to always pass `uuid` in our queries to automatically handle cache update.\r\n\r\nSo the role of the watcher I'm talking about is both to update existing conversations and also be able to catch when a new conversation is created (it can happen and not be initiated by the user, we then trigger an event from the backend that is listen from a subscription in the app). When this event happens it returns something like that\r\n\r\n```\r\nevent {\r\n newConversation {\r\n conversation {\r\n uuid\r\n unreadMessagesCount\r\n // This is the part that adds the new conversation to the existing ones of the users in the cache\r\n user {\r\n uuid\r\n conversations {\r\n uuid\r\n unreadMessagesCount\r\n }\r\n } \r\n }\r\n }\r\n}\r\n```\r\n\r\nIt works great, meaning that when this event happens, the watcher is being called with the newly created conversation, but the issue is that any new cache update for that specific conversation doesn't trigger the watcher again.\r\n\r\nAfter investigating a bit, I realised that the cache is being updated because if I'm adding 3 new messages into the new conversation (setting the `unreadMessagesCount` to 3), the watcher doesn't get called but then if I add 1 new message into an old one, the watcher is being called with both the new message on the old conversation and the 3 new on the new one. \r\n\r\nSo it really seems like `watch` is not being called again for changes on an item that wasn't in a collection when the `watch` was initially made. I've also take a look at https://github.com/apollographql/apollo-ios/issues/281 and making a `fetch` on the same query again after the event doesn't fix the issue.\r\n\r\nLet me know if I'm not clear on something as the whole thing is a bit complicated to explain.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"To add more to this, I feel like this is not related to collections only. If you have 1 query that watches something, then another query/mutation updates this cache indirectly (not using the same query, but another query that contains the same element with the same `uuid`), it doesn't work.","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"Do you have any thoughts on why the test that was added would be passing, but what you're working with would not be working?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm afraid no, but all I can tell is that it works with 0.32.0 and not with 0.34.0","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"Hi @designatednerd,\r\n\r\nI think I have the same problem but not on a collection. My watcher is not triggered anymore since I have updated Apollo from 0.31.0 to 0.34.1. I have a watcher in cachePolicy .returnCacheDataAndFetch on this Query.\r\n\r\n```\r\nquery GetRide($rideId: ID!) {\r\n ride(id: $rideId) {\r\n ...EndRideFragment\r\n }\r\n}\r\n```\r\n\r\nAnd I have a mutation that updates my cache and normally triggers my watcher.\r\n```\r\nmutation StopRide($input: StopActiveRideInput!) {\r\n stopActiveRide(input: $input) {\r\n ride {\r\n ...EndRideFragment\r\n }\r\n }\r\n}\r\n```\r\nSince my Apollo pod upgrade, not working anymore. My watcher is not triggered when mutation payload updates my cache.","author":{"__typename":"User","login":"Narayane","id":"MDQ6VXNlcjQ5MjEzMDg=","name":"Sébastien BALARD"}},{"__typename":"IssueComment","body":"This is also occurring for me. 0.33.0 (non beta) worked; but not 0.34.0 or 0.34.1","author":{"__typename":"User","login":"dhritzkiv","id":"MDQ6VXNlcjEzNDk4NjU=","name":"Daniel Hritzkiv"}},{"__typename":"IssueComment","body":"@dhritzkiv That makes sense, the network stack and how it interacts with the cache changed completely in 0.34.0. \r\n\r\nApologies, I've been under the weather. I'm gonna do some digging starting tomorrow to try to figure out how I broke this without breaking the tests 🙃","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"No rush from me! I was able to roll back to 0.33.0 no problem","author":{"__typename":"User","login":"dhritzkiv","id":"MDQ6VXNlcjEzNDk4NjU=","name":"Daniel Hritzkiv"}},{"__typename":"IssueComment","body":"I can wait 1 week to have feedback from you @designatednerd on this issue.\r\nIf you need more time to investigate or to solve it, I could roll back to 0.33.0 to avoid blocking me in production","author":{"__typename":"User","login":"Narayane","id":"MDQ6VXNlcjQ5MjEzMDg=","name":"Sébastien BALARD"}},{"__typename":"IssueComment","body":"Same here, I rollbacked to 0.32.1 so no rush from me, and thanks for taking time investigating this!","author":{"__typename":"User","login":"benoitletondor","id":"MDQ6VXNlcjg2ODA1NA==","name":"Benoit Letondor"}},{"__typename":"IssueComment","body":"I'm trying to reproduce this issue to investigate what could be going on, but it's been hard because unfortunately our tests aren't set up to run in real life conditions, where concurrency may play a role. The existing watcher tests all continue to pass, and so do some new ones I've been adding.\r\n\r\nIt would be helpful to learn more about the way people who experience this are using the framework, and what behavior they are seeing:\r\n- How are you initializing and configuring the client, cache, store and network transport?\r\n- Are you calling methods on `ApolloClient` from the main thread or from a background thread? Do you receive results on the main queue as well, or are you passing in a custom queue?\r\n- Does the issue occur 100% of the time, or only sometimes?\r\n- Are there other operations in flight when this happens, or does it also happen with just a single watcher and a single related query or mutation?\r\n- Anything else unusual or noticeable?\r\n\r\nI know this is a long shot, but it would be even more helpful if anyone was able to share a project that reliably exhibits this issue.","author":{"__typename":"User","login":"martijnwalraven","id":"MDQ6VXNlcjU0NDg1","name":"Martijn Walraven"}},{"__typename":"IssueComment","body":"A few more thoughts after taking a closer look at this:\r\n\r\n1) It seems any operations using the `WebSocketTransport` always ignore the cache completely starting in 0.33 (I believe https://github.com/apollographql/apollo-ios/commit/444c465671c786659599a16da4b2d23d43648a74 is where this change was introduced). That means subscription results are not actually published to the store, and thus will not trigger watchers. (@benoitletondor I think that would at least explain your initial bug report).\r\n\r\n2) That doesn't yet explain why queries and mutations would also fail to trigger watchers (assuming those are not using the `WebSocketTransport`). There is a possibility for misconfiguration however, which would lead to inadvertently having multiple stores (see https://github.com/apollographql/apollo-ios/issues/1438). Could some of you be bitten by this maybe?\r\n\r\n3) Using a custom `NetworkTransport` also currently ignores the cache completely (see https://github.com/apollographql/apollo-ios/pull/1442 for an in progress PR to work around this). Any chance this could explain the behavior some of you are seeing?","author":{"__typename":"User","login":"martijnwalraven","id":"MDQ6VXNlcjU0NDg1","name":"Martijn Walraven"}},{"__typename":"IssueComment","body":"I'm not using WebSocketTransport, but 3. sound like it could be what's plaguing us! Will have some time in two weeks to poke around that","author":{"__typename":"User","login":"dhritzkiv","id":"MDQ6VXNlcjEzNDk4NjU=","name":"Daniel Hritzkiv"}},{"__typename":"IssueComment","body":"@martijnwalraven I guess 3. could be an explanation in my case, I have a custom `NetworkTransport` implementation (http request headers additions, checks on http response)\r\n\r\n`public func send(operation: Operation, completionHandler: @escaping (_ result: Result, Error>) -> Void) -> Cancellable` in 0.33\r\n\r\nbecomes\r\n\r\n`public func send(operation: Operation, cachePolicy: CachePolicy, contextIdentifier: UUID?, callbackQueue: DispatchQueue, completionHandler: @escaping (Result, Error>) -> Void) -> Cancellable where Operation : GraphQLOperation` in 0.34\r\n\r\nI need to change\r\n```\r\ndo {\r\n let body = try self.serializationFormat.deserialize(data: data) as! JSONObject\r\n let response = GraphQLResponse(operation: operation, body: body)\r\n completionHandler(.success(response))\r\n} catch { }\r\n```\r\ninto\r\n```\r\ndo {\r\n let body = try self.serializationFormat.deserialize(data: data) as! JSONObject\r\n let response = GraphQLResponse(operation: operation, body: body)\r\n let result = try response.parseResultFast()\r\n completionHandler(.success(result))\r\n} catch { }\r\n```\r\nto try to conform my code to the new signature","author":{"__typename":"User","login":"Narayane","id":"MDQ6VXNlcjQ5MjEzMDg=","name":"Sébastien BALARD"}}]}},{"__typename":"Issue","title":"Why the response is not being triggered and no interceptors are dispatched?","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null},"body":"I'm building the client like this:\r\n![image](https://user-images.githubusercontent.com/6308120/94703838-90143b00-033f-11eb-8033-3f2727a09fbe.png)\r\nThis is my Interceptor Provider:\r\n![image](https://user-images.githubusercontent.com/6308120/94703879-9c989380-033f-11eb-8fab-ea802d571565.png)\r\nAnd this is an example of the query fetch:\r\n![image](https://user-images.githubusercontent.com/6308120/94703946-aae6af80-033f-11eb-93aa-b7670cb5c41d.png)\r\nIt is never stopping at result or at any interceptor, but console is dispatching:\r\n![image](https://user-images.githubusercontent.com/6308120/94704042-c81b7e00-033f-11eb-9ca7-ad9b833251b2.png)\r\n\r\nDo you have any idea what is wrong there?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"You are not actually including anything that calls the network, it looks like. You will need to include the `NetworkFetchInterceptor`, probably between request and response logging interceptors. \r\n\r\nI don't know why the response logging interceptor would be showing a 200 response when there's nothing that came through, because the request never went out to the network.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Obsolete type GraphQLHTTPResponseError","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"},"body":"## Bug report\r\n\r\nWith the new network stack (yeah!) a few types such as `GraphQLHTTPResponseError` became obsolte but did not get removed from code base yet.\r\n\r\n## Versions\r\n\r\n- `apollo-ios` SDK version: 0.34.0\r\n\r\n## Steps to reproduce\r\n\r\n\"Find usages\" of `GraphQLHTTPResponseError`, `GraphQLHTTPRequestError` and probably others.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"`GraphQLHTTPRequestError` is still used, but good catch on the response error. \r\n\r\nPlease note that \"find usages\" isn't the be-all, end-all, especially for enum types - always worth doing a text search through the full codebase. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"The problem here for me was that by not beeing broken because of a removed class my validations got semantically broken because they where still checking for that type.\r\n\r\nOf course you're right about `GraphQLHTTPRequestError`. I've mistaken that.\r\n\r\nBut still, regarding your advise to check for \"usages\" with full text search i have to strongly disagree. In fact i heavily rely on this kind of type based analysis and navigating through code and therefore i prefer AppCode over Xcode a lot because of it outstanding capabilities in that. You should give it a try.","author":{"__typename":"User","login":"knox","id":"MDQ6VXNlcjE2NDAx","name":"Mickey"}},{"__typename":"IssueComment","body":"I agree that it's helpful, but particularly when it comes to removing stuff, I've found it better to belt-and-suspenders things by actually searching out where something is used (even in AppCode, which I have used before). ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"This has been removed with `0.35.0`. If you find other unused types, please open a new issue. Thanks!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Enhance support for custom cache key resolver logic","author":{"__typename":"User","login":"qingqingliu","id":"MDQ6VXNlcjMzMDk3NjE=","name":null},"body":"## Feature request\r\n\r\nAdd similar support of [CacheKeyResolver](https://github.com/apollographql/apollo-android/blob/main/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheKeyResolver.kt) as from Android Apollo Client library. \r\n\r\n## Motivation\r\n\r\nCurrent iOS library provides cacheKeyForObject on ApolloClient that allows you to provide custom cache key for response, but there is no way for client app to provide custom cache key for request. This feature is needed in case client wants to use a different cache key for request\r\n\r\n## Proposed solution\r\n\r\nFollow Android pattern to introduce CacheKeyResolver on ApolloClient and support custom cache key for both response and request key.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"We're going to be looking in late 2020-early 2021 at getting our mobile caching more aligned, both across iOS and android and with our web cache, and this is one of the things I'll definitely be considering. \r\n\r\nI'm definitely open to discussion if you're interested in implementing this yourself.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks @designatednerd for the follow up. I see this is being part of bigger alignment between iOS and Android, I would probably wait for an overall proposal first. Happy to contribute though once the proposal is in place\r\n\r\nAs android side does seems have more feature supports like refetch, optimistic updates and custom cache key etc, wondering whether the direction for iOS would be following Android design pattern","author":{"__typename":"User","login":"qingqingliu","id":"MDQ6VXNlcjMzMDk3NjE=","name":null}},{"__typename":"IssueComment","body":"We're going to try to line up on what's best for both - the biggest issue right now is that iOS had a long period where no development took place (while Android was chugging along well with open-source contributions) and I'm still digging my way out of that hole. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Enum generation with `INIT` case","author":{"__typename":"User","login":"bezoadam","id":"MDQ6VXNlcjI1NjEzMTI1","name":"Adam Bezak"},"body":"## Bug report\r\n\r\nHi, enum is declared like this:\r\n![Snímka obrazovky 2020-10-01 o 8 26 56](https://user-images.githubusercontent.com/25613125/94775340-ede86780-03bf-11eb-9f4e-f9cb5bc9f5a0.png)\r\n\r\nand generated code throws these errors:\r\n![Snímka obrazovky 2020-10-01 o 8 27 08](https://user-images.githubusercontent.com/25613125/94775447-18d2bb80-03c0-11eb-9fe5-b6f6d12420ef.png)\r\n\r\nIt looks like there is problem with `INIT` case when using enum.\r\n\r\n## Versions\r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.0.1\r\n- Swift version: 5\r\n\r\n## Steps to reproduce\r\n\r\nGenerate code with `init` in enum case.\r\n\r\nIs it problem on my side or bug in apollo codegen. Any possible fixes?\r\nThanks.\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It's the codegen - it's not properly escaping the case named `init`, which is a reserved Swift keyword. Upcoming codegen should handle this better but it's gonna be a bit - is this schema already public or is it still being evolved? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Schema is partially public but I think there is not chance that there will be some changes. Anyway if I change `.init` to ``.init`` on lines where error is triggered, it disappears. But of course on next build code is regenerated. So I think this should be fixed in codegen.","author":{"__typename":"User","login":"bezoadam","id":"MDQ6VXNlcjI1NjEzMTI1","name":"Adam Bezak"}},{"__typename":"IssueComment","body":"Yeah, absolutely - fixing the current codegen is a pain (which is why it's being rewritten) so I was trying to make sure it was necessary before diving into it. 🙃","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thank you 👍 it is not necessary for me, I think i can handle it somehow (use temporary script to rename all `.init` cases to `\".init\"`)","author":{"__typename":"User","login":"bezoadam","id":"MDQ6VXNlcjI1NjEzMTI1","name":"Adam Bezak"}},{"__typename":"IssueComment","body":"You'd need to make it\r\n\r\n```swift\r\n`.init`\r\n```\r\n\r\n rather than `\".init\"`, but if you're ok with that, I'm very OK with not diving into typsecript hell 😇. If that's cool with you, mind if we close this one out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"When adding interceptors, they don't parse properly errors","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null},"body":"SDK 0.34.0\r\n\r\nI can fetch the data, response is received:\r\n![image](https://user-images.githubusercontent.com/6308120/94791351-cac9b200-03d7-11eb-9d99-78a0bacddbcf.png)\r\nBut when handling it:\r\n![image](https://user-images.githubusercontent.com/6308120/94791434-e92fad80-03d7-11eb-934b-7777241fbad7.png)\r\nIt is entering the failure, but with a totally separate error:\r\n![image](https://user-images.githubusercontent.com/6308120/94791471-f8166000-03d7-11eb-8e70-c9a48d108e87.png)\r\nActually, that error does not contain anything related to the errors data is receiving.\r\nEven with just the Network Interceptor:\r\n![image](https://user-images.githubusercontent.com/6308120/94791498-02d0f500-03d8-11eb-8877-bc49dd33a64e.png)\r\n\r\nCould you help there?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"If I use LegacyInterceptorProvider it does work","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null}},{"__typename":"IssueComment","body":"You don't have a parsing interceptor happening here, so the data is not being parsed by the time it gets to the end of the interceptor chain. The parsing isn't done by the chain itself, it's done by the individual interceptors.\r\n\r\nIf you're creating your own interceptor provider, you have to provide _all_ the interceptors that you're planning to use, including the ones that do the parsing. A good place to start is to copy the interceptors that are in `LegacyInterceptorProvider` and then add your custom interceptors to that array wherever you want them to execute. \r\n\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Is there anything else I can help with here, or can we close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"You can close it. Many thanks!\n\nEl mar., 6 oct. 2020 a las 0:43, Ellen Shapiro ()\nescribió:\n\n> Is there anything else I can help with here, or can we close this issue\n> out?\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly, view it on GitHub\n> ,\n> or unsubscribe\n> \n> .\n>\n\n\n-- \n*Jose Ángel Zamora Cobo*\nTelecommunication Engineer\nAndroid/iOS Senior Software Engineer\n\n","author":{"__typename":"User","login":"angelu25","id":"MDQ6VXNlcjYzMDgxMjA=","name":null}}]}},{"__typename":"Issue","title":"Failed codegen when using GitHub GraphQL schema","author":{"__typename":"User","login":"mattia","id":"MDQ6VXNlcjExMTM4OA==","name":"Mattia Valzelli"},"body":"## Bug report\r\n\r\nWhile trying to use the [Swift scripting codegen tooling](https://www.apollographql.com/docs/ios/swift-scripting/) I was not able to generate the `API.swift` file given the corresponding schema file.\r\n\r\nAn error like this is generated \r\n\r\n> Field \"AcceptEnterpriseAdministratorInvitationInput.clientMutationId\" already exists in the schema. It cannot also be defined in this type extension.\r\n\r\n\r\nBut using the GraphQL verification tool available in the [same repo](https://github.com/octokit/graphql-schema) it passes. (running `npm start validate:ts`)\r\n\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.2 beta 2 (12B5025f)\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nSet up the project as described in the [Swift scripting guide](https://www.apollographql.com/docs/ios/swift-scripting/) and use the GitHub schema definition with the following files:\r\n - [schema.graphql](https://raw.githubusercontent.com/octokit/graphql-schema/master/schema.graphql)\r\n - [schema.json](https://raw.githubusercontent.com/octokit/graphql-schema/master/schema.json)\r\n\r\n## Further details\r\n\r\n
\r\n Example `main.swift`\r\n \r\n```swift\r\nimport ApolloCodegenLib\r\n\r\n// Grab the parent folder of this file on the filesystem\r\nlet parentFolderOfScriptFile = FileFinder.findParentFolder()\r\n\r\n// Use that to calculate the source root of both the\r\nlet sourceRootURL = parentFolderOfScriptFile\r\n .apollo.parentFolderURL() // Sources\r\n .apollo.parentFolderURL() // Codegen\r\n .apollo.parentFolderURL() // My Project\r\n\r\n// From the source root, figure out where your target\r\n// root is within your main project\r\nlet targetRootURL = sourceRootURL\r\n .apollo.childFolderURL(folderName: \"My Project\")\r\n\r\n// Set up the URL you want to use to download the project\r\nlet endpoint = URL(string: \"https://api.github.com/graphql\")!\r\n\r\n// Create an options object for downloading the schema\r\nlet schemaDownloadOptions = ApolloSchemaDownloadConfiguration(\r\n endpointURL: endpoint,\r\n headers: [\"Authorization: Bearer XXXXXXXXX\"],\r\n outputFolderURL: targetRootURL\r\n)\r\n\r\n// Calculate where you want to create the folder where the CLI will\r\n// be downloaded by the ApolloCodegenLib framework.\r\nlet cliFolderURL = sourceRootURL\r\n .apollo.childFolderURL(folderName: \"Codegen\")\r\n .apollo.childFolderURL(folderName: \"ApolloCLI\")\r\n\r\ndo {\r\n // Actually attempt to download the schema.\r\n try ApolloSchemaDownloader.run(with: cliFolderURL,\r\n options: schemaDownloadOptions)\r\n} catch {\r\n // This makes the error message in Xcode a lot more legible,\r\n // and prevents the script from continuing to try to generate\r\n // code if the schema download failed.\r\n exit(1)\r\n}\r\n\r\n// Create the default Codegen options object (assumes schema.json\r\n// is in the target root folder, all queries are in some kind\r\n// of subfolder of the target folder and will output as a\r\n// single file to API.swift in the target folder)\r\nlet codegenOptions = ApolloCodegenOptions(targetRootURL: targetRootURL)\r\n\r\ndo {\r\n // Actually attempt to generate code.\r\n try ApolloCodegen.run(from: targetRootURL,\r\n with: cliFolderURL,\r\n options: codegenOptions)\r\n} catch {\r\n // This makes the error message in Xcode a lot more legible.\r\n exit(1)\r\n}\r\n```\r\n
\r\n\r\nPlease let me know if I can help debug this. Also I am new to GraphQL, so I may be doing something wrong.\r\n\r\nThank you for this library!","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I've definitely seen this from the `.graphql` version of the GitHub schema before, but it looks from the code like you're downloading the JSON version of it. Can you please confirm that and attach a copy of the schema you're getting from GitHub so I can take a look? Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> I've definitely seen this from the `.graphql` version of the GitHub schema before, but it looks from the code like you're downloading the JSON version of it. Can you please confirm that and attach a copy of the schema you're getting from GitHub so I can take a look? Thank you!\r\n\r\nYes, of course. The schema I'm downloading is from the [octokit repo](https://github.com/octokit/graphql-schema).\r\nThe files are:\r\n - [schema.graphql](https://gist.github.com/mattia/d2cc50fdbfc1a90e58c4c35716677052)\r\n - [schema.json](https://gist.github.com/mattia/4545c6371577d3a7c7c17722bf7266f2).\r\n\r\nThank you and have a nice day!","author":{"__typename":"User","login":"mattia","id":"MDQ6VXNlcjExMTM4OA==","name":"Mattia Valzelli"}},{"__typename":"IssueComment","body":"OK looks like I had it backwards, it's the JSON that's giving the weird error and the SDL that seems to be working fine. If you update your schema download options to downloading SDL instead of the default JSON option, that should work: \r\n\r\n```swift\r\n// Create an options object for downloading the schema\r\nlet schemaDownloadOptions = ApolloSchemaDownloadConfiguration(\r\n schemaFileType: .schemaDefinitionLanguage,\r\n endpointURL: endpoint,\r\n headers: [\"Authorization: Bearer XXXXXXXXX\"],\r\n outputFolderURL: targetRootURL\r\n)\r\n```","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thanks for the reply. I've been real busy these days but I will try to come back to you in the next few days after trying your suggestion.\r\n\r\nThanks again! Have a nice day","author":{"__typename":"User","login":"mattia","id":"MDQ6VXNlcjExMTM4OA==","name":"Mattia Valzelli"}},{"__typename":"IssueComment","body":"OK cool - I'm going to close this issue out for now, please let us know if using the Schema Definition Language version of their schema doesn't work by reopening this issue. \r\n\r\nAnyone else having a similar problem, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Is it okay to git ignore API.swift?","author":{"__typename":"User","login":"prateek3255","id":"MDQ6VXNlcjIxMjc3MTc5","name":"Prateek Surana"},"body":"## Question\r\n\r\nSince API.swift is auto-generated, is it good practice to add it to `.gitignore`?\r\n\r\nWe tried adding it to `.gitignore` but whenever someone new clones the repo, the code fails to compile because of a broken reference to API.swift, and hence we have to manually pass it for the very first time.\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.32.1\r\n- Xcode version: 11.4\r\n- Swift version: 5.1","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"This is not a recommended practice - the exact problem you're having illustrates why this isn't a good idea. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Okay, thanks for the clarification","author":{"__typename":"User","login":"prateek3255","id":"MDQ6VXNlcjIxMjc3MTc5","name":"Prateek Surana"}}]}},{"__typename":"Issue","title":"Using a custom Date scalar","author":{"__typename":"User","login":"Renish-Development","id":"MDQ6VXNlcjQ3Njg0NzE5","name":"Renish_Development"},"body":"@cerupcat @jzhw0130: You should be able to pass `--passthrough-custom-scalars` to `apollo-codegen` to avoid generating a `typealias` to `String` for custom scalars. You can then add your own alias and conversion code, see [here](https://github.com/apollographql/apollo-ios/issues/23#issuecomment-261697349) for an example.\r\n\r\n_Originally posted by @martijnwalraven in https://github.com/apollographql/apollo-ios/issues/94#issuecomment-327287361_","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"How to use/implement Date type custom scalar in iOS?\r\n\r\nI'm working with GraphQL. I have successfully implement Query and Mutation in iOS app.\r\nI'm facing issue with Date Type. As per references, I have added --passthrough-custom-scalars in Run Script BUT I'm facing compilation issue.\r\n**I'm facing issue with \"--passthrough-custom-scalars\" variable. I have added below code in Run script but I'm facing an error.**\r\n\r\n```\r\nDERIVED_DATA_CANDIDATE=\"${BUILD_ROOT}\"\r\nwhile ! [ -d \"${DERIVED_DATA_CANDIDATE}/SourcePackages\" ]; do\r\nif [ \"${DERIVED_DATA_CANDIDATE}\" = / ]; then\r\necho >&2 \"error: Unable to locate SourcePackages directory from BUILD_ROOT: '${BUILD_ROOT}'\"\r\nexit 1\r\nfi\r\nDERIVED_DATA_CANDIDATE=\"$(dirname \"${DERIVED_DATA_CANDIDATE}\")\"\r\ndone\r\nSCRIPT_PATH=\"${DERIVED_DATA_CANDIDATE}/SourcePackages/checkouts/apollo-ios/scripts\"\r\nif [ -z \"${SCRIPT_PATH}\" ]; then\r\necho >&2 \"error: Couldn't find the CLI script in your checked out SPM packages; make sure to add the framework to your project.\"\r\nexit 1\r\nfi\r\ncd \"${SRCROOT}/${TARGET_NAME}\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./*/.graphql --localSchemaFile=\"schema.json\" API.swift\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh schema:download --endpoint=\"endpointURL\"\r\n#custom scalars\r\n**$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift --passthrough-custom-scalars**\r\n```\r\n\r\n**Code for Define Date Scalars**\r\n```swift\r\npublic typealias DateTime = Date\r\nextension DateTime: JSONDecodable, JSONEncodable {\r\n public init(jsonValue value: JSONValue) throws {\r\n guard let string = value as? String else {\r\n throw JSONDecodingError.couldNotConvert(value: value, to: String.self)\r\n }\r\n guard let date = ISO8601DateFormatter().date(from: string) else {\r\n throw JSONDecodingError.couldNotConvert(value: value, to: Date.self)\r\n }\r\n self = date\r\n }\r\n public var jsonValue: JSONValue {\r\n return ISO8601DateFormatter().string(from: self)\r\n }\r\n}\r\n```\r\n\r\n**I have reviewed schema JSON have a Date variable but API.swift still string type.**\r\nHere is my graphql mutation.\r\n```graphql\r\nmutation AddPeriod($uid:ID!, $start_time : Date!, $flow: PeriodFlowInput){\r\n addPeriod(uid:$uid, start_time : $start_time, flow: $flow){\r\n id\r\n start_time\r\n end_time\r\n flow {\r\n value\r\n flow_time\r\n }\r\n }\r\n}\r\n```\r\n\r\nHow can I pass date in GraphQL mutation. Please help me. Thanks in advance","author":{"__typename":"User","login":"Renish-Development","id":"MDQ6VXNlcjQ3Njg0NzE5","name":"Renish_Development"}},{"__typename":"IssueComment","body":"Hi @Renish-Development - I updated your comment to add some formatting. \r\n\r\nIt looks like your type is called `Date` rather than `DateTime`, which would mean I believe you need to have your typealias be:\r\n\r\n```swift\r\ntypealias Date = Swift.Date\r\n```\r\n\r\nAnd then have your extension be on `Date` rather than `DateTime`. Give that a shot, let me know how it goes.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd , \r\n\r\n**1. Swift Date is Not available. I'm using Xcode 12. Please look at the attached screen shot.**\r\n\r\n**2. I'm also facing issue with execute --passthrough-custom-scalars. Please let me know what I missed for custom scalars**\r\n\r\n**$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift --passthrough-custom-scalars**\r\n\r\n\"Screenshot\r\n","author":{"__typename":"User","login":"Renish-Development","id":"MDQ6VXNlcjQ3Njg0NzE5","name":"Renish_Development"}},{"__typename":"IssueComment","body":"Argh, I meant `Foundation.Date`. I always forget what's swift and what's foundation📈\r\n\r\nAnd `--output API.swift` has to be the last argument - move `--passthrough-custom-scalars` before that. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd , Its' not working. Please can I do any mistake or issue due to the updated version of Xcode 12. I'm using Xcode 12. Please check with your side and let me know it's work or not. Happy top share more information","author":{"__typename":"User","login":"Renish-Development","id":"MDQ6VXNlcjQ3Njg0NzE5","name":"Renish_Development"}},{"__typename":"IssueComment","body":"I did notice that the param is `--passthroughCustomScalars` rather than `--passthrough-custom-scalars` - that could be part of it. If that's not what's not working, please let me know in more detail what isn't working and in what way it is not working. Thanks. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Hi @Renish-Development is there anything more I can help with here or can we close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"You're far from the only person who's asked a ton of questions about this so I've added a page to our example playground to try and clarify this. Please see #1474 for further details","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd , Please add verify and step by step code or make tutorial as per latest version of GIT repo. Also I have not found proper documentation regarding custom scalar, pass token in API call, generate schema file with auth token and so on. I'm happy to help you anyway and if you can guide I will write tutorial for the same. Looking forward....","author":{"__typename":"User","login":"GlobesyncTechnologies","id":"MDQ6VXNlcjUzNDc1MDIx","name":"Renish | GlobeSync Technologies"}},{"__typename":"IssueComment","body":"@GlobesyncTechnologies Please see the PR I linked for an example of using a custom scalar. Please check out [our full tutorial](https://www.apollographql.com/docs/ios/tutorial) for full setup instructions. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Mismatched stores for ApolloClient/LegacyInterceptorProvider","author":{"__typename":"User","login":"danpalmer","id":"MDQ6VXNlcjIwMjQwMA==","name":"Dan Palmer"},"body":"## Bug report\r\n\r\nCaveat: this isn't quite a bug, perhaps more of a design bug, but we nearly shipped a bug in our app because of it. Also, I may just be missing things!\r\n\r\nThere are two ways to set up an `ApolloStore` for the networking in Apollo, and unless both are done, in the same way, I believe there can be inconsistencies.\r\n\r\nFor example, we previously did this in our `ApolloClient` setup:\r\n\r\n```swift\r\nlet networkTransport = HTTPNetworkTransport(url: baseURL)\r\nlet cache = InMemoryNormalizedCache()\r\nlet store = ApolloStore(cache: cache)\r\nlet client = ApolloClient(networkTransport: networkTransport, store: store)\r\n```\r\n\r\nWhen upgrading to the newest version of Apollo, we originally re-wrote this as:\r\n\r\n```swift\r\nlet provider = LegacyInterceptorProvider()\r\nlet networkTransport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: baseURL)\r\nlet cache = InMemoryNormalizedCache()\r\nlet store = ApolloStore(cache: cache)\r\nlet client = ApolloClient(networkTransport: networkTransport, store: store)\r\n```\r\n\r\nAs far as I can tell (please tell me if I'm wrong!) this has set up a store that is now not being used at all. We can still call `client.clearCache()` or `client.cacheKeyForObject` and it will use the store that we created, but this would _not_ affect the store being used by the interceptors.\r\n\r\nSimilarly, we could have configured a more complex cache setup, but that would not be used by the interceptors.\r\n\r\nIf we corrected this in the following way...\r\n\r\n```swift\r\nlet cache = InMemoryNormalizedCache()\r\nlet store = ApolloStore(cache: cache)\r\nlet provider = LegacyInterceptorProvider(store: store)\r\nlet networkTransport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: baseURL)\r\nlet client = ApolloClient(networkTransport: networkTransport)\r\n```\r\n\r\n...this would also introduce bugs because while our correct store is being used for the networking, `client.clearCache` or `client.cacheKeyForObject` are pointing to the `ApolloClient`'s default store from its init method.\r\n\r\n## Versions\r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.0\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nSee above for the process that can lead to incorrect use. This is roughly the steps that we took while upgrading Apollo to 0.34.x – i.e. we went through two invalid implementations before reaching one that we believe is valid.\r\n\r\n## Further details\r\n\r\nAs mentioned above, this isn't really a bug, but I think it's a design issue that could be improved. My recommendation would be to eliminate the store from the `ApolloClient` entirely, and leave it up to the user to coordinate the store with their interceptor provider. Potentially the store could become part of the interceptor provider protocol so that the client could still back `cacheKeyForObject`/`clearCache` onto the provider's store.\r\n\r\nAn alternative would be to eliminate the store from the interceptor provider, and ensure that in the client the store is set correctly on the provider so that they always line up.\r\n\r\nLastly, if maintaining backwards compatibility is key, the store from the provider and the store from the client could be compared at the end of the client initialiser, and an error raised if they are not exactly the same object.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Is there a particular using you're not passing in the `store` parameter for `client` on that last version? eg: \r\n\r\n```swift\r\nlet cache = InMemoryNormalizedCache()\r\nlet store = ApolloStore(cache: cache)\r\nlet provider = LegacyInterceptorProvider(store: store)\r\nlet networkTransport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: baseURL)\r\nlet client = ApolloClient(networkTransport: networkTransport, store: store)\r\n```\r\n\r\nThat would ensure you have the same store in all places. \r\n\r\nI do agree it's a little overcomplicated at the moment - I do plan to keep evolving this, and I appreciate the feedback.\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> Is there a particular using you're not passing in the store parameter for client on that last version? eg:\r\n\r\nNot particularly, but we did go through this stage on the way to our fully working version, which is pretty much what you have in your example. The fact that there were multiple opportunities for human error in getting to that working solution suggests there's a better design possible.\r\n\r\nIdeally these would be caught by the type system, or made un-representable, as I don't believe they are states of the system with valid use-cases.\r\n\r\nWould you accept a PR to address this? If so, what's your preferred approach out of those options I outlined, or is there another way you'd like to solve this?","author":{"__typename":"User","login":"danpalmer","id":"MDQ6VXNlcjIwMjQwMA==","name":"Dan Palmer"}},{"__typename":"IssueComment","body":"If you're not using a custom interceptor provider, the default initializer for `ApolloClient` initializes all this stuff for you - is that more what you're thinking? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> If you're not using a custom interceptor provider, the default initializer for ApolloClient initializes all this stuff for you - is that more what you're thinking?\r\n\r\nI think that route is safe.\r\n\r\nWe were transitioning from the legacy networking stack where we used `HTTPNetworkTransportPreflightDelegate` though. To maintain compatibility we decided to use `LegacyInterceptorProvider` and add an additional interceptor that did what our preflight delegate implementation had previously done, hence ending up with needing to pass the store into two different places, and this getting out of sync in two different ways before we realised the implicit dependency between those two places.\r\n\r\nAlso, just realised that the 3rd code example in the issue body is roughly what's in `Network.swift` in the docs here: https://www.apollographql.com/docs/ios/tutorial/tutorial-mutations/ – following the docs here will result in an invalid construction of the networking stack I think.\r\n\r\nHaving thought about this a bit more, I think there's a more common way this could also be done incorrectly:\r\n\r\n```swift\r\nlet provider = LegacyInterceptorProvider()\r\nlet networkTransport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: baseURL)\r\nlet client = ApolloClient(networkTransport: networkTransport, store: store)\r\n```\r\n\r\nIf not manually constructing a store at all, but instantiating a custom interceptor provider, there are two different stores being used and therefore it's impossible to clear the cache of the \"real\" one, but no error would be raised clearing the cache of the unused one.\r\n\r\nIt's possible I've missed somewhere that the stores get \"joined up\" – I'm new to Swift and don't know much about the Apollo codebase and may not understand the intention here. Apologies if that's the case!\r\n\r\n- - -\r\n\r\nI think there are 3 possible options here (although very open to more suggestions!):\r\n\r\n1. Eliminate the store from the ApolloClient entirely, leave it up to the user to coordinate the store with their interceptor provider. User will need to hold a reference to it for setting/getting the cache key, or clearing the cache.\r\n\r\n2. Eliminate the store from the interceptor provider init, have the client inject it into the interceptor provider. This way the user only has one place to pass it in, and if they don't the default one is still the same.\r\n\r\n3. If maintaining backwards compatibility is key, the store from the provider and the store from the client could be compared at the end of the client initialiser, and an error raised if they are not exactly the same object.\r\n\r\n","author":{"__typename":"User","login":"danpalmer","id":"MDQ6VXNlcjIwMjQwMA==","name":"Dan Palmer"}},{"__typename":"IssueComment","body":"Good catch on the example in the tutorial, that's definitely an error.\r\n\r\nThere are (rare) instances where someone intentionally wants to use different stores, but you're right that most of the time, that's not the case. \r\n\r\nI think of the options you propose, 2 probably makes the most sense. I'll try to see what I can do here. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> There are (rare) instances where someone intentionally wants to use different stores, but you're right that most of the time, that's not the case.\r\n\r\nInteresting! I'm not sure I quite understand what the use-case is for the client to have a different store to the interceptor provider? I can't see how that client store gets used apart from by the user... which means if I've understood correctly, it's not plugged in to the Apollo internals?","author":{"__typename":"User","login":"danpalmer","id":"MDQ6VXNlcjIwMjQwMA==","name":"Dan Palmer"}},{"__typename":"IssueComment","body":"basically there are some people who use multiple clients with multiple stores, and there are some...odd ways people make that work. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I've shipped the PR removing the default stores with `0.36.0` - I took a couple swipes at doing something else besides that, but everything I tried wound up *far* more complicated than \"actually make people select what store they're passing\". \r\n\r\nGoing to close this one out, please open a new issue if you think you've got a better suggestion!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Nice one! PRs look good. Straightforward approach sounds good – I can't see myself making the mistakes above if this was in place. Better API ergonomics can come later if they're needed at all.\r\n\r\nThanks for your work on this!","author":{"__typename":"User","login":"danpalmer","id":"MDQ6VXNlcjIwMjQwMA==","name":"Dan Palmer"}}]}},{"__typename":"Issue","title":"Can not find 'GenericScalar' in scope","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null},"body":"## Bug report\r\n\r\nBackend is JWT and when i'll try to execute a mutation for tokenVerification it gives me an error. We have Payload (Scalar Type) as response it in. I have added --passthroughCustomScalars in run script also.\r\n\r\n`SCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\ncd \"${SRCROOT}/${TARGET_NAME}\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" --passthroughCustomScalars API.swift\r\n`\r\n\r\n## Versions\r\n\r\n\r\n- `apollo-ios` SDK version: POD 0.34.0\r\n- Xcode version: XCode 12\r\n- Swift version: Swift 5\r\n\r\n## Steps to reproduce\r\n\r\nPlease add Scalar type response in mutation/query and try to build the project (first clear build folder)\r\n\r\n## Further details\r\n\r\nI have tried to do Type Conversion using this help : https://github.com/apollographql/apollo-ios/blob/main/Sources/Apollo/JSONStandardTypeConversions.swift\r\n\r\nBut its not working as we are using swift 5 i think.\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! Can you clarify a bit: \r\n\r\n- What is the name of your custom scalar type, `Payload` or `GenericScalar`? \r\n- What is the underlying type of your custom scalar? It sounds like it's a string containing the JWT, I just want to double check\r\n- Have you tried using a `typealias` to define the scalar type? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@tapannathvani Hi, do you have answers to any of the questions I asked? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Closing this issue as i am not using Payload response data now.","author":{"__typename":"User","login":"tapannathvani","id":"MDQ6VXNlcjEwMzY4OTU1","name":null}}]}},{"__typename":"Issue","title":"Add example for direct writing to the cache","author":{"__typename":"User","login":"michael-mckenna","id":"MDQ6VXNlcjE0MDM1MTQ4","name":null},"body":"## Feature request\r\n\r\nAdd examples for writing directly to the cache, hopefully for all variants of the \"write\" function:\r\n```\r\ntransaction.write(object:withKey:)\r\ntransaction.write(data:forQuery:)\r\ntransaction.write(object:withKey:variables:)\r\n```\r\n\r\nLooks like only `read` and `update` are in the docs at the moment.\r\nhttps://github.com/apollographql/apollo-ios/blob/main/docs/source/caching.mdx#direct-cache-access\r\n\r\n## Motivation\r\n\r\nI'm new to GraphQL and using it for a side project has a learning experience. I don't want to get the whole server and datasource set up yet - would like to just do the iOS portion and have some sort of proof of concept going before pursuing it further. Because of this, I'm using the direct cache access exclusively for now. The extra examples in the readme will help me and future devs a lot. I come from using Realm and Core Data so this is quite a bit different for me.\r\n\r\n## Outstanding Questions\r\n\r\nIs there a sample app that utilizes direct cache access? If so, it'd be great to add a reference to that.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi, I can certainly add one, but I will say that the idea is that you avoid manually reading from or writing to the cache unless you absolutely have to, and let the store handle most of the nonsense around dealing with cache keys and things like that.\r\n\r\nIf it's your first time messing around with it and you just want to get an idea of how it works, I'd recommend checking out the app from the [Tutorial](https://www.apollographql.com/docs/ios/tutorial/), which uses a server that's already set up. You can then more easily inspect how things go into the in-memory cache or, if you want to, you can switch to using the SQLite cache and examine the SQLite database. \r\n\r\nThat will also allow you to have a base to mess around from if you are interested in seeing how the writing works if you need it.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd Just to clarify, it is still the expectation though that you should use manual cache updating after mutations / incoming subscriptions, correct? Recently I started to receive JSON `missingValue` errors in my cache updates and I'm not sure if it has anything to do with the major architectural changes that have been going on. ","author":{"__typename":"User","login":"Nickersoft","id":"MDQ6VXNlcjIxMDQxMjk=","name":"Tyler Nickerson"}},{"__typename":"IssueComment","body":"Subscriptions don't hit the cache at all at the moment - I wasn't part of that decision but it makes sense from a standpoint of \"This is constantly changing information, we don't necessarily want to cache all of it\", and also from a performance standpoint. So yes, that you'd need to do manually.\r\n\r\nMutation results can update the cache, though if you're not using a `cacheKeyForObject` function that says the cache key should be based on a unique identifier, you will need to update any related queries manually. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Can't update the RequestBodyCreator for WebSocketTransport","author":{"__typename":"User","login":"lowki93","id":"MDQ6VXNlcjU0NzMwMTc=","name":"budain"},"body":"## Bug report\r\n\r\nWe use `WebSocketTransport` and we need to override the `requestBodyCreator` parameters.\r\nWe define `CustomBodyCreator`:\r\n```\r\nstruct CustomBodyCreator: RequestBodyCreator {\r\n \r\n public func requestBody(\r\n for operation: Operation,\r\n sendOperationIdentifiers: Bool\r\n ) -> GraphQLMap {\r\n .....\r\n }\r\n \r\n}\r\n\r\n```\r\n\r\nwe put it when we initialize the `WebSocketTransport`: \r\n```\r\n WebSocketTransport(request: request, requestBodyCreator: CustomBodyCreator())\r\n```\r\n\r\nThe method call in `WebSocketTransport` don't use the method define in the procotol :\r\n```\r\n func sendHelper(operation: Operation, resultHandler: @escaping (_ result: Result) -> Void) -> String? {\r\n let body = requestBodyCreator.requestBody(for: operation, sendOperationIdentifiers: self.sendOperationIdentifiers)\r\n ....\r\n return sequenceNumber\r\n }\r\n```\r\nBut `requestBody` from our struct is never call.\r\n\r\nThere is a an extension for `RequestBodyCreator` that define the function in the protocol : \r\n```\r\nextension RequestBodyCreator {\r\n /// Creates a `GraphQLMap` out of the passed-in operation\r\n ///\r\n /// - Parameters:\r\n /// - operation: The operation to use\r\n /// - sendOperationIdentifiers: Whether or not to send operation identifiers. Defaults to false.\r\n /// - sendQueryDocument: Whether or not to send the full query document. Defaults to true.\r\n /// - autoPersistQuery: Whether to use auto-persisted query information. Defaults to false.\r\n /// - Returns: The created `GraphQLMap`\r\n public func requestBody(for operation: Operation,\r\n sendOperationIdentifiers: Bool = false,\r\n sendQueryDocument: Bool = true,\r\n autoPersistQuery: Bool = false) -> GraphQLMap {\r\n.....\r\n}\r\n```\r\n\r\nWhy can put this default implementation in `ApolloRequestBodyCreator` directly ?\r\n```\r\n// Helper struct to create requests independently of HTTP operations.\r\npublic struct ApolloRequestBodyCreator: RequestBodyCreator {\r\n // Internal init methods cannot be used in public methods\r\n public init() { }\r\n}\r\n```\r\n\r\nWhy we can't override this ?\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.0.1\r\n- Swift version: 5.2 \r\n\r\n## Further details\r\n\r\nWe need to override this to make `WebSocketTransport`with `AppSync`from AWS","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi, apologies for the delay, I was under the weather. \r\n\r\nYou can't override `ApolloRequestBodyCreator` because it's not intended to be overridden - that's why `RequestBodyCreator` is a protocol with a default implementation: That way your custom implementation can use the default implementation without having to implement it yourself if you don't need to. \r\n\r\nThat being said, there've been some changes to this class recently (mostly, removing all the stuff that was going on for uploads) that might make changes make sense. \r\n\r\nI'm not sure why your custom implementation wouldn't be getting called - I would double check that the request creator is being passed in everywhere you expect it to be by setting some breakpoints and validating whether you've got your `CustomRequestCreator` or an `ApolloRequestBodyCreator`, and then working backwards to try to figure out where things are going wrong. If it is the custom request creator, that's definitely a bug. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"OK updating a test, I am now seeing the issue you're having - looks like something I gave [literally an entire talk on](https://speakerdeck.com/designatednerd/protocols-all-the-way-down-dotswift-paris-january-2018?slide=63) just came to bite me because I have angered the gods of iOS development 🤦‍♀️ \r\n\r\nThe issue is the default implementation is getting called even if it's overridden when the only type the compiler knows about is the protocol itself. \r\n\r\nUnfortunately I think the approach in #1448 is going to break things too hard - it removes the ability for anyone to use the default implementation at all. I will make some changes with some tests to validate it works though. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"This has shipped with `0.35.0`. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Am running to this error `Cannot find 'HTTPNetworkTransport' in scope` and `Cannot find type 'HTTPNetworkTransportDelegate' in scope` when am trying to make calls, ApolloClient Version 0.34.1","author":{"__typename":"User","login":"gbrigens","id":"MDQ6VXNlcjQyMTAxNTY=","name":"Гералд Бирген"},"body":"Am running to this error `Cannot find 'HTTPNetworkTransport' in scope` and `Cannot find type 'HTTPNetworkTransportDelegate' in scope` when am trying to make calls, ApolloClient Version 0.34.1\r\n\r\nHere is my code;\r\n```\r\nfinal class Network {\r\n static let shared = Network()\r\n private lazy var networkTransport: NetworkTransport = {\r\n \r\n let transport = HTTPNetworkTransport(url: URL(string: \"https://exampe.com/grapghql\")!)\r\n transport.delegate = self\r\n \r\n return transport\r\n }()\r\n \r\n private(set) lazy var apollo = ApolloClient(networkTransport: self.networkTransport)\r\n}\r\n\r\nextension Network: HTTPNetworkTransportDelegate {\r\n func networkTransport(_ networkTransport: NetworkTransport, shouldSend request: URLRequest) -> Bool {\r\n return true\r\n }\r\n \r\n func networkTransport(_ networkTransport: NetworkTransport, willSend request: inout URLRequest) {\r\n \r\n let token = \"\"\r\n var headers = request.allHTTPHeaderFields ?? [String: String]()\r\n headers[\"Authorization\"] = \"Bearer \\(token)\"\r\n \r\n request.allHTTPHeaderFields = headers\r\n }\r\n}\r\n```\r\nI appreciate your feedback.\r\n\r\n_Originally posted by @gbrigens in https://github.com/apollographql/apollo-ios/issues/909#issuecomment-706535757_","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Hi! In 0.34.0 after an RFC and multiple betas, we released an updated networking stack which removed these methods in favor of a `RequestChainNetworkTransport`. Please see the [0.34.0 release notes](https://github.com/apollographql/apollo-ios/releases/tag/0.34.0) for links to updated documentation.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd this is my first time working with Apolloclient and GraphQL. I have ted the one from the link still running into errors `Cannot find 'NetworkInterceptorProvider' in scope`... Do you have an example that shows passing authorization headers?","author":{"__typename":"User","login":"gbrigens","id":"MDQ6VXNlcjQyMTAxNTY=","name":"Гералд Бирген"}},{"__typename":"IssueComment","body":"Yes, the [tutorial bit on additional mutations](https://www.apollographql.com/docs/ios/tutorial/tutorial-mutations/) has an example","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd thank you for your help, hope in future there will be more tutorials on iOS. I have been searching for content online and there isn't much compared to Android.","author":{"__typename":"User","login":"gbrigens","id":"MDQ6VXNlcjQyMTAxNTY=","name":"Гералд Бирген"}},{"__typename":"IssueComment","body":"Yes, definitely in the long term plan to beef that up.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Cannot query field \"currencyTypes\" on type \"Query\".","author":{"__typename":"User","login":"Hazem-Mohammed","id":"MDQ6VXNlcjU1Mjk4MDg0","name":null},"body":"Hello all,\r\n\r\nThis is my first time to work with GraphQl and i have a very weird issue if i try to add any new query to my .graphql file i get error Cannot query field on type\r\ni faced this issue once and the solution was simply download the new schema file and it is work just fine now it doesn't work and if the Backend add any new query and i try to use it i get the same error even after update the schema file.\r\n\r\nnow i have the same issue again and i have tried almost everything:\r\n1- remove schema and download the new one.\r\n2- remove the (Generate Apollo GraphQL API) and add it again\r\n3- remove apollo SDK and reinstall it (cocoapods)\r\n4- update apollo SDK to the latest version\r\n5- make sure the schema have the new query's (works fine with the android)\r\n\r\n1- screenshot from Altair GraphQl Client:\r\n\"Screen\r\n\r\n\r\n2- screenshot from Xcode:\r\n\"Screen\r\n\"Screen\r\n\r\n3- screenshot from schema file this one show that the query is there.\r\n\"Screen\r\n\r\n4- screenshot from .graphql file:\r\n\"Screen\r\n\r\ni really don't know what is the issue here i have tried to clean project file , restart Xcode, restart Mac and the 5 steps mentioned above with no result and the same schema file work just fine with the android team.\r\n\r\nany help will be much appreciated \r\n- `apollo-ios` SDK version: 0.33.0\r\n- Xcode version: 11.6\r\n- Swift version: 5","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"finally i solved the issue.\r\ni was downloading the schema file from terminal using this command:\r\napollo schema:download --endpoint=https://myEndPoint schema.json\r\n\r\nthat was working with me in past but for some unknown reason using this command cause the problem\r\n\r\nThe solution:\r\nDownload schema using CLI script:\r\nSCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\ncd \"${SRCROOT}/${TARGET_NAME}\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh schema:download --endpoint=http://myEndPoint schema.json\r\n","author":{"__typename":"User","login":"Hazem-Mohammed","id":"MDQ6VXNlcjU1Mjk4MDg0","name":null}}]}},{"__typename":"Issue","title":"Crash in Alamofire","author":{"__typename":"User","login":"tspecht","id":"MDQ6VXNlcjYwMzE0NA==","name":null},"body":"## Bug report\r\n\r\nSince upgrading to the latest `0.34.0` release line with the revamped networking stack, we are seeing intermittent failures in conjunction with Alamofire. Is this a known issue?\r\n\r\n```\r\nCode Type: X86-64 (Native)\r\nParent Process: launchd_sim [2352]\r\nResponsible: SimulatorTrampoline [2256]\r\nUser ID: 501\r\n\r\nDate/Time: 2020-10-13 14:15:09.012 +0000\r\nOS Version: Mac OS X 10.15.5 (19F101)\r\nReport Version: 12\r\nAnonymous UUID: 4763FA26-E06C-409D-9FAC-0174438B0AC7\r\n\r\n\r\nTime Awake Since Boot: 2500 seconds\r\n\r\nSystem Integrity Protection: disabled\r\n\r\nCrashed Thread: 7 Dispatch queue: org.alamofire.session.rootQueue\r\n\r\nException Type: EXC_BAD_ACCESS (SIGSEGV)\r\nException Codes: KERN_INVALID_ADDRESS at 0x000027b7a55693a0\r\nException Note: EXC_CORPSE_NOTIFY\r\n\r\nTermination Signal: Segmentation fault: 11\r\nTermination Reason: Namespace SIGNAL, Code 0xb\r\nTerminating Process: exc handler [6910]\r\n\r\nVM Regions Near 0x27b7a55693a0:\r\n mapped file 000000011638b000-000000011caba000 [103.2M] r--/rwx SM=COW Object_id=254d583f\r\n--> \r\n MALLOC_NANO 0000600000000000-0000600008000000 [128.0M] rw-/rwx SM=ALI \r\n\r\nApplication Specific Information:\r\nCoreSimulator 704.12.2 - Device: iPhone 11 (********-****-****-****-************) - Runtime: iOS 13.7 (17H22) - DeviceType: iPhone 11\r\n\r\nThread 7 Crashed:: Dispatch queue: org.alamofire.session.rootQueue\r\n0 libobjc.A.dylib \t0x00007fff512b7c6a objc_retain + 10\r\n1 com.apple.Foundation \t0x00007fff259243bf NSKeyValueWillChange + 510\r\n2 com.apple.Foundation \t0x00007fff25923ff7 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 487\r\n3 com.apple.Foundation \t0x00007fff259249f2 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 68\r\n4 com.apple.Foundation \t0x00007fff2591f6da _NSSetLongLongValueAndNotify + 269\r\n5 com.apple.CFNetwork \t0x00007fff230f3bfc 0x7fff22f52000 + 1711100\r\n6 com.apple.Foundation \t0x00007fff2594f28c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7\r\n7 com.apple.Foundation \t0x00007fff2594f1ad -[NSBlockOperation main] + 80\r\n8 com.apple.Foundation \t0x00007fff259520dc __NSOPERATION_IS_INVOKING_MAIN__ + 17\r\n9 com.apple.Foundation \t0x00007fff2594e3ee -[NSOperation start] + 731\r\n10 com.apple.Foundation \t0x00007fff25952a20 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 17\r\n11 com.apple.Foundation \t0x00007fff25952540 __NSOQSchedule_f + 182\r\n12 libdispatch.dylib \t0x00007fff520e9344 _dispatch_block_async_invoke2 + 83\r\n13 libdispatch.dylib \t0x00007fff520dc8cb _dispatch_client_callout + 8\r\n14 libdispatch.dylib \t0x00007fff520e260c _dispatch_lane_serial_drain + 707\r\n15 libdispatch.dylib \t0x00007fff520e3044 _dispatch_lane_invoke + 388\r\n16 libdispatch.dylib \t0x00007fff520ed0c4 _dispatch_workloop_worker_thread + 626\r\n17 libsystem_pthread.dylib \t0x00007fff52301a3d _pthread_wqthread + 290\r\n18 libsystem_pthread.dylib \t0x00007fff52300b77 start_wqthread + 15\r\n```\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: `0.34.0`\r\n- Xcode version: 11.7 as well as 12.0\r\n- Swift version: 5.1 as well as 5.3\r\n\r\n## Steps to reproduce\r\n\r\nHappens intermittently, hard to come up with exact steps.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"That's a new one on me - under the hood we're using the same `URLSessionClient` that wraps `URLSession` as we were previously, so there shouldn't be anything messing with `URLSession` that wasn't already happening before. \r\n\r\nThe crash is happening on the Alamofire queue, but it looks like it's happening pretty deep within foundation when a block operation tries to change a value and it triggers KVO, and then something blows up. \r\n\r\nFew questions:\r\n- Have you seen this happen on device or just on sim? \r\n- Have you cleaned your build folder since this happened? \r\n- Did Alamofire also update versions or is it still an older version?\r\n- Are you using the apollo-alamofire wrapper (which is totally separate from this repo) or are you just using AF in parallel to what we're doing? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I see several people have 👍'd this - any further details from anyone would be helpful","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd we have been doing some more experiments on our end, the common denominator so far seems to be recent versions of Firebase. We opened a separate issue in their repository hoping to get some insights on that, would be helpful to know if any of the other users upvoting this here are also using Firebase in their projects. Wondering if there might be some method swizzling going on somewhere? 🤔 \r\n\r\nhttps://github.com/firebase/firebase-ios-sdk/issues/6734","author":{"__typename":"User","login":"tspecht","id":"MDQ6VXNlcjYwMzE0NA==","name":null}},{"__typename":"IssueComment","body":"Oh interesting - yes that definitely seems plausible. For what it's worth our codebase is entirely in Swift, which doesn't completely prevent us from using swizzling but does make it way more of a pain. Either way, we do not use any swizzling. \r\n\r\nFor others running into this issue, are you also using Firebase? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I am also using Firebase","author":{"__typename":"User","login":"ethan021021","id":"MDQ6VXNlcjE1MzI5NjU4","name":"Ethan"}},{"__typename":"IssueComment","body":"OK - since the stack trace doesn't show anything from the Apollo API, we're not doing any swizzling that could cause the crashes in the stack trace, and there seems to be an issue with the Firebase SDK and other people having this issue seem to also be using Firebase, I'm going to close this issue and direct folks to the [Firebase issue where this is being discussed in significantly more detail](https://github.com/firebase/firebase-ios-sdk/issues/6734). \r\n\r\nThanks all for the heads up on this!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"run-bundled-codegen.sh: No such file or directory","author":{"__typename":"User","login":"mobile-simformsolutions","id":"MDQ6VXNlcjYzMjI1OTEz","name":null},"body":"## run-bundled-codegen.sh: No such file or directory\r\n\r\ni'm implementing this demo as per the documentation (https://www.apollographql.com/docs/ios/tutorial/tutorial-obtain-schema) but after adding script into build phase it will showing me this error:\r\n\r\n**Command PhaseScriptExecution failed with a nonzero exit code**\r\n**Script-3E447D9625386A88004AD507.sh: line 10: /run-bundled-codegen.sh: No such file or directory\r\nCommand PhaseScriptExecution failed with a nonzero exit code**\r\n\r\n![Screenshot 2020-10-16 at 10 32 30 AM](https://user-images.githubusercontent.com/63225913/96215184-e8337a00-0f9a-11eb-8a38-b02591340731.png)\r\n\r\n## Versions\r\n0.34.1\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.0.1\r\n- Swift version: 5","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It looks like you may have skipped step 6, in which you add the build script where the script path is retrieved. It links to [these instructions](https://www.apollographql.com/docs/ios/installation/#adding-a-code-generation-build-step) which are separated out by package manager. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"got it thanks but one suggestion for documentation please make one section where whole script was there.","author":{"__typename":"User","login":"mobile-simformsolutions","id":"MDQ6VXNlcjYzMjI1OTEz","name":null}},{"__typename":"IssueComment","body":"Appreciate the feedback - for what it's worth the reason it's linked is because those instructions had been changing enough that having it in two places meant that it was going to constantly get out of sync. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Help wanted migrating to new Networking stack","author":{"__typename":"User","login":"taher-mosbah","id":"MDQ6VXNlcjIzMDAwODc=","name":"Mohamed Taher Mosbah"},"body":"## Question\r\nGreetings 👋 \r\n\r\nWe are trying to update our custom implementation of a `NetworkTransport` to the new networking stack in version 0.34 but can't seem to figure out where to start, we took a look at the release notes and the documentation `RequestChainNetworkTransport` seems promising but can't figure out how to achieve the same results.\r\n\r\nHere is the current implementation:\r\n\r\n```\r\nimport Foundation\r\nimport Apollo\r\n\r\n/// A network transport that uses HTTP POST requests to send GraphQL operations to a server, and that uses `URLSession` as the networking implementation.\r\npublic class ApolloHTTPGETNetworkTransport: NetworkTransport {\r\n public enum NetworkError: Swift.Error {\r\n case invalidURLComponents\r\n }\r\n\r\n let url: URL\r\n let session: URLSession\r\n let serializationFormat = JSONSerializationFormat.self\r\n let jsonEncoder = JSONEncoder()\r\n\r\n /// Creates a network transport with the specified server URL and session configuration.\r\n ///\r\n /// - Parameters:\r\n /// - url: The URL of a GraphQL server to connect to.\r\n /// - configuration: A session configuration used to configure the session. Defaults to `URLSessionConfiguration.default`.\r\n /// - sendOperationIdentifiers: Whether to send operation identifiers rather than full operation text, for use with servers that support query persistence. Defaults to false.\r\n public init(url: URL, configuration: URLSessionConfiguration = URLSessionConfiguration.default, sendOperationIdentifiers: Bool = false) {\r\n self.url = url\r\n self.session = URLSession(configuration: configuration)\r\n self.sendOperationIdentifiers = sendOperationIdentifiers\r\n }\r\n\r\n /// Send a GraphQL operation to a server and return a response.\r\n ///\r\n /// - Parameters:\r\n /// - operation: The operation to send.\r\n /// - completionHandler: A closure to call when a request completes.\r\n /// - response: The response received from the server, or `nil` if an error occurred.\r\n /// - error: An error that indicates why a request failed, or `nil` if the request was successful.\r\n /// - Returns: An object that can be used to cancel an in progress request.\r\n public func send(operation: Operation, completionHandler: @escaping (Result, Error>) -> Void) -> Cancellable where Operation: GraphQLOperation {\r\n let query = requestBody(for: operation)\r\n guard var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else {\r\n completionHandler(.failure(NetworkError.invalidURLComponents))\r\n return EmptyCancellable()\r\n }\r\n urlComponents.queryItems = query.compactMap { queryMapItem -> URLQueryItem? in\r\n guard let queryMapItemValue = queryMapItem.value else { return nil }\r\n if let queryMapItemValue = queryMapItemValue as? JSONObject {\r\n guard let queryItemValue = ((try? String(data: JSONSerializationFormat.serialize(value: queryMapItemValue), encoding: .utf8)) as String??) else { return nil }\r\n return URLQueryItem(name: queryMapItem.key, value: queryItemValue)\r\n }\r\n if let queryMapItemValue = queryMapItemValue as? String {\r\n return URLQueryItem(name: queryMapItem.key, value: queryMapItemValue)\r\n }\r\n return nil\r\n }\r\n\r\n var request = URLRequest(url: url)\r\n request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\r\n request.httpMethod = \"GET\"\r\n request.url = urlComponents.url\r\n let task = session.dataTask(with: request) { (data: Data?, response: URLResponse?, error: Swift.Error?) in\r\n if let error = error {\r\n completionHandler(.failure(error))\r\n return\r\n }\r\n\r\n guard let httpResponse = response as? HTTPURLResponse else {\r\n fatalError(\"Response should be an HTTPURLResponse\")\r\n }\r\n\r\n if !httpResponse.isSuccessful {\r\n completionHandler(.failure(GraphQLHTTPResponseError(body: data, response: httpResponse, kind: .errorResponse)))\r\n return\r\n }\r\n\r\n guard let data = data else {\r\n completionHandler(.failure(GraphQLHTTPResponseError(body: nil, response: httpResponse, kind: .invalidResponse)))\r\n return\r\n }\r\n\r\n do {\r\n guard let body = try self.serializationFormat.deserialize(data: data) as? JSONObject else {\r\n throw GraphQLHTTPResponseError(body: data, response: httpResponse, kind: .invalidResponse)\r\n }\r\n let response = GraphQLResponse(operation: operation, body: body)\r\n completionHandler(.success(response))\r\n } catch {\r\n completionHandler(.failure(error))\r\n }\r\n }\r\n\r\n task.resume()\r\n\r\n return task\r\n }\r\n\r\n private let sendOperationIdentifiers: Bool\r\n\r\n private func requestBody(for operation: Operation) -> GraphQLMap {\r\n if sendOperationIdentifiers {\r\n guard let operationIdentifier = operation.operationIdentifier else {\r\n preconditionFailure(\"To send operation identifiers, Apollo types must be generated with operationIdentifiers\")\r\n }\r\n return [\"id\": operationIdentifier, \"variables\": operation.variables]\r\n }\r\n return [\"query\": operation.queryDocument, \"variables\": operation.variables]\r\n }\r\n}\r\n\r\nfileprivate extension HTTPURLResponse {\r\n var isSuccessful: Bool {\r\n return (200..<300).contains(statusCode)\r\n }\r\n\r\n var statusCodeDescription: String {\r\n return HTTPURLResponse.localizedString(forStatusCode: statusCode)\r\n }\r\n\r\n var textEncoding: String.Encoding? {\r\n guard let encodingName = textEncodingName else { return nil }\r\n\r\n return String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding(encodingName as CFString)))\r\n }\r\n}\r\n\r\n```\r\n\r\nfeel free to ask me any questions about the code and thanks for your time !\r\n\r\n## Versions\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 120.1\r\n- Swift version: 5.3","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"So it looks like you could probably get to this point with what you're doing by passing in a custom `RequestBodyCreator` to `RequestChainNetworkTransport` and then setting the `useGETForQueries` parameter to `true` - I believe almost all the rest of this is handled for you automatically in the RCNT otherwise.\r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@taher-mosbah Anything else I can help with here? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"thanks for your answer, it's clear will try to implement as soon as I got the time 😄 ","author":{"__typename":"User","login":"taher-mosbah","id":"MDQ6VXNlcjIzMDAwODc=","name":"Mohamed Taher Mosbah"}}]}},{"__typename":"Issue","title":"Swift scripting error with xcode 12","author":{"__typename":"User","login":"jdevng","id":"MDQ6VXNlcjI2ODE3NDEw","name":null},"body":"## Bug report\r\n\r\nInitialization of Codegen directory at \r\n\r\nhttps://www.apollographql.com/docs/ios/swift-scripting/\r\n\r\nresults in error.\r\n\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.35\r\n- Xcode version: 12.0.1\r\n- Swift version: Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)\r\n\r\n## Steps to reproduce\r\n```\r\n\r\n% swift packet init --type executable\r\nerror: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-packet (No such file or directory)\r\n```\r\n\r\n\r\n## Further details\r\n\r\nPlease replace this line with any further details or context necessary to understand the problem. Delete this section if you don't have anything further to add.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I think you mean `swift package --init` rather than `swift packet --init`","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I'm blind. Will delete :) Thank you. Should learn to copy!","author":{"__typename":"User","login":"jdevng","id":"MDQ6VXNlcjI2ODE3NDEw","name":null}}]}},{"__typename":"Issue","title":"set the timeout of the ApolloCodegenLib","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"},"body":"I am following the guide to download zip file with CLI.\r\nHow can I set the timeout of the ApolloCodegenLib:CLIDownloader ?\r\nMy network is so bad :(\r\n\r\n```\r\nswift run\r\n[DEBUG - ApolloCodegenLib:CLIDownloader.swift:72] - Downloading zip file with the CLI...\r\ndownloadTimedOut(after: 30.0)\r\n```","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"For anyone stumbling across this, all of the methods to call into the codegen lib should have a `timeout` parameter. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Create WebsocketTransport without connecting automatically","author":{"__typename":"User","login":"winstondu","id":"MDQ6VXNlcjgxNzQzMTA=","name":"Winston Du"},"body":"## Feature request\r\n\r\nCurrently, the designated initializer for the WebSocketTransport[ immediately connects the websocket. ](https://github.com/apollographql/apollo-ios/blob/cf537701e407bed1a13df6dd6288d641abdda42a/Sources/ApolloWebSocket/WebSocketTransport.swift#L128)\r\n\r\nWe wish to manually control when it does its first connection.\r\n\r\n## Motivation\r\n\r\nWe want to our app's webservers to able to handle load, and at high traffic times we actually want the ability to disable automatic websocket connections to our server at app startup.\r\n\r\n## Proposed solution\r\n\r\nAdd a parameter to the [designated initializer](https://github.com/apollographql/apollo-ios/blob/cf537701e407bed1a13df6dd6288d641abdda42a/Sources/ApolloWebSocket/WebSocketTransport.swift#L128) on whether the websocket should connect immediately on initialization. In otherwords, wrap the `websocket.connect()` call in an `if` statement.\r\n\r\nAdditional notes: \r\nBecause the mutex-locked `reconnect` parameter only comes into play after the the first disconnection (which can only happen after the first connection), that parameter does not affect things.\r\n \r\n## Outstanding Questions\r\n- It is up to the implementor to decide whether there should be a separate api for the first websocket connection, or if the developer can just call `reconnectWebSocket()`","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Seems like a reasonable request, and thank you for adding a PR! I'll keep feedback over on the PR just for the sake of clarity. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"allowSpecificHTTPSCertificateForHost warning in iOS 14","author":{"__typename":"User","login":"DiwakarThapa","id":"MDQ6VXNlcjI5OTE3Nzk5","name":"diwakar thapa"},"body":"I started receiving following warning on Xcode after I update my iPhone to iOS 14. How to fix this warning? \r\n ## Warning\r\nnil host used in call to allowSpecificHTTPSCertificateForHost: \r\nnil host used in call to allowAnyHTTPSCertificateForHost:\r\nnil host used in call to allowSpecificHTTPSCertificateForHost: \r\nnil host used in call to allowAnyHTTPSCertificateForHost:\r\n\r\n## Network Transport \r\nprivate var networkTransport: HTTPNetworkTransport {\r\n let configuration = URLSessionConfiguration.default\r\n configuration.timeoutIntervalForResource = 65\r\n configuration.timeoutIntervalForRequest = 65\r\n let client = URLSessionClient(sessionConfiguration: configuration)\r\n let transport = HTTPNetworkTransport(url: URL(string: self.baseUrl)!, client: client)\r\n transport.delegate = self\r\n return transport\r\n }\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.30.0\r\n- Xcode version: 11.2.1\r\n- Swift version: 5","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Wow, weird! Never seen that before. We're not doing anything that I'm aware of that should be calling any of those methods. \r\n\r\nWould be curious if this is still happening in versions `0.34.0` and above - we made some pretty significant changes to the networking stack there. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@DiwakarThapa Is there any further information you can share here? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since I haven't heard back in a couple weeks, I'm going to close this out - @DiwakarThapa if you get more info feel free to reopen. Anyone else with a similar problem, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Initializer default values make it very easy to accidentally create 2 distinct ApolloStore's","author":{"__typename":"User","login":"namolnad","id":"MDQ6VXNlcjYxNDg0ODA=","name":"Dan Loman"},"body":"## Bug report\r\n\r\nCurrently it's very easy, through default initializer values, to end up with multiple ApolloStore's and the inability to properly invalidate your cache. I just spent a fair amount of time debugging this issue, which I think could be resolved by removing some default values in one or both the `ApolloClient`'s and `LegacyInterceptorProvider`'s initializers. The problem is as follows:\r\n\r\n``` swift\r\nlet interceptorProvider: LegacyInterceptorProvider = .init() // More likely to use your own subclass for authentication\r\nlet transport: RequestChainNetworkTransport = .init(\r\n interceptorProvider: interceptorProvider,\r\n endpointURL: baseUrl.appendingPathComponent(\"graphql\")\r\n)\r\nlet client: ApolloClient = .init(\r\n networkTransport: transport\r\n)\r\n```\r\n\r\nThe above code creates two separate `ApolloStore`'s with default caches of `InMemoryNormalizedCache()` for both the `LegacyInterceptorProvider` and for the `ApolloClient`. When going to invalidate your cache here, you will invalidate one of the caches (the ApolloStore one), but the InterceptorProvider's cache will remain untouched, which is where results seem to be fetched from, thus making it impossible to actually invalidate the cache. Without these default values, I believe this problem would be obvious to the developer.\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.0\r\n- Xcode version: 12.0.1\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nInitialize the ApolloClient using default values, as above.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Yeah this is basically a dupe of #1438 - I'm going to take a look at your solution, I was still pondering exactly how to get this set up in a friendlier way. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yup, definitely a dupe — sorry for missing that and thanks for taking a look!","author":{"__typename":"User","login":"namolnad","id":"MDQ6VXNlcjYxNDg0ODA=","name":"Dan Loman"}},{"__typename":"IssueComment","body":"This has shipped with `0.36.0`!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"graphql file with description","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"},"body":"Any way to add description to graphql file? This results in errors in compile time.\r\n\r\nA good example would be:\r\n\r\n```\r\n\"\"\"\r\nA simple GraphQL schema which is well described.\r\n\"\"\"\r\nschema {\r\n query: Query\r\n}\r\n```\r\n\r\nhttp://spec.graphql.org/draft/#sec-Descriptions\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"In theory that should not result in errors - can you give an example of a file where this is resulting in errors, along with the errors? Any information around your setup would also be really helpful. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Just add \r\n\r\n \"\"\"\r\n A simple GraphQL schema which is well described.\r\n \"\"\"\r\n\r\nto the first line of any .graphql file and Build then you will see the error.\r\n\r\n Showing Recent Messages\r\n Error: Syntax error in \r\n\r\n file:///Users/mac/a.graphql: Syntax \r\n\r\n Error: Unexpected Name \"query\".\r\n\r\n","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"}},{"__typename":"IssueComment","body":"Are you trying to add this to your operation graphQL files, or to the Schema graphQL file? This syntax is intended for the schema - you can see an example in [the version of the GitHub Schema we're using for some tests](https://github.com/apollographql/apollo-ios/blob/main/Sources/GitHubAPI/schema.docs.graphql). \r\n\r\nIf you were to try to add this to an operation's graphQL file like: \r\n\r\n```graphQL\r\n\"\"\"\r\nA simple GraphQL schema which is well described.\r\n\"\"\"\r\nquery UserInfo($id: ID!) {\r\n user(id: $id) {\r\n name\r\n }\r\n}\r\n```\r\n\r\nThat would not compile. Does that help? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@wongzigii Any thoughts on my response? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Good to know! Thanks @designatednerd ","author":{"__typename":"User","login":"wongzigii","id":"MDQ6VXNlcjczODQyODg=","name":"Zigii Wong"}}]}},{"__typename":"Issue","title":"Is there any way to have a hybrid cache instead of memory/disk exclusively?","author":{"__typename":"User","login":"malonehedges","id":"MDQ6VXNlcjEyMDkyMjk2","name":"Malone Hedges"},"body":"Is there any official (or community) support for a hybrid cache for Apollo iOS?","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Not at this time but I have had at least one customer talk to us about this. We're gonna be doing some heavy work around the cache in the next couple months but probably after that we can take a look. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Awesome, would love to adopt a hybrid cache when one is available","author":{"__typename":"User","login":"malonehedges","id":"MDQ6VXNlcjEyMDkyMjk2","name":"Malone Hedges"}}]}},{"__typename":"Issue","title":"some thoughts on Interceptors","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"},"body":"## Feedback\r\n\r\nI just update from 0.33.0 to 0.36.0 and want to share some thoughts on Interceptors.\r\n\r\n- confusing what does proceedAsync, handleErrorAsync, retry and kickoff do. If I have error in response and want to retry do I call retry? or kickoff?\r\n- `Request`ChainNetworkTransport but you pass response Interceptors to it (as request and response interceptors are the same list)\r\n- confusing that same call used for request and response, only way to check for response == nil in `interceptAsync`\r\n- `TokenAddingInterceptor` from docs adds Authorization header to request not depending if its request or response. Is that how it should be?\r\n- `RequestChainNetworkTransport` have `additionalHeaders` - shouldn't this be interceptor?\r\n- there is `AutomaticPersistedQueryInterceptor` and also `autoPersistQueries` on `RequestChainNetworkTransport` what should I use?\r\n- There is `LegacyInterceptorProvider` but something not \"legacy\" (`NetworkInterceptorProvider`) only mentioned in documentation. How do I create custom provider where I add only my interceptors and leave \"default\" ones untouched? `NetworkInterceptorProvider` from docs have 10 interceptors, `LegacyInterceptorProvider` have 7. Should I inherit from `LegacyInterceptorProvider` or should I copy one from docs and constantly track if new Interceptor will just appear in the list?\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36.0\r\n- Swift version: 5.3","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"comment about `TokenAddingInterceptor` is invalid as it is inserted in first place (so it can't be response)","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"> confusing what does proceedAsync, handleErrorAsync, retry and kickoff do. If I have error in response and want to retry do I call retry? or kickoff?\r\n\r\n- `proceedAsync` is called anytime you want to have the chain proceed to the next interceptor\r\n- `handleErrorAsync` is called anytime you want to have the chain return an error to the original caller\r\n- `kickoff` should only be called by you when you want to start the chain from scratch.\r\n- `retry` should be called if you want to retry a request - it will [reset the interceptor index under the hood and call `kickoff` to restart the chain](https://github.com/apollographql/apollo-ios/blob/9c624bbcfa1c8b3b909ee0c53ec43ebb1a50e944/Sources/Apollo/RequestChain.swift#L129). You should use this method rather than trying to reset the index yourself. Basically, don't call `kickoff` on the chain from within an interceptor, call `retry`. \r\n\r\n> RequestChainNetworkTransport but you pass response Interceptors to it (as request and response interceptors are the same list) confusing that same call used for request and response, only way to check for response == nil in interceptAsync\r\n\r\nI'm not totally clear on what the question here is - is it \"Why are we using the same interceptors for preparing a request as handling a response?\" If yes, please confirm, if not, please clarify. Thanks. \r\n\r\n> TokenAddingInterceptor from docs adds Authorization header to request not depending if its request or response. Is that how it should be?\r\n\r\nYes - the idea of that is that you put it first so that it is the first change applied before a request goes out. \r\n\r\n> RequestChainNetworkTransport have additionalHeaders - shouldn't this be interceptor?\r\n\r\nThese are intended to be additional headers that must be added to every single request, and which do not change (for example, an API key or a language setting). The interceptors are intended for things which may change (for example, a user's authentication token). \r\n\r\n> there is AutomaticPersistedQueryInterceptor and also autoPersistQueries on RequestChainNetworkTransport what should I use?\r\n\r\nThe short answer is both - `autoPersistQueries` tells you whether auto-persisted queries should be used at all, and the interceptor does the work of checking for APQ-related errors and auto-retrying when needed. Essentially, `autoPersistQueries` tells you if you should send APQ hashes outgoing, and the interceptor handles incoming responses to tell if you need to retry due to an APQ failure. \r\n\r\n> There is LegacyInterceptorProvider but something not \"legacy\" (NetworkInterceptorProvider) only mentioned in documentation. How do I create custom provider where I add only my interceptors and leave \"default\" ones untouched? NetworkInterceptorProvider from docs have 10 interceptors, LegacyInterceptorProvider have 7. Should I inherit from LegacyInterceptorProvider or should I copy one from docs and constantly track if new Interceptor will just appear in the list?\r\n\r\nYou _can_ inherit from `LegacyInterceptorProvider`, and override the method providing the array of interceptors. This is easier if you're putting interceptors at the beginning or end of the array rather than interspersing them throughout. If they're interspersed, it's likely better create your own implementation of `InterceptorProvider` and using the array provided by `LegacyInterceptorProvider` as a starting point. \r\n\r\nI will call out in release notes if any changes are made to the `LegacyInterceptorProvider`, particularly new interceptors - the intent is that the core interceptors should not change. \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I was going through a similar thinking process as @RolandasRazma yesterday doing the same 0.33->0.36 migration. Would be super helpful if you added these explanations to the documentation for other people. ","author":{"__typename":"User","login":"Nealsoni00","id":"MDQ6VXNlcjcwMTMxOTE=","name":"Neal Soni"}},{"__typename":"IssueComment","body":"Have y'all had a chance to read through [the updated client creation documentation](https://www.apollographql.com/docs/ios/initialization/#advanced-client-creation), particularly the [section on how the request chain works](https://www.apollographql.com/docs/ios/initialization/#how-the-requestchain-works)? I would be particularly interested in where you feel like that's not clear enough. Thanks!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I did, I think for me most confusion would have been averted if:\r\n\r\n- there would be 2 lists: pre server call and post server call having different call signature (no reply in \"pre\" ones)\r\n- there would be no \"Legacy\" in class names as it made not clear what to use\r\n- don't feel feel comfortable of just copying list of \"default\" interceptors as that list might change without the realising","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"> there would be 2 lists: pre server call and post server call having different call signature (no reply in \"pre\" ones)\r\n\r\nOne of the reasons I went with a single chain is we've had repeated feature requests to have the data associated with what was being requested passed through to the completion handler. I will be taking a look at some options based on feedback here, I think maybe there could be some other options that might make `NetworkTransport` unnecessary and allow the user to send data through any transport (ie, send it with a websocket if you really feel like it). \r\n\r\n> there would be no \"Legacy\" in class names as it made not clear what to use\r\n\r\nOK. I believe I tried to explain \"Legacy\" vs \"Codable\" as \"What we've been using\" vs \"What we will be using in the future\" in those docs, but it sounds like that didn't help. I'll try to clarify that.\r\n\r\n> don't feel feel comfortable of just copying list of \"default\" interceptors as that list might change without the realising\r\n\r\nI mean, that's going to be a problem no matter what if you need to intersperse different interceptors - if you're subclassing hte default list and relying on the default order in terms of where to insert your interceptors, that's going to cause problems too. Again, I can certainly commit to making sure I make it very clear in release notes when any of this changes. \r\n","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@RolandasRazma @Nealsoni00 I've just opened a PR with updated docs. Would love your feedback on #1484. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> One of the reasons I went with a single chain is we've had repeated feature requests to have the data associated \r\n\r\nEverything could still work as it does now under the hood. 2 list would allow to not have \"response\" in pre list\r\n\r\n> I mean, that's going to be a problem no matter what\r\n\r\nthat's not necessary true if there would be 2 lists as in most cases you need \"pre action\" and \"post action\"\r\n\r\n\r\nI already migrated and now it's more clear what's going on so I'm not advocating for a change. Most likely all new users will do better as they have no expectations ","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"> 2 list would allow to not have \"response\" in pre list\r\n\r\nThat's fair. \r\n\r\n> I'm not advocating for a change.\r\n\r\nI think if we're gonna make one it's better to do it sooner rather than later, honestly. I also need to think a few things over, to be honest.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"OK, I've merged #1464. I will continue to think about what could work to make it easier to deal with when an interceptor will be called - pre or post response - and see what I can come up with. However, I wanted to check - do you feel there's anything else here that still needs to be directly addressed before we can close this issue out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I will close it","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"@RolandasRazma thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Crash in 0.36.0","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"},"body":"## Bug report\r\n\r\nCrash using interceptors\r\n\r\n\"Screenshot\r\n\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36.0\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nI have TokenAddingInterceptor that retrieves token from server and asynchronously calls `chain.proceedAsync`. I have check for TokenAddingInterceptor being released to not call up the chain on dealloc, so that's not the case.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"The crash is happening in the `URLSessionClient` rather than in any of the interceptors - it looks like the client either a) Hasn't had a chance to set up its `URLSession` or b) has had the session torn down. \r\n\r\nCan you share how you're setting up your `TokenAddingService`? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"There is nothing interesting to see there. It just check for token validity if it it expired updates it from server and calls back. I will try to trace/fix crash as it's blocking us, but as its another race condition its not going to be simple as I can't even replicate it reliably. Sometimes it crashes every run (tests) sometimes I hit https://github.com/apollographql/apollo-ios/issues/1376 and sometimes all tests passes without any problem :)","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"I can replicate it with example from https://www.apollographql.com/docs/ios/tutorial/tutorial-mutations/\r\n\r\n```swift\r\nclass TokenAddingInterceptor: ApolloInterceptor {\r\n func interceptAsync(chain: RequestChain, request: HTTPRequest, response: HTTPResponse?, completion: @escaping (Result, Error>) -> Void) {\r\n DispatchQueue.main.async { [weak self] in\r\n guard self != nil else { return }\r\n chain.proceedAsync(request: request, response: response, completion: completion)\r\n }\r\n }\r\n \r\n}\r\n```","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"This is how memory graph looks for crashing client\r\n\r\n\"Screenshot\r\n","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"NetworkFetchInterceptor:32 don't you need `self.currentTask?.cancel()` before it?\r\n\r\nP.S. adding cancel didn't stop crash, but still, don't you need it there? (made PR https://github.com/apollographql/apollo-ios/pull/1476)","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"Ok, what's happening is that `RequestChain` (created in `RequestChainNetworkTransport`) lifetime is longer than `LegacyInterceptorProvider` and `LegacyInterceptorProvider` does `shouldInvalidateClientOnDeinit` \r\n\r\n`RequestChain` is created in `RequestChainNetworkTransport`, `LegacyInterceptorProvider` is released invalidating client and `RequestChain` knows nothing about it. \r\n\r\nI managed to \"solve\" it by retaining link to chain in `RequestChainNetworkTransport` and canceling it in `deinit` - not sure if that's correct thing to do, as that would imply that I need to cancel it on send as well (or retain all references created by send)","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"sorry for spam @designatednerd ","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"I thought not retaining chain would help\r\n\r\n```swift\r\nclass TokenAddingInterceptor: ApolloInterceptor {\r\n func interceptAsync(chain: RequestChain, request: HTTPRequest, response: HTTPResponse?, completion: @escaping (Result, Error>) -> Void) {\r\n DispatchQueue.main.async { [weak self, weak chain] in\r\n guard self != nil else { return }\r\n chain?.proceedAsync(request: request, response: response, completion: completion)\r\n }\r\n }\r\n \r\n}\r\n```\r\n\r\nbut that's not the case - it is deallocated before we can update token and call to server never executed","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"right - if you let go of the chain there there's nothing hanging on to it, so ARC smashes it. \r\n\r\nI'm surprised the legacy interceptor provider is getting deallocated - that indicates that the Request Chain Network Transport itself is getting deallocated. I would really like to see how you're setting this stuff up for tests - it seems like maybe something is calling into an old instance of RCNT in different tests. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"`RequestChainNetworkTransport` is deallocated, but the problem is not that it is deallocated, the problem is that it doesn't cleanup properly while it does that\r\n\r\n```swift\r\nclass TokenAddingInterceptor: ApolloInterceptor {\r\n func interceptAsync(chain: RequestChain, request: HTTPRequest, response: HTTPResponse?, completion: @escaping (Result, Error>) -> Void) {\r\n DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { [weak self] in\r\n guard self != nil else { return }\r\n chain?.proceedAsync(request: request, response: response, completion: completion)\r\n }\r\n }\r\n}\r\n\r\nlet transport = RequestChainNetworkTransport(...)\r\nlet apolloClient = ApolloClient(networkTransport: transport, ...)\r\napolloClient.fetch(query: ...)\r\n```\r\n\r\nwill make whole app crash in 1 second because `ApolloClient` will be deallocated together with `RequestChainNetworkTransport` while `RequestChain` will be retained by block (and it has to be)\r\n\r\nCrash will happen because deallocatingin `LegacyInterceptorProvider` will call `client.invalidate()` that will nil `URLSessionClient.sesion` and after 1 sec it will be accessed with force unwrap","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"this is the crash https://github.com/apollographql/apollo-ios/pull/1480","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"I guess easy workaround would be to remove force unwrap, but the real problem is that `RequestChain` don't know that it is no longer needed. Correct fix would be to add \"cancel\" for chain in `RequestChainNetworkTransport` as mentioned in https://github.com/apollographql/apollo-ios/issues/1473#issuecomment-717173144 the only difficulty it that there is multiple chains per transport and all of them needs to be cancelled","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"Created PR with workaround https://github.com/apollographql/apollo-ios/pull/1481 but somehow don't fee good about it :) It doe's work, but feels like some code smell","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"should I close this?","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"I'll close it when it actually ships","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"GraphQLError parsing issue in response?.parsedResponse ","author":{"__typename":"User","login":"StanislavCekunov","id":"MDQ6VXNlcjk3NzQ0Nzc=","name":null},"body":"Hello Apollo community,\r\nI am currently updating our codebase to support `RequestChainNetworkTransport` interface. \r\nIn a previous structure I used `HTTPNetworkTransportGraphQLErrorDelegate` to catch `GraphQLError` to initiate access token update and retryHandler to retry faild request. \r\n\r\nWith the new `RequestChain` structure I am perfoming same action inside ResponseCodeInterceptor. Though, `GraphQLError` is not being parced anymore. I am accessing it by `response?.parsedResponse?.errors`\r\n\r\nHere is the response raw data: \r\n`{\"errors\":[{\"message\":\"Access denied\",\"path\":[\"getUserDetails\"],\"locations\":[{\"line\":2,\"column\":1}],\"extensions\":{\"code\":\"accessTokenExpired\"}}],\"data\":null}`\r\n\r\nWould love to get some help or suggestions where is the right way to fetch `GraphQLError` this time.\r\nAm I doing something wrong? \r\nThanks\r\n\r\n## Versions\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36.0\r\n- Swift version: 5.3\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I would probably do this check in an interceptor that runs after `LegacyParsingInterceptor` - that's where the actual parsing takes place, and after it's gone through that inteceptor, you should be able to access it using `response?.parsedResponse?.errors`. \r\n\r\nThe `ResponseCodeInterceptor` that's provided by default is mostly just checking to make sure the response code is something vaguely sane before attempting to parse the result","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Thank you @designatednerd !\r\nI have added a new interceptor `AccessTokenValidationInterceptor` right after `LegacyParsingInterceptor`. \r\nSolved. 🙌 \r\n\r\n","author":{"__typename":"User","login":"StanislavCekunov","id":"MDQ6VXNlcjk3NzQ0Nzc=","name":null}},{"__typename":"IssueComment","body":"@StanislavCekunov Mind if we close this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Using same query with different set of fields","author":{"__typename":"User","login":"vani2","id":"MDQ6VXNlcjQ3MzQ5ODM=","name":"Ivan Vavilov"},"body":"## Question\r\n\r\nI have query of `draftProfile` and `profile`\r\n\r\n```GraphQL\r\nquery fetchProfile {\r\n draftProfile {\r\n firstName\r\n secondName\r\n },\r\n profile {\r\n firstName\r\n secondName \r\n }\r\n}\r\n```\r\n\r\nLater I need to make the same query but only `profile` object.\r\n\r\n```GraphQL\r\nquery fetchProfile {\r\n profile {\r\n firstName\r\n secondName \r\n }\r\n}\r\n``` \r\n\r\nIf I declare these two queries I get the error `There are multiple definitions for the `fetchProfile` operation. Please rename or remove all operations with the duplicated name before continuing.`.\r\n\r\nHow I can make it possible? \r\n\r\n## Versions\r\n\r\n- `apollo-ios` SDK version: 0.35\r\n- Xcode version: 12.0\r\n- Swift version: 5.3","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"You need to give the two queries different names at the `query fetchProfile` point. Maybe `query fetchProfileWithDraft` for that top one and just `fetchProfile` for the bottom one? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Oh, yes, that's easy. Thanks.","author":{"__typename":"User","login":"vani2","id":"MDQ6VXNlcjQ3MzQ5ODM=","name":"Ivan Vavilov"}}]}},{"__typename":"Issue","title":"XCode 12 : Could not find module ‘Apollo’ for target ‘arm64-apple-ios-simulator’; found: x86_64-apple-ios-simulator, x86_64","author":{"__typename":"User","login":"poorvasingh04","id":"MDQ6VXNlcjIwMDkwODU5","name":"Poorva Singh"},"body":"## Bug report\r\n\r\nXCode 12 : Could not find module ‘Apollo’ for target ‘arm64-apple-ios-simulator’; found: x86_64-apple-ios-simulator, x86_64\r\nUnable to build app against iOS simulator using XCode 12.\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.27.1 and 0.36.0\r\n- Xcode version: 12\r\n- Swift version: 5\r\n\r\n## Steps to reproduce\r\nBuild code against iOS simulator. I am using app to build against iOS simulator for UI tests.\r\n\r\n## Further details\r\n\r\nCode fails to compile. I also added following post install script in podfile:\r\n\r\npost_install do |pi|\r\n pi.pods_project.targets.each do |t|\r\n t.build_configurations.each do |config|\r\n config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'\r\n config.build_settings[\"EXCLUDED_ARCHS[sdk=iphonesimulator*]\"] = \"arm64\"\r\n end\r\n end\r\nend\r\n\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"It looks like your post-install script's change `EXCLUDED_ARCHS` is actively excluding the `arm64` type that the compiler is looking for. Is there a particular reason why you're excluding that? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd yes. To compile with Xcode 12 against iOS simulator, we need to exclude arm64 architecture in app and all the linked pods. This is same issue as described here: https://stackoverflow.com/questions/63607158/xcode-12-building-for-ios-simulator-but-linking-in-object-file-built-for-ios","author":{"__typename":"User","login":"poorvasingh04","id":"MDQ6VXNlcjIwMDkwODU5","name":"Poorva Singh"}},{"__typename":"IssueComment","body":"Interesting - there's a related suggestion in there about making sure that `ONLY_ACTIVE_ARCH` is set to yes for your debug setup. In a sample CocoaPods app I've got where that's set up I have not seen this issue.\r\n\r\nI *think* as long as you're not building on a developer transition kit, setting that up should help with this, since it seems like Xcode is trying to build the universe, then complaining that the thing you specifically told it not to build isn't there.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd ONLY_ACTIVE_ARCH is already set to Yes","author":{"__typename":"User","login":"poorvasingh04","id":"MDQ6VXNlcjIwMDkwODU5","name":"Poorva Singh"}},{"__typename":"IssueComment","body":"🤔 That's...very odd if you're not on a developer transition kit. Are you on a developer transition kit? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd no. I am not in a developer transition kit. I am trying to build app against simulator for my UI tests but it fails with Xcode 12.1","author":{"__typename":"User","login":"poorvasingh04","id":"MDQ6VXNlcjIwMDkwODU5","name":"Poorva Singh"}},{"__typename":"IssueComment","body":"Here's a couple other things I can think of that are unlikely but worth checking: \r\n\r\n- If there's more than one target in your project, are all targets in your project set for `ONLY_ACTIVE_ARCH`, or just the main application?\r\n- Is your scheme set to run the tests in release mode rather than debug mode? \r\n- Is there something about XCUI tests that's trying to build the app for release even though your tests are set in debug?\r\n\r\nIf none of those turn up the problem, do you mind either emailing me your project or a sample project that reproduces this issue? ellen at apollographql dot com. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Were you ever able to figure this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Race condition when unsubscribing","author":{"__typename":"User","login":"marioradonic","id":"MDQ6VXNlcjQxNTg3Mzc=","name":null},"body":"## Bug report\r\n\r\nI've been randomly (but often) getting `.unprocessedMessage` errors in my `.subscribe(...` handlers. I had a look at the code and it seems to me that there is a possible race condition.\r\n\r\nWhen [unsubscribing](https://github.com/apollographql/apollo-ios/blob/e0f65fee8c197239dbefbf1386b8e7f83b684f25/Sources/ApolloWebSocket/WebSocketTransport.swift#L301) from a subscribe task websocket message is sent requesting the subscription to stop and handler is released. It might be possible that a message is received from the socket with the update before the backend has time process this stop message and stop sending the messages. So in the [processMessage](https://github.com/apollographql/apollo-ios/blob/e0f65fee8c197239dbefbf1386b8e7f83b684f25/Sources/ApolloWebSocket/WebSocketTransport.swift#L146) method we end up in [this clause](https://github.com/apollographql/apollo-ios/blob/e0f65fee8c197239dbefbf1386b8e7f83b684f25/Sources/ApolloWebSocket/WebSocketTransport.swift#L177) because there is no subscription handlers any more. And then **all** the other handlers are notified about this error. This doesn't seem right to me as there was nothing wrong with other subscriptions.\r\n\r\nI'm not an expert in web sockets, so I don't know what the best solution would be. Maybe wait for the ack message from backend? But then the subscriber might get a message after cancelling the task, which is not nice. Maybe keep an intermittent array of task ids whose cancellation hasn't been acknowledged by the backend and ignore messages for those subscribers? That is if there is a stop acknowledge message from backend.\r\n\r\nI don't mind creating a PR if someone suggests the approach on how to fix this.\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.35.0\r\n- Xcode version: 12.1\r\n- Swift version: 5.3\r\n\r\n## Steps to reproduce\r\n\r\nI have a rx code in format of:\r\n`subscribeSomething().flatMapLatest { subscribeSomethingElse(using: $0) }`\r\n\r\nWhen the first subscription updates the second one is cancelled and new one is created.\r\n\r\n## Further details\r\n\r\nI can probably restructure my query so it's all done in one subscription, which would fix my issue but the underlying problem will still be there although it might happen less often.\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"I don't have any bright ideas on this one, websockets are also not my area of expertise. \r\n\r\n@fassko, if you're around, would love to hear any thoughts you have.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I was using GraphQL subscriptions with just one subscription. Otherwise, you can run into these weird side effects that you explained.","author":{"__typename":"User","login":"fassko","id":"MDQ6VXNlcjI5NDgy","name":"Kristaps Grinbergs"}},{"__typename":"IssueComment","body":"@fassko Well, it was worth a shot 🙃\r\n\r\n@marioradonic - Are you subscribing to the same `subscription` from your schema multiple times, or are there different `subscription`s defined that you're using? Basically, are your multiple subscriptions all returning the same information, or different information?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@designatednerd I am using multiple. Basically, I am subscribing to entity A, and when it updates I subscribe to entity B, cancelling the previous B subscription if there was any. (this cancelled subscription causes the problem - if the message comes from the backend with the cancelled subscription id the first entity A subscriber and the new B subscriber get the error message.\r\n\r\nI had another look at the websocket connection and it seems there is no closing acknowledgment message from the backend upon closing the subscription. So I'm not sure at which point should an unhandled message be considered an internal error. In any case I don't think it's a good API design that all the other subscribers get the error message, since nothing is wrong with their subscriptions. Maybe there could be a global error handler for these kinds of errors?\r\n\r\n","author":{"__typename":"User","login":"marioradonic","id":"MDQ6VXNlcjQxNTg3Mzc=","name":null}},{"__typename":"IssueComment","body":">cancelling the previous B subscription if there was any. \r\n\r\nIn theory you shouldn't have to cancel any existing subscription to entity B - if you've already got a running subscription it should continue to get all updates.\r\n\r\nIt may help me understand a bit better if you can give a concrete example of what entity A and entity B are representing. To take an example from our sample code, if you've subscribed to all reviews of Star Wars episodes, then as soon as you get a review of _Return of the Jedi_ kick off a second subscription that only handles _Jedi_ reviews, any further reviews that come in on that first subscription for _Jedi_ would also come in on the second subscription, without needing to stop and restart. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"spectrum.chat/apollo link is unavailable, Heroku error shown","author":{"__typename":"User","login":"gemmakbarlow","id":"MDQ6VXNlcjMzNzk2Mw==","name":"Gemma Barlow"},"body":"## Bug report\r\n\r\nMorning folks ! \r\n\r\nNot technically an Apollo bug, but I wanted to flag that https://spectrum.chat/apollo, linked from [CONTRIBUTING.md](https://github.com/apollographql/apollo-ios/blob/main/CONTRIBUTING.md), is currently returning a Heroku error.\r\n\r\n\"Screen\r\n\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- N / A\r\n\r\n## Steps to reproduce\r\n\r\n- N / A\r\n\r\n## Further details\r\n\r\nPlease feel free to close this if it isn't something you are in control of / hosting yourselves. I wasn't able to find a status page for the tool / platform and am not familiar with it. Google results get mixed in with the ISP provider unfortunately. 😄 ","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Haha, i have the same problem with the ISP, particularly since they are _my_ ISP. \r\n\r\nSpectrum is a chat platform that got bought out by GitHub about a year and a half ago - we'd been using them prior to that buyout and have been continuing to do so. Thanks for the heads up on this, but unfortunately there isn't much we can do about their deploys failing. Upside is it seems to be back up and running now, though!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"How to handle errors correctly","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null},"body":"Hi,\r\nI am currently on the stage of migrating from 0.33 -> 0.36. Gone through all the provided documentation, but I am still confused on what would be the correct way of handling errors(also read the suggested article: https://medium.com/@sachee/200-ok-error-handling-in-graphql-7ec869aec9bc).\r\n\r\nBefore going to write this question, I just wanted to give it a try myself.\r\nOne of the most important use cases related to error handling is that we want to cover the case when a auth token expires on the backend, which results in an error when performing the next app query or mutation. At this stage, we want to catch the error, perform automatically a relogin(call `login` mutation), which basically will return a new auth token and after all that re-execute the failed request(query/mutation).\r\nAs far as I managed to understand, the best way to do this is through `ApolloErrorInterceptor`, which I basically did. I created a custom `ApolloErrorInterceptor`, returned it in `InterceptorProvider.additionalErrorInterceptor`.\r\nThe first problem I met is that it seems that not absolutely all errors get through this interceptor. Which left me without ideas on how to continue, but since this new apollo sdk approach is pretty fresh, I also left some space to consider it might be a bug, `full stop`.\r\n\r\nNow my question is: what is the correct way of handling errors? Can we improve the documentation to provide more examples about it?\r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Interesting, I thought it was me but maybe `InterceptorProvider.additionalErrorInterceptor` is not what we expect.\r\nI just went through same update and had same problem as you do. what worked for me was:\r\n\r\n```swift\r\n/// InterceptorProvider\r\n func interceptors(for operation: Operation) -> [ApolloInterceptor] {\r\n return [\r\n MaxRetryInterceptor(),\r\n LegacyCacheReadInterceptor(store: self.store),\r\n TokenAddingInterceptor(...),\r\n NetworkFetchInterceptor(client: self.client),\r\n TokenErrorInterceptor(...),\r\n ResponseCodeInterceptor(),\r\n LegacyParsingInterceptor(cacheKeyForObject: self.store.cacheKeyForObject),\r\n AutomaticPersistedQueryInterceptor(),\r\n LegacyCacheWriteInterceptor(store: self.store),\r\n ]\r\n }\r\n\r\n func additionalErrorInterceptor(for operation: Operation) -> ApolloErrorInterceptor? {\r\n return nil\r\n }\r\n```\r\n\r\n```swift\r\n/// TokenErrorInterceptor\r\n func interceptAsync(chain: RequestChain, request: HTTPRequest, response: HTTPResponse?, completion: @escaping (Result, Error>) -> Void) {\r\n guard\r\n let responseStatusCode = response?.httpResponse.statusCode,\r\n responseStatusCode == 401\r\n else {\r\n chain.proceedAsync(request: request, response: response, completion: completion)\r\n return\r\n }\r\n \r\n tokenService.renewAccessToken { [weak self] (error: OAuthSwiftError?) in\r\n guard self != nil else { return }\r\n \r\n if let error = error {\r\n chain.handleErrorAsync(error, request: request, response: response, completion: completion)\r\n } else {\r\n chain.retry(request: request, completion: completion)\r\n }\r\n }\r\n }\r\n```\r\n\r\nneither `additionalErrorInterceptor` nor having `TokenErrorInterceptor` after `ResponseCodeInterceptor` worked","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"`additionalErrorInterceptor` is generally intended for error handling *after* something has been dealt with by the request chain. In this case, you want to deal with it *within* the request chain, so that you can call retry. \r\n\r\n@RolandasRazma's example is a great one if the token error is coming back from middleware and causing a `401 Unauthorized` to be returned. \r\n\r\nIf there's something within GraphQL that's returning the error, you'll get a `200 OK` and an error on `GraphQLResult`'s `errors` property. In that case, you would want to insert your `TokenErrorInterceptor` after the `LegacyParsingInterceptor`, since that's where those would actually be parsed.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> `additionalErrorInterceptor` is generally intended for error handling _after_ something has been dealt with by the request chain.\r\n\r\nJust for the sake of understanding it better, what does it mean and why in some particular conditions it is not called.? I guess some of the docs needs to be more explicit about the use cases when it should be used.","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"It only wouldn't be called if it doesn't exist. It's designed to be a place to have all errors, no matter what the origin, pass through before being handed back to the caller. This allows for things like error logging that are hard to do without a centralized error handler. \r\n\r\nI'll work on clarifying this in the docs.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@odanu @RolandasRazma Added some docs on the additional error interceptor to #1484 ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"OK, that's merged - is there anything else here I can help clarify, or do you mind if we close this out?","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I think you can close this ticket. Though you have to maybe give it a try for different use cases around `additionalErrorInterceptor`. As written above, it looks like it doesn't catch all the errors.","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"> nor having `TokenErrorInterceptor` after `ResponseCodeInterceptor` worked\r\n\r\nHere the issue would be that the `401` response code would be caught by the `ResponseCodeInterceptor` [and returned as an error through `handleErrorAsync`](https://github.com/apollographql/apollo-ios/blob/a00031c2a357c03a2f58a5dda0afb35462dfef42/Sources/Apollo/ResponseCodeInterceptor.swift#L44) (which in turn [calls the `additionalErrorInterceptor` if it exists](https://github.com/apollographql/apollo-ios/blob/a00031c2a357c03a2f58a5dda0afb35462dfef42/Sources/Apollo/RequestChain.swift#L149)) and the chain would not proceed. \r\n\r\nThat would mean `TokenErrorInterceptor` wouldn't get called because an error has already been caught. That's why you have to put it before the `ResponseCodeInterceptor`. \r\n\r\nDoes that help explain why that wouldn't work? Or is there another place where things aren't showing up where you expect them to? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"No Ellen. I was not referring this part. Let's sum up again the thoughts.\r\nThe documentation and you, assures that `additionalErrorInterceptor` gets called, having the error which was collected in any of the interceptors. Which basically means that no matter at which level of the request/response/parsing/etc an error occurs, it will arrive to the `additionalErrorInterceptor`.\r\nNow as mentioned in the initial question, it seems that not all of the errors reach the `additionalErrorInterceptor`. That was my initial test. I just thought it would be the right place to handle all the errors, but got blocked because some of the errors didn't get to it. Check the question again please :).","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"Right, and my question is, what are the errors that are not passed through in your testing? \r\n\r\nNote that if there is an _expected_ error, which is handled by the interceptor (for example, the auto-persisted-query-specific error which is handled by the `AutomaticPersistedQueryInterceptor`), then that is not passed on since that is an error that was expected and handled. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"I will try to collect the information tomorrow;)","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"So I can find 2 cases when `additionalErrorInterceptor` is not used:\r\n1. when an interceptor caught the error triggered retry... the example with expired token\r\n2. `GraphQLError` objects which arrive through `GraphQLResults.errors` array.\r\n\r\nBut I guess both of these cases is expected behaviour.","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"You're correct - because a `GraphQLResult` can contain partial results with an error explaining what's missing, simply having `errors` be non-empty doesn't indicate that a request failed. \r\n\r\nYou can see an example of where we're looking for _specific_ errors to handle in that array in the `AutomaticPersistedQueryInterceptor`, and if you know your backend will be returning _specific_ errors you need to handle in that array (for example, token expiration errors there instead of as a 401), you can add your own interceptors to handle those. \r\n\r\nOtherwise, `GraphQLError`s should be returned as part of the `GraphQLResult`.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"@odanu Anything else here or can I close this out? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Oh sorry. All good. I had to close it earlier.","author":{"__typename":"User","login":"odanu","id":"MDQ6VXNlcjExMTA0MDg=","name":null}},{"__typename":"IssueComment","body":"👍 Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"How to fix that error?","author":{"__typename":"User","login":"zinminphyo","id":"MDQ6VXNlcjMzMzY4MzQ3","name":"Zin Min Phyo"},"body":"## Bug report\r\n\r\nPlease replace this line with a short description of the problem. Make sure you've read `CHANGELOG.md` in the root of the repo to make sure a new version hasn't already addressed your problem!\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.34.1\r\n- Xcode version: 12.0\r\n- Swift version: 5\r\n\"Screen\r\n\r\n- Package manager:\r\n\r\n## Steps to reproduce\r\n\r\nPlease replace this line with steps to reproduce the problem.\r\n\r\n## Further details\r\n\r\nPlease replace this line with any further details or context necessary to understand the problem. Delete this section if you don't have anything further to add.","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"@zinminphyo Can you please share more details about when and how this happened? It's not something I can necessarily tell you why it's happening without more detail. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Since I haven't gotten any further details here, I'm going to close this out. @zinminphyo Please reopen with further details if you have them. Anyone else with a similar problem, please open a new issue. Thank you!","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Generate Apollo GraphQL Api Bitrise issue","author":{"__typename":"User","login":"Kevin94singh","id":"MDQ6VXNlcjIxMzQ3NDg5","name":"Kevin Singh"},"body":"Hi,\r\n\r\nWhen building on a local machine with Fastlane, everything works ok. However, when I try to upload my build with Bitrise, I'm getting an error: \r\n\r\n```\r\n- ▸ Running script 'Generate Apollo GraphQL API'\r\n** ARCHIVE FAILED **\r\nThe following build commands failed:\r\n\tPhaseScriptExecution Generate\\ Apollo\\ GraphQL\\ API /Users/vagrant/Library/Developer/Xcode/DerivedData/project_name-asogvanbfzdyhybkhoculdmlwwfk/Build/Intermediates.noindex/ArchiveIntermediates/project_name_beta/IntermediateBuildFilesPath/project_name.build/Release-iphoneos/project_name_beta/Script-7A325491234C77FE003B1AE2.sh\r\n(1 failure)\r\n[11:36:34]: Exit status: 65\r\n```\r\n**Our Generate Apollo GraphQL API script**\r\n\r\n```\r\nSCRIPT_PATH=\"${PODS_ROOT}/Apollo/scripts\"\r\ncd \"${SRCROOT}/ProjectName\"\r\n\"${SCRIPT_PATH}\"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile=\"schema.json\" API.swift\r\n```\r\n\r\n| - project_folder\r\n | project.xcodeproj\r\n | - target_folder \r\n | schema.json\r\n | AppDelegate.swift\r\n | ViewController.swift\r\n | etc...\r\n | - another_folders\r\n | etc...\r\n\r\n**Apollo version: 0.30, iOS, Bitrise Fastlane version 2.7.x ** We have two targets (prod and beta), currently trying to build for Beta.\r\n\r\nI think that there might be an issue with NPM. In our workflow on Bitrise, I've set `run npm command`- `install -g apollo@2.25` - the version I have on my machine. But this step doesn't help. \r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"If you're using `run-bundled-codegen` it shouldn't be an issue with NPM - the bundled codegen downloads Node and all dependencies as a workaround because we were having *so* many problems with NPM. It certainly seems like another issue is happening that's causing the code generation to fail but isn't spitting out a reason correctly. \r\n\r\nI take it things build correctly when you try to run this locally? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"> If you're using `run-bundled-codegen` it shouldn't be an issue with NPM - the bundled codegen downloads Node and all dependencies as a workaround because we were having _so_ many problems with NPM. It certainly seems like another issue is happening that's causing the code generation to fail but isn't spitting out a reason correctly.\r\n> \r\n> I take it things build correctly when you try to run this locally?\r\n\r\nYes, when I run this locally with Fastlane, it builds correctly.","author":{"__typename":"User","login":"Kevin94singh","id":"MDQ6VXNlcjIxMzQ3NDg5","name":"Kevin Singh"}},{"__typename":"IssueComment","body":"Weird - and are you using Fastlane on bitrise as well, or something else? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes, we are using Fastlane. Our steps for a workflow are Activate SSH Key, Git Clone repository, and Fastlane (set to a version 2.x.x, that is currently 2.7.1).","author":{"__typename":"User","login":"Kevin94singh","id":"MDQ6VXNlcjIxMzQ3NDg5","name":"Kevin Singh"}},{"__typename":"IssueComment","body":"Cool, thanks for clarifying - how are you setting things to \"beta\" - using a Scheme or a build configuration or some combination thereof? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"We have two schemes - \"beta\" and \"prod\". Each has its own target. The script is implemented in both targets .","author":{"__typename":"User","login":"Kevin94singh","id":"MDQ6VXNlcjIxMzQ3NDg5","name":"Kevin Singh"}},{"__typename":"IssueComment","body":"And am I correct in assuming the `.graphql` files and `API.swift` output are in the same folder (under `\"${SRCROOT}/ProjectName\"`), just shared between both targets? \r\n\r\nHonestly, if it's working locally and the only error info you're getting from Bitrise is a generic exit code 65, I'm not sure how much help I can be - you may want to reach out to them to see if you can get more detailed logs about what's not building on your beta version. \r\n\r\nOne thing I have tried in the past when something's building locally but not on CI for me is to check it back out in a separate folder and try from there - I've definitely found issues where there's some kind of local config not checked into version control that means it works in your main working directory, but not for anyone else (including CI) that checks it out. Probably worth a shot just to rule that out as a cause.","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Yes, it is shared between both targets. Prod build shows the same failure as a beta. \r\n\r\nI'll try to get more detailed logs and let you know. Thank you for your time! 😊","author":{"__typename":"User","login":"Kevin94singh","id":"MDQ6VXNlcjIxMzQ3NDg5","name":"Kevin Singh"}}]}},{"__typename":"Issue","title":"callbackQueue is not used in WebSocketTransport","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"},"body":"## Bug report\r\n\r\nhttps://github.com/apollographql/apollo-ios/blob/185d6b784538691b5a4287c25df9cae140abec02/Sources/ApolloWebSocket/WebSocketTransport.swift#L361 callbackQueue is unused\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36.0\r\n\r\n## Steps to reproduce\r\n\r\nsubscribe using any callbackQueue, callback is done on some internal one","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Welp, that's embarrassing. Fix is up in #1507. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"thanks","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"Thank YOU for catching it","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"WebSocketTransport.send completionHandler is called in non escaping manner in case of error","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"},"body":"## Bug report\r\n\r\nhttps://github.com/apollographql/apollo-ios/blob/185d6b784538691b5a4287c25df9cae140abec02/Sources/ApolloWebSocket/WebSocketTransport.swift#L364\r\n\r\ncompletionHandler is called in non escaping manner in case of error\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36.0","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Do you mean it's not called on the callback queue? ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"Was thinking about @escaping but yes, calling it on callback cue would fix that","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}},{"__typename":"IssueComment","body":"It's declared as [`@escaping` here](https://github.com/apollographql/apollo-ios/blob/185d6b784538691b5a4287c25df9cae140abec02/Sources/ApolloWebSocket/WebSocketTransport.swift#L362) - declaring escaping does not require it to escape, though. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}},{"__typename":"IssueComment","body":"sure, but it might break flow depending on what's happening internally\r\n\r\n```swift\r\nWebSocketTransport.send {\r\n print(\"a\")\r\n}\r\n\r\nprint(\"b\")\r\n```\r\n\r\nwhat order will be output depends on internal state and that's not great.\r\n\r\nIn any case, closing as https://github.com/apollographql/apollo-ios/pull/1507 fixes it","author":{"__typename":"User","login":"RolandasRazma","id":"MDQ6VXNlcjEwMjcxODc=","name":"Rolandas Razma"}}]}},{"__typename":"Issue","title":"Compatibility issues on Linux with CommonCrypto","author":{"__typename":"User","login":"abdimaye","id":"MDQ6VXNlcjI5MDIzNzI2","name":null},"body":"## Feature request\r\n\r\nThe CommonCrypto module is only available in Xcode 10+. It would be nice to have this replaced with an open source module such that the apollo client can run on other platforms.\r\n\r\n## Motivation\r\n\r\nWe are currently trying to run parts of our codebase on Linux.\r\n\r\n## Proposed solution\r\n\r\nReplace CommonCrypto with an open source library. There are only two files in ApolloCore that use it and the diff wouldn't be that big. \r\n\r\nI was looking at `swift-crypto` https://swift.org/blog/crypto/ but there are compatibility issues where it requires mocos 10.15 and apollo requires 10.10. \r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"We don't *officially* support Linux, but I would very much like to. My thought is that we could make some kind of protocol that uses `swift-crypto` for Linux band still uses `CommonCrypto` on iOS etc. Would be more than open to a PR if you have some time, I'm buried at the moment. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}},{"__typename":"Issue","title":"Apollo CLI step fails to locate SourcePackages directory ","author":{"__typename":"User","login":"alcamla","id":"MDQ6VXNlcjI5MDQ1Mjk=","name":"Alejandro Camacho"},"body":"## Bug report\r\n\r\nI am following the steps on the tutorial for iOS. I added Apollo to the project using SPM. After adding the corresponding CLI script, and building the project, I get the following error: \r\n`error: Unable to locate SourcePackages directory from BUILD_ROOT: '/Users/myUser/Library/Developer/Xcode/DerivedData/Build/Products'`\r\nI have noticed that BUILD_ROOT is set to that folder directly, so there is no chance that the while loop finds the SourcePackages folder. I am running on Xcode 12.1\r\n\r\n## Versions\r\n\r\nPlease fill in the versions you're currently using: \r\n\r\n- `apollo-ios` SDK version: 0.36\r\n- Xcode version: 12.1\r\n- Swift version: 5.3\r\n- Package manager: Swift package manager\r\n\r\n## Steps to reproduce\r\n\r\n1. Create project\r\n2. Add Apollo dependency using SPM\r\n3. Add new run script phase with the code generation build step for SPM\r\n4. Modify the last line to download the schema on first run\r\n5. Build the project \r\n","comments":{"__typename":"IssueCommentConnection","nodes":[{"__typename":"IssueComment","body":"Ugh, I bet they changed the damned location of the source packages in 12.1 - it's definitely undocumented. \r\n\r\nI'll get a look at this tomorrow, but I think I'm going to recommend trying the [Swift Scripting Setup](https://www.apollographql.com/docs/ios/swift-scripting/) - that doesn't have any dependency on going diving through the derived data folder. ","author":{"__typename":"User","login":"designatednerd","id":"MDQ6VXNlcjE5NzY0OTg=","name":"Ellen Shapiro"}}]}}]}}}} diff --git a/Tests/ApolloServerIntegrationTests/SchemaRegistryApolloSchemaDownloaderTests.swift b/Tests/ApolloServerIntegrationTests/SchemaRegistryApolloSchemaDownloaderTests.swift new file mode 100644 index 0000000000..9b1b126a32 --- /dev/null +++ b/Tests/ApolloServerIntegrationTests/SchemaRegistryApolloSchemaDownloaderTests.swift @@ -0,0 +1,31 @@ +#if os(macOS) +import XCTest +import ApolloTestSupport +import ApolloCodegenTestSupport +@testable import ApolloCodegenLib + +class SchemaRegistryApolloSchemaDownloaderTests: XCTestCase { + func testDownloadingSchema_fromSchemaRegistry_shouldOutputSDL() throws { + let testOutputFolderURL = CodegenTestHelper.outputFolderURL() + XCTAssertFalse(FileManager.default.apollo.fileExists(at: testOutputFolderURL)) + + guard let apiKey = ProcessInfo.processInfo.environment["REGISTRY_API_KEY"] else { + throw XCTSkip("No API key could be fetched from the environment to test downloading from the schema registry") + } + + let settings = ApolloSchemaDownloadConfiguration.DownloadMethod.ApolloRegistrySettings(apiKey: apiKey, graphID: "Apollo-Fullstack-8zo5jl") + let configuration = ApolloSchemaDownloadConfiguration(using: .apolloRegistry(settings), + outputFolderURL: CodegenTestHelper.schemaFolderURL()) + + try ApolloSchemaDownloader.fetch(with: configuration) + XCTAssertTrue(FileManager.default.apollo.fileExists(at: configuration.outputURL)) + + // Can it be turned into the expected schema? + let frontend = try ApolloCodegenFrontend() + let source = try frontend.makeSource(from: configuration.outputURL) + let schema = try frontend.loadSchemaFromSDL(source) + let rocketType = try schema.getType(named: "Rocket") + XCTAssertEqual(rocketType?.name, "Rocket") + } +} +#endif diff --git a/Tests/ApolloServerIntegrationTests/StarWarsApolloSchemaDownloaderTests.swift b/Tests/ApolloServerIntegrationTests/StarWarsApolloSchemaDownloaderTests.swift index 522a956347..7157729c80 100644 --- a/Tests/ApolloServerIntegrationTests/StarWarsApolloSchemaDownloaderTests.swift +++ b/Tests/ApolloServerIntegrationTests/StarWarsApolloSchemaDownloaderTests.swift @@ -1,11 +1,3 @@ -// -// StarWarsApolloSchemaDownloaderTests.swift -// ApolloServerIntegrationTests -// -// Created by Anthony Miller on 4/20/21. -// Copyright © 2021 Apollo GraphQL. All rights reserved. -// - #if os(macOS) import XCTest import ApolloTestSupport @@ -14,68 +6,37 @@ import ApolloCodegenTestSupport class StarWarsApolloSchemaDownloaderTests: XCTestCase { - func testDownloadingSchemaAsJSON() throws { + func testDownloadingSchema_usingIntrospection_shouldOutputSDL() throws { let testOutputFolderURL = CodegenTestHelper.outputFolderURL() - - let options = ApolloSchemaOptions(downloadMethod: .introspection(endpointURL: TestServerURL.starWarsServer.url), - outputFolderURL: testOutputFolderURL) + let configuration = ApolloSchemaDownloadConfiguration(using: .introspection(endpointURL: TestServerURL.starWarsServer.url), + outputFolderURL: testOutputFolderURL) // Delete anything existing at the output URL - try FileManager.default.apollo.deleteFile(at: options.outputURL) - XCTAssertFalse(FileManager.default.apollo.fileExists(at: options.outputURL)) - - let cliFolderURL = CodegenTestHelper.cliFolderURL() + try FileManager.default.apollo.deleteFile(at: configuration.outputURL) + XCTAssertFalse(FileManager.default.apollo.fileExists(at: configuration.outputURL)) - _ = try ApolloSchemaDownloader.run(with: cliFolderURL, - options: options) + try ApolloSchemaDownloader.fetch(with: configuration) // Does the file now exist? - XCTAssertTrue(FileManager.default.apollo.fileExists(at: options.outputURL)) + XCTAssertTrue(FileManager.default.apollo.fileExists(at: configuration.outputURL)) // Is it non-empty? - let data = try Data(contentsOf: options.outputURL) - XCTAssertFalse(data.isEmpty) - - // Is it JSON? - let json = try XCTUnwrap(JSONSerialization.jsonObject(with: data, options: []) as? [AnyHashable:Any]) - - // Is it schema json? - _ = try XCTUnwrap(json["__schema"]) - - // OK delete it now - try FileManager.default.apollo.deleteFile(at: options.outputURL) - XCTAssertFalse(FileManager.default.apollo.fileExists(at: options.outputURL)) - } - - func testDownloadingSchemaInSchemaDefinitionLanguage() throws { - let testOutputFolderURL = CodegenTestHelper.outputFolderURL() - - let options = ApolloSchemaOptions(schemaFileType: .schemaDefinitionLanguage, - downloadMethod: .introspection(endpointURL: TestServerURL.starWarsServer.url), - outputFolderURL: testOutputFolderURL) - - // Delete anything existing at the output URL - try FileManager.default.apollo.deleteFile(at: options.outputURL) - XCTAssertFalse(FileManager.default.apollo.fileExists(at: options.outputURL)) - - let cliFolderURL = CodegenTestHelper.cliFolderURL() - - print(try ApolloSchemaDownloader.run(with: cliFolderURL, - options: options)) - - // Does the file now exist? - XCTAssertTrue(FileManager.default.apollo.fileExists(at: options.outputURL)) - - // Is it non-empty? - let data = try Data(contentsOf: options.outputURL) + let data = try Data(contentsOf: configuration.outputURL) XCTAssertFalse(data.isEmpty) // It should not be JSON XCTAssertNil(try? JSONSerialization.jsonObject(with: data, options: []) as? [AnyHashable:Any]) + // Can it be turned into the expected schema? + let frontend = try ApolloCodegenFrontend() + let source = try frontend.makeSource(from: configuration.outputURL) + let schema = try frontend.loadSchemaFromSDL(source) + let episodeType = try schema.getType(named: "Episode") + XCTAssertEqual(episodeType?.name, "Episode") + // OK delete it now - try FileManager.default.apollo.deleteFile(at: options.outputURL) - XCTAssertFalse(FileManager.default.apollo.fileExists(at: options.outputURL)) + try FileManager.default.apollo.deleteFile(at: configuration.outputURL) + XCTAssertFalse(FileManager.default.apollo.fileExists(at: configuration.outputURL)) } }