diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj index fce283f057..b7c9135c37 100644 --- a/Apollo.xcodeproj/project.pbxproj +++ b/Apollo.xcodeproj/project.pbxproj @@ -184,6 +184,7 @@ DE09F9BD27024FEA00795949 /* InputObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE09F9BC27024FEA00795949 /* InputObject.swift */; }; DE09F9C3270269E800795949 /* MockJavaScriptObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE09F9C0270269E800795949 /* MockJavaScriptObject.swift */; }; DE09F9C6270269F800795949 /* OperationDefinitionTemplate_DocumentType_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE09F9C5270269F800795949 /* OperationDefinitionTemplate_DocumentType_Tests.swift */; }; + DE0BCCE127C020F300A04743 /* AnimalKingdomAPI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE3C7A11260A6B9800D2F4FF /* AnimalKingdomAPI.framework */; }; DE12B2D7273B204B003371CC /* TestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE12B2D6273B204B003371CC /* TestError.swift */; }; DE12B2D9273C4338003371CC /* MockIRSubscripts.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE12B2D8273C4338003371CC /* MockIRSubscripts.swift */; }; DE181A2C26C5C0CB000C0B9C /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE181A2B26C5C0CB000C0B9C /* WebSocket.swift */; }; @@ -258,6 +259,18 @@ DE674D9F261CEEE4000E8FC8 /* a.txt in Resources */ = {isa = PBXBuildFile; fileRef = 9B2061192591B3550020D1E0 /* a.txt */; }; DE6B15AF26152BE10068D642 /* DefaultInterceptorProviderIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6B15AE26152BE10068D642 /* DefaultInterceptorProviderIntegrationTests.swift */; }; DE6B15B126152BE10068D642 /* Apollo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9FC750441D2A532C00458D91 /* Apollo.framework */; }; + DE6B650827C059A800970E4E /* ApolloAPI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE058621266978A100265760 /* ApolloAPI.framework */; }; + DE6B650C27C4293D00970E4E /* FieldArgumentRendering.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6B650B27C4293D00970E4E /* FieldArgumentRendering.swift */; }; + DE6D07F927BC3B6D009F5F33 /* GraphQLInputField+Rendered.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6D07F827BC3B6D009F5F33 /* GraphQLInputField+Rendered.swift */; }; + DE6D07FD27BC3D53009F5F33 /* OperationDefinition_VariableDefinition_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6D07FA27BC3BE9009F5F33 /* OperationDefinition_VariableDefinition_Tests.swift */; }; + DE6D07FF27BC7F78009F5F33 /* InputVariableRenderable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6D07FE27BC7F78009F5F33 /* InputVariableRenderable.swift */; }; + DE6D080427BD9A91009F5F33 /* PetAdoptionMutation.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6D080327BD9A91009F5F33 /* PetAdoptionMutation.swift */; }; + DE6D080727BD9AA9009F5F33 /* PetAdoptionInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6D080627BD9AA9009F5F33 /* PetAdoptionInput.swift */; }; + DE6D080927BD9ABA009F5F33 /* Mutation.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6D080827BD9ABA009F5F33 /* Mutation.swift */; }; + DE6D083327BDA211009F5F33 /* MeasurementsInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6D083227BDA211009F5F33 /* MeasurementsInput.swift */; }; + DE72867A27BEEC4D00577A0E /* PetSearchQuery.graphql in Resources */ = {isa = PBXBuildFile; fileRef = DE72867927BEEC4D00577A0E /* PetSearchQuery.graphql */; }; + DE72867C27BEEDF900577A0E /* PetSearchQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE72867B27BEEDF900577A0E /* PetSearchQuery.swift */; }; + DE72867E27BEEE2D00577A0E /* PetSearchFilters.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE72867D27BEEE2D00577A0E /* PetSearchFilters.swift */; }; DE736F4626FA6EE6007187F2 /* InflectorKit in Frameworks */ = {isa = PBXBuildFile; productRef = E6E4209126A7DF4200B82624 /* InflectorKit */; }; DE796429276998B000978A03 /* IR+RootFieldBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE796428276998B000978A03 /* IR+RootFieldBuilder.swift */; }; DE79642B276999E700978A03 /* IRNamedFragmentBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE79642A276999E700978A03 /* IRNamedFragmentBuilderTests.swift */; }; @@ -316,6 +329,7 @@ DED46035261CEA660086EF63 /* ApolloTestSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F8A95781EC0FC1200304A2D /* ApolloTestSupport.framework */; }; DED46042261CEA8A0086EF63 /* TestServerURLs.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED45C172615308E0086EF63 /* TestServerURLs.swift */; }; DED46051261CEAD20086EF63 /* StarWarsAPI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9FCE2CFA1E6C213D00E34457 /* StarWarsAPI.framework */; }; + DEE2DAA227BAF00500EC0607 /* GraphQLType+Rendered.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEE2DAA127BAF00500EC0607 /* GraphQLType+Rendered.swift */; }; DEFBBC86273470F70088AABC /* IR+Field.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEFBBC85273470F70088AABC /* IR+Field.swift */; }; DEFE0FC52748822900FFA440 /* IR+EntitySelectionTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEFE0FC42748822900FFA440 /* IR+EntitySelectionTree.swift */; }; E603863C27B2FB1D00E7B060 /* PetDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = E603765727B2FB1900E7B060 /* PetDetails.swift */; }; @@ -353,7 +367,7 @@ E623FD2A2797A6F4008B4CED /* InterfaceTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E623FD292797A6F4008B4CED /* InterfaceTemplate.swift */; }; E64F7EB827A0854E0059C021 /* UnionTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E64F7EB727A0854E0059C021 /* UnionTemplate.swift */; }; E64F7EBA27A085D90059C021 /* UnionTemplateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E64F7EB927A085D90059C021 /* UnionTemplateTests.swift */; }; - E64F7EBC27A11A510059C021 /* GraphQLNamedType+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = E64F7EBB27A11A510059C021 /* GraphQLNamedType+Swift.swift */; }; + E64F7EBC27A11A510059C021 /* GraphQLNamedType+SwiftName.swift in Sources */ = {isa = PBXBuildFile; fileRef = E64F7EBB27A11A510059C021 /* GraphQLNamedType+SwiftName.swift */; }; E64F7EBF27A11B110059C021 /* GraphQLNamedType+SwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E64F7EBE27A11B110059C021 /* GraphQLNamedType+SwiftTests.swift */; }; E64F7EC127A122300059C021 /* ObjectTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E64F7EC027A122300059C021 /* ObjectTemplate.swift */; }; E657CDBA26FD01D4005834D6 /* ApolloSchemaInternalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E657CDB926FD01D4005834D6 /* ApolloSchemaInternalTests.swift */; }; @@ -515,6 +529,13 @@ remoteGlobalIDString = DE058606266978A100265760; remoteInfo = ApolloModels; }; + DE0BCCDF27C020EE00A04743 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 9FC7503B1D2A532C00458D91 /* Project object */; + proxyType = 1; + remoteGlobalIDString = DE3C7A00260A6B9800D2F4FF; + remoteInfo = AnimalKingdomAPI; + }; DE3C7A96260A6C1000D2F4FF /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 9FC7503B1D2A532C00458D91 /* Project object */; @@ -529,6 +550,13 @@ remoteGlobalIDString = 9FC750431D2A532C00458D91; remoteInfo = Apollo; }; + DE6D083427BDAB9E009F5F33 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 9FC7503B1D2A532C00458D91 /* Project object */; + proxyType = 1; + remoteGlobalIDString = DE058606266978A100265760; + remoteInfo = ApolloAPI; + }; DECD46F9262F659100924527 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 9FC7503B1D2A532C00458D91 /* Project object */; @@ -980,6 +1008,18 @@ DE6B160B26152D210068D642 /* Project-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Project-Debug.xcconfig"; sourceTree = ""; }; DE6B160C26152D210068D642 /* Workspace-Packaging.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Workspace-Packaging.xcconfig"; sourceTree = ""; }; DE6B160D26152D210068D642 /* Workspace-Shared.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Workspace-Shared.xcconfig"; sourceTree = ""; }; + DE6B650B27C4293D00970E4E /* FieldArgumentRendering.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FieldArgumentRendering.swift; sourceTree = ""; }; + DE6D07F827BC3B6D009F5F33 /* GraphQLInputField+Rendered.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GraphQLInputField+Rendered.swift"; sourceTree = ""; }; + DE6D07FA27BC3BE9009F5F33 /* OperationDefinition_VariableDefinition_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationDefinition_VariableDefinition_Tests.swift; sourceTree = ""; }; + DE6D07FE27BC7F78009F5F33 /* InputVariableRenderable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputVariableRenderable.swift; sourceTree = ""; }; + DE6D080227BD9933009F5F33 /* PetAdoptionMutation.graphql */ = {isa = PBXFileReference; lastKnownFileType = text; path = PetAdoptionMutation.graphql; sourceTree = ""; }; + DE6D080327BD9A91009F5F33 /* PetAdoptionMutation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PetAdoptionMutation.swift; sourceTree = ""; }; + DE6D080627BD9AA9009F5F33 /* PetAdoptionInput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PetAdoptionInput.swift; sourceTree = ""; }; + DE6D080827BD9ABA009F5F33 /* Mutation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Mutation.swift; sourceTree = ""; }; + DE6D083227BDA211009F5F33 /* MeasurementsInput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MeasurementsInput.swift; sourceTree = ""; }; + DE72867927BEEC4D00577A0E /* PetSearchQuery.graphql */ = {isa = PBXFileReference; lastKnownFileType = text; path = PetSearchQuery.graphql; sourceTree = ""; }; + DE72867B27BEEDF900577A0E /* PetSearchQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PetSearchQuery.swift; sourceTree = ""; }; + DE72867D27BEEE2D00577A0E /* PetSearchFilters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PetSearchFilters.swift; sourceTree = ""; }; DE796428276998B000978A03 /* IR+RootFieldBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "IR+RootFieldBuilder.swift"; sourceTree = ""; }; DE79642A276999E700978A03 /* IRNamedFragmentBuilderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IRNamedFragmentBuilderTests.swift; sourceTree = ""; }; DE79642C27699A6A00978A03 /* IR+NamedFragmentBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "IR+NamedFragmentBuilder.swift"; sourceTree = ""; }; @@ -1016,6 +1056,7 @@ DEE1B3F3273B08D8007350E5 /* AllAnimals.graphql.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllAnimals.graphql.swift; sourceTree = ""; }; DEE1B3F4273B08D8007350E5 /* Types.graphql.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Types.graphql.swift; sourceTree = ""; }; DEE1B3F5273B08D8007350E5 /* WarmBloodedDetails.graphql.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WarmBloodedDetails.graphql.swift; sourceTree = ""; }; + DEE2DAA127BAF00500EC0607 /* GraphQLType+Rendered.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GraphQLType+Rendered.swift"; sourceTree = ""; }; DEFBBC85273470F70088AABC /* IR+Field.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "IR+Field.swift"; sourceTree = ""; }; DEFE0FC42748822900FFA440 /* IR+EntitySelectionTree.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "IR+EntitySelectionTree.swift"; sourceTree = ""; }; E603765727B2FB1900E7B060 /* PetDetails.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PetDetails.swift; sourceTree = ""; }; @@ -1054,7 +1095,7 @@ E623FD2B2797A700008B4CED /* InterfaceTemplateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InterfaceTemplateTests.swift; sourceTree = ""; }; E64F7EB727A0854E0059C021 /* UnionTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnionTemplate.swift; sourceTree = ""; }; E64F7EB927A085D90059C021 /* UnionTemplateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnionTemplateTests.swift; sourceTree = ""; }; - E64F7EBB27A11A510059C021 /* GraphQLNamedType+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GraphQLNamedType+Swift.swift"; sourceTree = ""; }; + E64F7EBB27A11A510059C021 /* GraphQLNamedType+SwiftName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GraphQLNamedType+SwiftName.swift"; sourceTree = ""; }; E64F7EBE27A11B110059C021 /* GraphQLNamedType+SwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GraphQLNamedType+SwiftTests.swift"; sourceTree = ""; }; E64F7EC027A122300059C021 /* ObjectTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectTemplate.swift; sourceTree = ""; }; E64F7EC227A1243A0059C021 /* ObjectTemplateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectTemplateTests.swift; sourceTree = ""; }; @@ -1137,6 +1178,7 @@ DEAFB77F2706474C00BE02F3 /* Nimble in Frameworks */, DECD49DB262F8AAA00924527 /* ApolloTestSupport.framework in Frameworks */, DECD4992262F841600924527 /* ApolloCodegenTestSupport.framework in Frameworks */, + DE0BCCE127C020F300A04743 /* AnimalKingdomAPI.framework in Frameworks */, 9FDE0752258F3BC200DC0CA5 /* StarWarsAPI.framework in Frameworks */, 9BAEEC01234BB8FD00808306 /* ApolloCodegenLib.framework in Frameworks */, ); @@ -1201,6 +1243,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DE6B650827C059A800970E4E /* ApolloAPI.framework in Frameworks */, DE3C7A94260A6C1000D2F4FF /* ApolloUtils.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1566,7 +1609,6 @@ 9B7B6F68233C2C0C00F32205 /* FileManager+Apollo.swift */, 9BAEEBF62346F0A000808306 /* StaticString+Apollo.swift */, 9B8C3FB1248DA2EA00707B13 /* URL+Apollo.swift */, - E64F7EBB27A11A510059C021 /* GraphQLNamedType+Swift.swift */, ); name = Extensions; sourceTree = ""; @@ -2015,6 +2057,7 @@ DE31A437276A78140020DC44 /* Templates */ = { isa = PBXGroup; children = ( + DE6D07FC27BC3C81009F5F33 /* RenderingHelpers */, E6C9849227929EBE009481BE /* EnumTemplate.swift */, DE5FD60A276970FC0033EE23 /* FragmentTemplate.swift */, E608FBA427B1EFDF00493756 /* HeaderCommentTemplate.swift */, @@ -2040,8 +2083,9 @@ E69BEDA62798B89600000D10 /* InputObjectTemplateTests.swift */, E623FD2B2797A700008B4CED /* InterfaceTemplateTests.swift */, E64F7EC227A1243A0059C021 /* ObjectTemplateTests.swift */, - DE09F9C5270269F800795949 /* OperationDefinitionTemplate_DocumentType_Tests.swift */, DE09066E27A4713F00211300 /* OperationDefinitionTemplateTests.swift */, + DE09F9C5270269F800795949 /* OperationDefinitionTemplate_DocumentType_Tests.swift */, + DE6D07FA27BC3BE9009F5F33 /* OperationDefinition_VariableDefinition_Tests.swift */, DE5FD608276956C70033EE23 /* SchemaTemplateTests.swift */, E6B42D0C27A4749100A3BD58 /* SwiftPackageManagerModuleTemplateTests.swift */, E64F7EB927A085D90059C021 /* UnionTemplateTests.swift */, @@ -2068,6 +2112,8 @@ children = ( DE2FCF2E26E8092B0057EA67 /* AllAnimalsQuery.graphql */, DE2FCF2D26E8092B0057EA67 /* AnimalSchema.graphqls */, + DE72867927BEEC4D00577A0E /* PetSearchQuery.graphql */, + DE6D080227BD9933009F5F33 /* PetAdoptionMutation.graphql */, DE2FCF2F26E8092B0057EA67 /* ClassroomPets.graphql */, DE2FCF3226E8092B0057EA67 /* HeightInMeters.graphql */, DE2FCF3126E8092B0057EA67 /* PetDetails.graphql */, @@ -2146,6 +2192,28 @@ path = Configuration/Shared; sourceTree = SOURCE_ROOT; }; + DE6D07FC27BC3C81009F5F33 /* RenderingHelpers */ = { + isa = PBXGroup; + children = ( + E64F7EBB27A11A510059C021 /* GraphQLNamedType+SwiftName.swift */, + DEE2DAA127BAF00500EC0607 /* GraphQLType+Rendered.swift */, + DE6D07F827BC3B6D009F5F33 /* GraphQLInputField+Rendered.swift */, + DE6D07FE27BC7F78009F5F33 /* InputVariableRenderable.swift */, + DE6B650B27C4293D00970E4E /* FieldArgumentRendering.swift */, + ); + path = RenderingHelpers; + sourceTree = ""; + }; + DE6D080527BD9AA9009F5F33 /* InputObjects */ = { + isa = PBXGroup; + children = ( + DE6D080627BD9AA9009F5F33 /* PetAdoptionInput.swift */, + DE72867D27BEEE2D00577A0E /* PetSearchFilters.swift */, + DE6D083227BDA211009F5F33 /* MeasurementsInput.swift */, + ); + path = InputObjects; + sourceTree = ""; + }; DE9C04AB26EA763E00EC35E7 /* Accumulators */ = { isa = PBXGroup; children = ( @@ -2282,6 +2350,8 @@ E603765827B2FB1900E7B060 /* HeightInMeters.swift */, E603765927B2FB1900E7B060 /* ClassroomPetDetails.swift */, E603765A27B2FB1900E7B060 /* ClassroomPetsQuery.swift */, + DE6D080327BD9A91009F5F33 /* PetAdoptionMutation.swift */, + DE72867B27BEEDF900577A0E /* PetSearchQuery.swift */, E603765B27B2FB1900E7B060 /* AllAnimalsQuery.swift */, E603765C27B2FB1900E7B060 /* WarmBloodedDetails.swift */, ); @@ -2291,6 +2361,7 @@ E603765D27B2FB1900E7B060 /* Schema */ = { isa = PBXGroup; children = ( + DE6D080527BD9AA9009F5F33 /* InputObjects */, E603765E27B2FB1900E7B060 /* Unions */, E603766027B2FB1900E7B060 /* Enums */, E603766327B2FB1900E7B060 /* Objects */, @@ -2320,6 +2391,7 @@ E603766327B2FB1900E7B060 /* Objects */ = { isa = PBXGroup; children = ( + DE6D080827BD9ABA009F5F33 /* Mutation.swift */, E603766427B2FB1900E7B060 /* Query.swift */, E603766527B2FB1900E7B060 /* Bird.swift */, E603766627B2FB1900E7B060 /* Human.swift */, @@ -2615,10 +2687,11 @@ buildRules = ( ); dependencies = ( + 9BAEEC03234BB8FD00808306 /* PBXTargetDependency */, DECD49DA262F8AA500924527 /* PBXTargetDependency */, DECD4991262F841300924527 /* PBXTargetDependency */, + DE0BCCE027C020EE00A04743 /* PBXTargetDependency */, 9FDE0742258F3B6100DC0CA5 /* PBXTargetDependency */, - 9BAEEC03234BB8FD00808306 /* PBXTargetDependency */, ); name = ApolloCodegenTests; packageProductDependencies = ( @@ -2786,6 +2859,7 @@ buildRules = ( ); dependencies = ( + DE6D083527BDAB9E009F5F33 /* PBXTargetDependency */, DE3C7A97260A6C1000D2F4FF /* PBXTargetDependency */, ); name = AnimalKingdomAPI; @@ -3040,6 +3114,7 @@ DE223C1E271F332D004A0148 /* AnimalSchema.graphqls in Resources */, DE223C1F271F332D004A0148 /* ClassroomPets.graphql in Resources */, DE223C20271F332D004A0148 /* HeightInMeters.graphql in Resources */, + DE72867A27BEEC4D00577A0E /* PetSearchQuery.graphql in Resources */, DE223C21271F332D004A0148 /* PetDetails.graphql in Resources */, DE223C22271F332D004A0148 /* WarmBloodedDetails.graphql in Resources */, ); @@ -3132,6 +3207,7 @@ E66F8899276C15580000BDA8 /* ObjectFileGenerator.swift in Sources */, 9BAEEBEF2346644B00808306 /* ApolloSchemaDownloader.swift in Sources */, DE5FD601276923620033EE23 /* TemplateString.swift in Sources */, + DE6D07FF27BC7F78009F5F33 /* InputVariableRenderable.swift in Sources */, DE796429276998B000978A03 /* IR+RootFieldBuilder.swift in Sources */, E64F7EC127A122300059C021 /* ObjectTemplate.swift in Sources */, 9F1A966F258F34BB00A06EEB /* JavaScriptBridge.swift in Sources */, @@ -3149,9 +3225,11 @@ 9BAEEBF32346DDAD00808306 /* CodegenLogger.swift in Sources */, 9F628EB52593651B00F94F9D /* GraphQLValue.swift in Sources */, DE5FD5FD2769222D0033EE23 /* OperationDefinitionTemplate.swift in Sources */, + DE6B650C27C4293D00970E4E /* FieldArgumentRendering.swift in Sources */, DE5EEC8527988F1A00AF5913 /* IR+SelectionSet.swift in Sources */, DE3484622746FF8F0065B77E /* IR+OperationBuilder.swift in Sources */, E610D8DF278F8F1E0023E495 /* UnionFileGenerator.swift in Sources */, + DEE2DAA227BAF00500EC0607 /* GraphQLType+Rendered.swift in Sources */, DE223C2D2721FCE8004A0148 /* ScopedSelectionSetHashable.swift in Sources */, DE79642D27699A6A00978A03 /* IR+NamedFragmentBuilder.swift in Sources */, 9B47518D2575AA850001FB87 /* Pluralizer.swift in Sources */, @@ -3167,10 +3245,11 @@ E610D8DB278EB0900023E495 /* InterfaceFileGenerator.swift in Sources */, 9B7B6F69233C2C0C00F32205 /* FileManager+Apollo.swift in Sources */, E674DB41274C0A9B009BB90E /* Glob.swift in Sources */, + DE6D07F927BC3B6D009F5F33 /* GraphQLInputField+Rendered.swift in Sources */, DE5B318F27A48E060051C9D3 /* ImportStatementTemplate.swift in Sources */, 9F1A966C258F34BB00A06EEB /* GraphQLSchema.swift in Sources */, 9BE74D3D23FB4A8E006D354F /* FileFinder.swift in Sources */, - E64F7EBC27A11A510059C021 /* GraphQLNamedType+Swift.swift in Sources */, + E64F7EBC27A11A510059C021 /* GraphQLNamedType+SwiftName.swift in Sources */, 9B7B6F59233C287200F32205 /* ApolloCodegen.swift in Sources */, E608FBA527B1EFDF00493756 /* HeaderCommentTemplate.swift in Sources */, DE2739112769AEBA00B886EF /* SelectionSetTemplate.swift in Sources */, @@ -3250,6 +3329,7 @@ E6C9849527929FED009481BE /* EnumTemplateTests.swift in Sources */, DE5FD609276956C70033EE23 /* SchemaTemplateTests.swift in Sources */, E61EF713275EC99A00191DA7 /* ApolloCodegenTests.swift in Sources */, + DE6D07FD27BC3D53009F5F33 /* OperationDefinition_VariableDefinition_Tests.swift in Sources */, E6B4E9992798A8CB004EC8C4 /* InterfaceTemplateTests.swift in Sources */, 9F62DF8E2590539A00E6E808 /* SchemaIntrospectionTests.swift in Sources */, E6D90D0D278FFE35009CAC5D /* SchemaFileGeneratorTests.swift in Sources */, @@ -3467,16 +3547,21 @@ buildActionMask = 2147483647; files = ( E603864A27B2FB1D00E7B060 /* Height.swift in Sources */, + DE72867E27BEEE2D00577A0E /* PetSearchFilters.swift in Sources */, E603864227B2FB1D00E7B060 /* ClassroomPet.swift in Sources */, E603864F27B2FB1D00E7B060 /* WarmBlooded.swift in Sources */, E603863F27B2FB1D00E7B060 /* ClassroomPetsQuery.swift in Sources */, + DE6D080727BD9AA9009F5F33 /* PetAdoptionInput.swift in Sources */, E603864D27B2FB1D00E7B060 /* Animal.swift in Sources */, E603864527B2FB1D00E7B060 /* Query.swift in Sources */, DE223C24271F335D004A0148 /* Resources.swift in Sources */, E603864B27B2FB1D00E7B060 /* PetRock.swift in Sources */, E603864027B2FB1D00E7B060 /* AllAnimalsQuery.swift in Sources */, + DE6D080927BD9ABA009F5F33 /* Mutation.swift in Sources */, E603864427B2FB1D00E7B060 /* RelativeSize.swift in Sources */, + DE6D083327BDA211009F5F33 /* MeasurementsInput.swift in Sources */, E603864627B2FB1D00E7B060 /* Bird.swift in Sources */, + DE72867C27BEEDF900577A0E /* PetSearchQuery.swift in Sources */, E603864927B2FB1D00E7B060 /* Rat.swift in Sources */, E603863E27B2FB1D00E7B060 /* ClassroomPetDetails.swift in Sources */, E603864127B2FB1D00E7B060 /* WarmBloodedDetails.swift in Sources */, @@ -3486,6 +3571,7 @@ E603864E27B2FB1D00E7B060 /* Pet.swift in Sources */, E603864327B2FB1D00E7B060 /* SkinCovering.swift in Sources */, E603864727B2FB1D00E7B060 /* Human.swift in Sources */, + DE6D080427BD9A91009F5F33 /* PetAdoptionMutation.swift in Sources */, E603864827B2FB1D00E7B060 /* Cat.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -3625,6 +3711,11 @@ target = DE058606266978A100265760 /* ApolloAPI */; targetProxy = DE05862726697B1D00265760 /* PBXContainerItemProxy */; }; + DE0BCCE027C020EE00A04743 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DE3C7A00260A6B9800D2F4FF /* AnimalKingdomAPI */; + targetProxy = DE0BCCDF27C020EE00A04743 /* PBXContainerItemProxy */; + }; DE3C7A97260A6C1000D2F4FF /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 9B68353D2463481A00337AE6 /* ApolloUtils */; @@ -3635,6 +3726,11 @@ target = 9FC750431D2A532C00458D91 /* Apollo */; targetProxy = DE6B15B226152BE10068D642 /* PBXContainerItemProxy */; }; + DE6D083527BDAB9E009F5F33 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DE058606266978A100265760 /* ApolloAPI */; + targetProxy = DE6D083427BDAB9E009F5F33 /* PBXContainerItemProxy */; + }; DECD46FA262F659100924527 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 9B7B6F46233C26D100F32205 /* ApolloCodegenLib */; diff --git a/Apollo.xcodeproj/xcshareddata/xcschemes/AnimalKingdomAPI.xcscheme b/Apollo.xcodeproj/xcshareddata/xcschemes/AnimalKingdomAPI.xcscheme new file mode 100644 index 0000000000..9d54a6a58d --- /dev/null +++ b/Apollo.xcodeproj/xcshareddata/xcschemes/AnimalKingdomAPI.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sources/AnimalKingdomAPI/Generated/Operations/AllAnimalsQuery.swift b/Sources/AnimalKingdomAPI/Generated/Operations/AllAnimalsQuery.swift index 1d49dfc30b..62ccfef2a6 100644 --- a/Sources/AnimalKingdomAPI/Generated/Operations/AllAnimalsQuery.swift +++ b/Sources/AnimalKingdomAPI/Generated/Operations/AllAnimalsQuery.swift @@ -372,10 +372,10 @@ public class AllAnimalsQuery: GraphQLQuery { public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Bird.self) } public static var selections: [Selection] { [ - .field("wingspan", Int.self), + .field("wingspan", Float.self), ] } - public var wingspan: Int { data["wingspan"] } + public var wingspan: Float { data["wingspan"] } public var height: Height { data["height"] } public var species: String { data["species"] } public var skinCovering: GraphQLEnum? { data["skinCovering"] } diff --git a/Sources/AnimalKingdomAPI/Generated/Operations/ClassroomPetDetails.swift b/Sources/AnimalKingdomAPI/Generated/Operations/ClassroomPetDetails.swift index 520e842031..5ec3de09b0 100644 --- a/Sources/AnimalKingdomAPI/Generated/Operations/ClassroomPetDetails.swift +++ b/Sources/AnimalKingdomAPI/Generated/Operations/ClassroomPetDetails.swift @@ -113,10 +113,10 @@ public struct ClassroomPetDetails: AnimalKingdomAPI.SelectionSet, Fragment { public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Bird.self) } public static var selections: [Selection] { [ - .field("wingspan", Int.self), + .field("wingspan", Float.self), ] } - public var wingspan: Int { data["wingspan"] } + public var wingspan: Float { data["wingspan"] } public var species: String { data["species"] } public var humanName: String? { data["humanName"] } public var laysEggs: Bool { data["laysEggs"] } diff --git a/Sources/AnimalKingdomAPI/Generated/Operations/ClassroomPetsQuery.swift b/Sources/AnimalKingdomAPI/Generated/Operations/ClassroomPetsQuery.swift index 6113d4d444..85988fb3a7 100644 --- a/Sources/AnimalKingdomAPI/Generated/Operations/ClassroomPetsQuery.swift +++ b/Sources/AnimalKingdomAPI/Generated/Operations/ClassroomPetsQuery.swift @@ -137,7 +137,7 @@ public class ClassroomPetsQuery: GraphQLQuery { public var species: String { data["species"] } public var humanName: String? { data["humanName"] } public var laysEggs: Bool { data["laysEggs"] } - public var wingspan: Int { data["wingspan"] } + public var wingspan: Float { data["wingspan"] } public struct Fragments: FragmentContainer { public let data: DataDict diff --git a/Sources/AnimalKingdomAPI/Generated/Operations/PetAdoptionMutation.swift b/Sources/AnimalKingdomAPI/Generated/Operations/PetAdoptionMutation.swift new file mode 100644 index 0000000000..00d4f89627 --- /dev/null +++ b/Sources/AnimalKingdomAPI/Generated/Operations/PetAdoptionMutation.swift @@ -0,0 +1,56 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public class PetAdoptionMutation: GraphQLMutation { + public let operationName: String = "PetAdoptionMutation" + public let document: DocumentType = .notPersisted( + definition: .init( + """ + mutation PetAdoptionMutation($input: PetAdoptionInput!) { + adoptPet(input: $input) { + id + humanName + } + } + """ + )) + + public var input: PetAdoptionInput + + public init(input: PetAdoptionInput) { + self.input = input + } + + public var variables: Variables? { + ["input": input] + } + + public struct Data: AnimalKingdomAPI.SelectionSet { + public let data: DataDict + public init(data: DataDict) { self.data = data } + + public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Mutation.self) } + public static var selections: [Selection] { [ + .field("adoptPet", AdoptPet.self, arguments: ["input": .variable("input")]), + ] } + + public var adoptPet: AdoptPet { data["adoptPet"] } + + /// AdoptPet + public struct AdoptPet: AnimalKingdomAPI.SelectionSet { + public let data: DataDict + public init(data: DataDict) { self.data = data } + + public static var __parentType: ParentType { .Interface(AnimalKingdomAPI.Pet.self) } + public static var selections: [Selection] { [ + .field("id", ID.self), + .field("humanName", String?.self), + ] } + + public var id: ID { data["id"] } + public var humanName: String? { data["humanName"] } + } + } +} \ No newline at end of file diff --git a/Sources/AnimalKingdomAPI/Generated/Operations/PetSearchQuery.swift b/Sources/AnimalKingdomAPI/Generated/Operations/PetSearchQuery.swift new file mode 100644 index 0000000000..daa1c10cf6 --- /dev/null +++ b/Sources/AnimalKingdomAPI/Generated/Operations/PetSearchQuery.swift @@ -0,0 +1,67 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public class PetSearchQuery: GraphQLQuery { + public let operationName: String = "PetSearch" + public let document: DocumentType = .notPersisted( + definition: .init( + """ + query PetSearch($filters: PetSearchFilters = {species: ["Dog", "Cat"], size: SMALL, measurements: {height: 10.5, weight: 5.0}}) { + pets(filters: $filters) { + id + humanName + } + } + """ + )) + + public var filters: GraphQLNullable + + public init(filters: GraphQLNullable = .init( + PetSearchFilters( + species: ["Dog", "Cat"], + size: .init(.SMALL), + measurements: .init( + MeasurementsInput( + height: 10.5, + weight: 5.0 + ) + ) + ) + )) { + self.filters = filters + } + + public var variables: Variables? { + ["filters": filters] + } + + public struct Data: AnimalKingdomAPI.SelectionSet { + public let data: DataDict + public init(data: DataDict) { self.data = data } + + public static var __parentType: ParentType { .Object(AnimalKingdomAPI.Query.self) } + public static var selections: [Selection] { [ + .field("pets", [Pet].self, arguments: ["filters": .variable("filters")]), + ] } + + public var pets: [Pet] { data["pets"] } + + /// Pet + public struct Pet: AnimalKingdomAPI.SelectionSet { + public let data: DataDict + public init(data: DataDict) { self.data = data } + + public static var __parentType: ParentType { .Interface(AnimalKingdomAPI.Pet.self) } + public static var selections: [Selection] { [ + .field("id", ID.self), + .field("humanName", String?.self), + ] } + + public var id: ID { data["id"] } + public var humanName: String? { data["humanName"] } + } + } +} \ No newline at end of file diff --git a/Sources/AnimalKingdomAPI/Generated/Package.swift b/Sources/AnimalKingdomAPI/Generated/Package.swift index d8256797c0..35825a33ea 100644 --- a/Sources/AnimalKingdomAPI/Generated/Package.swift +++ b/Sources/AnimalKingdomAPI/Generated/Package.swift @@ -14,7 +14,7 @@ let package = Package( .library(name: "AnimalKingdomAPI", targets: ["AnimalKingdomAPI"]), ], dependencies: [ - .package(url: "https://github.com/apollographql/apollo-ios.git", .branch("release/1.0-alpha-incubating")), + .package(url: "https://github.com/apollographql/apollo-ios.git", from: "1.0.0-alpha.1"), ], targets: [ .target( @@ -25,4 +25,4 @@ let package = Package( path: "." ), ] -) +) \ No newline at end of file diff --git a/Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/MeasurementsInput.swift b/Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/MeasurementsInput.swift new file mode 100644 index 0000000000..18322169ad --- /dev/null +++ b/Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/MeasurementsInput.swift @@ -0,0 +1,39 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public struct MeasurementsInput: InputObject { + public private(set) var data: InputDict + + public init(_ data: InputDict) { + self.data = data + } + + public init( + height: Float, + weight: Float, + wingspan: GraphQLNullable = nil + ) { + data = InputDict([ + "height": height, + "weight": weight, + "wingspan": wingspan + ]) + } + + public var height: Float { + get { data.height } + set { data.height = newValue } + } + + public var weight: Float { + get { data.weight } + set { data.weight = newValue } + } + + public var wingspan: GraphQLNullable { + get { data.wingspan } + set { data.wingspan = newValue } + } +} \ No newline at end of file diff --git a/Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/PetAdoptionInput.swift b/Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/PetAdoptionInput.swift new file mode 100644 index 0000000000..4a68fe3ae9 --- /dev/null +++ b/Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/PetAdoptionInput.swift @@ -0,0 +1,60 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public struct PetAdoptionInput: InputObject { + public private(set) var data: InputDict + + public init(_ data: InputDict) { + self.data = data + } + + public init( + ownerID: ID, + petID: ID, + humanName: GraphQLNullable = nil, + favoriteToy: String, + isSpayedOrNeutered: Bool?, + measurements: GraphQLNullable = nil + ) { + data = InputDict([ + "ownerID": ownerID, + "petID": petID, + "humanName": humanName, + "favoriteToy": favoriteToy, + "isSpayedOrNeutered": isSpayedOrNeutered, + "measurements": measurements + ]) + } + + public var ownerID: ID { + get { data.ownerID } + set { data.ownerID = newValue } + } + + public var petID: ID { + get { data.petID } + set { data.petID = newValue } + } + + public var humanName: GraphQLNullable { + get { data.humanName } + set { data.humanName = newValue } + } + + public var favoriteToy: String { + get { data.favoriteToy } + set { data.favoriteToy = newValue } + } + + public var isSpayedOrNeutered: Bool? { + get { data.isSpayedOrNeutered } + set { data.isSpayedOrNeutered = newValue } + } + + public var measurements: GraphQLNullable { + get { data.measurements } + set { data.measurements = newValue } + } +} \ No newline at end of file diff --git a/Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/PetSearchFilters.swift b/Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/PetSearchFilters.swift new file mode 100644 index 0000000000..87ee858ce3 --- /dev/null +++ b/Sources/AnimalKingdomAPI/Generated/Schema/InputObjects/PetSearchFilters.swift @@ -0,0 +1,39 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public struct PetSearchFilters: InputObject { + public private(set) var data: InputDict + + public init(_ data: InputDict) { + self.data = data + } + + public init( + species: [String], + size: GraphQLNullable> = nil, + measurements: GraphQLNullable = nil + ) { + data = InputDict([ + "species": species, + "size": size, + "measurements": measurements + ]) + } + + public var species: [String] { + get { data.species } + set { data.species = newValue } + } + + public var size: GraphQLNullable> { + get { data.size } + set { data.size = newValue } + } + + public var measurements: GraphQLNullable { + get { data.measurements } + set { data.measurements = newValue } + } +} \ No newline at end of file diff --git a/Sources/AnimalKingdomAPI/Generated/Schema/Objects/Mutation.swift b/Sources/AnimalKingdomAPI/Generated/Schema/Objects/Mutation.swift new file mode 100644 index 0000000000..89e6dffd92 --- /dev/null +++ b/Sources/AnimalKingdomAPI/Generated/Schema/Objects/Mutation.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public final class Mutation: Object { + override public class var __typename: String { "Mutation" } + + override public class var __metadata: Metadata { _metadata } + private static let _metadata: Metadata = Metadata(implements: [ + ]) +} \ No newline at end of file diff --git a/Sources/AnimalKingdomAPI/Generated/Schema/Schema.swift b/Sources/AnimalKingdomAPI/Generated/Schema/Schema.swift index d5ca415e6d..9b302ad99d 100644 --- a/Sources/AnimalKingdomAPI/Generated/Schema/Schema.swift +++ b/Sources/AnimalKingdomAPI/Generated/Schema/Schema.swift @@ -15,6 +15,7 @@ public enum Schema: SchemaConfiguration { public static func objectType(forTypename __typename: String) -> Object.Type? { switch __typename { case "Query": return AnimalKingdomAPI.Query.self + case "Mutation": return AnimalKingdomAPI.Mutation.self case "Cat": return AnimalKingdomAPI.Cat.self case "Bird": return AnimalKingdomAPI.Bird.self case "Rat": return AnimalKingdomAPI.Rat.self diff --git a/Sources/AnimalKingdomAPI/graphql/AnimalSchema.graphqls b/Sources/AnimalKingdomAPI/graphql/AnimalSchema.graphqls index 1c7f70a32d..3ed4adf1cb 100644 --- a/Sources/AnimalKingdomAPI/graphql/AnimalSchema.graphqls +++ b/Sources/AnimalKingdomAPI/graphql/AnimalSchema.graphqls @@ -1,10 +1,37 @@ type Query { allAnimals: [Animal!]! - allPets: [Pet!]! classroomPets: [ClassroomPet!]! + pets(filters: PetSearchFilters!): [Pet!]! +} + +type Mutation { + adoptPet(input: PetAdoptionInput!): Pet! +} + +input PetAdoptionInput { + ownerID: ID! + petID: ID! + "The given name the pet is called by its human." + humanName: String + favoriteToy: String! + isSpayedOrNeutered: Boolean! = false + measurements: MeasurementsInput +} + +input MeasurementsInput { + height: Float! + weight: Float! + wingspan: Float +} + +input PetSearchFilters { + species: [String!]! + size: RelativeSize + measurements: MeasurementsInput } interface Animal { + id: ID! species: String! height: Height! predators: [Animal!]! @@ -12,12 +39,14 @@ interface Animal { } interface Pet { + id: ID! humanName: String favoriteToy: String! owner: Human } interface HousePet implements Animal & Pet { + id: ID! species: String! height: Height! predators: [Animal!]! @@ -31,6 +60,7 @@ interface HousePet implements Animal & Pet { } interface WarmBlooded implements Animal { + id: ID! species: String! height: Height! predators: [Animal!]! @@ -49,6 +79,7 @@ type Height { } type Human implements Animal & WarmBlooded { + id: ID! firstName: String! species: String! height: Height! @@ -59,6 +90,7 @@ type Human implements Animal & WarmBlooded { } type Cat implements Animal & Pet & WarmBlooded { + id: ID! species: String! height: Height! predators: [Animal!]! @@ -72,6 +104,7 @@ type Cat implements Animal & Pet & WarmBlooded { } type Dog implements Animal & Pet & HousePet & WarmBlooded { + id: ID! species: String! height: Height! predators: [Animal!]! @@ -87,6 +120,7 @@ type Dog implements Animal & Pet & HousePet & WarmBlooded { } type Bird implements Animal & Pet & WarmBlooded { + id: ID! species: String! height: Height! predators: [Animal!]! @@ -96,10 +130,11 @@ type Bird implements Animal & Pet & WarmBlooded { owner: Human bodyTemperature: Int! laysEggs: Boolean! - wingspan: Int! + wingspan: Float! } type Fish implements Animal & Pet { + id: ID! species: String! height: Height! predators: [Animal!]! @@ -110,6 +145,7 @@ type Fish implements Animal & Pet { } type Rat implements Animal & Pet { + id: ID! species: String! height: Height! predators: [Animal!]! @@ -120,6 +156,7 @@ type Rat implements Animal & Pet { } type Crocodile implements Animal { + id: ID! species: String! height: Height! predators: [Animal!]! @@ -128,6 +165,7 @@ type Crocodile implements Animal { } type PetRock implements Pet { + id: ID! humanName: String favoriteToy: String! owner: Human diff --git a/Sources/AnimalKingdomAPI/graphql/PetAdoptionMutation.graphql b/Sources/AnimalKingdomAPI/graphql/PetAdoptionMutation.graphql new file mode 100644 index 0000000000..fbfddebe72 --- /dev/null +++ b/Sources/AnimalKingdomAPI/graphql/PetAdoptionMutation.graphql @@ -0,0 +1,6 @@ +mutation PetAdoptionMutation($input: PetAdoptionInput!) { + adoptPet(input: $input) { + id + humanName + } +} diff --git a/Sources/AnimalKingdomAPI/graphql/PetSearchQuery.graphql b/Sources/AnimalKingdomAPI/graphql/PetSearchQuery.graphql new file mode 100644 index 0000000000..6a65134cdf --- /dev/null +++ b/Sources/AnimalKingdomAPI/graphql/PetSearchQuery.graphql @@ -0,0 +1,14 @@ +query PetSearch($filters: PetSearchFilters = { + species: ["Dog", "Cat"], + size: SMALL, + measurements: { + height: 10.5, + weight: 5.0 + } + } +) { + pets(filters: $filters) { + id + humanName + } +} diff --git a/Sources/ApolloAPI/GraphQLEnum.swift b/Sources/ApolloAPI/GraphQLEnum.swift index 3e794eb84b..a589c3d2f8 100644 --- a/Sources/ApolloAPI/GraphQLEnum.swift +++ b/Sources/ApolloAPI/GraphQLEnum.swift @@ -34,6 +34,10 @@ public enum GraphQLEnum: CaseIterable, Equatable, RawRepresentable self = .case(caseValue) } + public init(_ rawValue: String) { + self.init(rawValue: rawValue) + } + /// The underlying enum case. If the value is `__unknown`, this will be `nil`. public var value: T? { switch self { diff --git a/Sources/ApolloAPI/GraphQLNullable.swift b/Sources/ApolloAPI/GraphQLNullable.swift index 65f18e30a3..2a5ab04e59 100644 --- a/Sources/ApolloAPI/GraphQLNullable.swift +++ b/Sources/ApolloAPI/GraphQLNullable.swift @@ -26,11 +26,6 @@ public enum GraphQLNullable: ExpressibleByNilLiteral { return wrapped } - public var unsafelyUnwrapped: Wrapped { - guard case let .some(wrapped) = self else { fatalError("Force unwrap Nullable value failed!") } - return wrapped - } - public subscript(dynamicMember path: KeyPath) -> T? { unwrapped?[keyPath: path] } @@ -39,3 +34,88 @@ public enum GraphQLNullable: ExpressibleByNilLiteral { self = .none } } + +// MARK: - ExpressibleBy Literal Extensions + +extension GraphQLNullable: ExpressibleByUnicodeScalarLiteral +where Wrapped: ExpressibleByUnicodeScalarLiteral { + public init(unicodeScalarLiteral value: Wrapped.UnicodeScalarLiteralType) { + self = .some(Wrapped(unicodeScalarLiteral: value)) + } +} + +extension GraphQLNullable: ExpressibleByExtendedGraphemeClusterLiteral +where Wrapped: ExpressibleByExtendedGraphemeClusterLiteral { + public init(extendedGraphemeClusterLiteral value: Wrapped.ExtendedGraphemeClusterLiteralType) { + self = .some(Wrapped(extendedGraphemeClusterLiteral: value)) + } +} + +extension GraphQLNullable: ExpressibleByStringLiteral +where Wrapped: ExpressibleByStringLiteral { + public init(stringLiteral value: Wrapped.StringLiteralType) { + self = .some(Wrapped(stringLiteral: value)) + } +} + +extension GraphQLNullable: ExpressibleByIntegerLiteral +where Wrapped: ExpressibleByIntegerLiteral { + public init(integerLiteral value: Wrapped.IntegerLiteralType) { + self = .some(Wrapped(integerLiteral: value)) + } +} + +extension GraphQLNullable: ExpressibleByFloatLiteral +where Wrapped: ExpressibleByFloatLiteral { + public init(floatLiteral value: Wrapped.FloatLiteralType) { + self = .some(Wrapped(floatLiteral: value)) + } +} + +extension GraphQLNullable: ExpressibleByBooleanLiteral +where Wrapped: ExpressibleByBooleanLiteral { + public init(booleanLiteral value: Wrapped.BooleanLiteralType) { + self = .some(Wrapped(booleanLiteral: value)) + } +} + +extension GraphQLNullable: ExpressibleByArrayLiteral +where Wrapped: _InitializableByArrayLiteralElements { + public init(arrayLiteral elements: Wrapped.ArrayLiteralElement...) { + self = .some(Wrapped(elements)) + } +} + +extension GraphQLNullable: ExpressibleByDictionaryLiteral +where Wrapped: _InitializableByDictionaryLiteralElements { + public init(dictionaryLiteral elements: (Wrapped.Key, Wrapped.Value)...) { + self = .some(Wrapped(elements)) + } +} + +public protocol _InitializableByArrayLiteralElements: ExpressibleByArrayLiteral { + init(_ array: [ArrayLiteralElement]) +} +extension Array: _InitializableByArrayLiteralElements {} + +public protocol _InitializableByDictionaryLiteralElements: ExpressibleByDictionaryLiteral { + init(_ elements: [(Key, Value)]) +} + +extension Dictionary: _InitializableByDictionaryLiteralElements { + public init(_ elements: [(Key, Value)]) { + self.init(uniqueKeysWithValues: elements) + } +} + +// MARK: - Custom Type Initialization + +public extension GraphQLNullable { + init(_ caseValue: T) where Wrapped == GraphQLEnum { + self = .some(Wrapped(caseValue)) + } + + init(_ object: Wrapped) where Wrapped: InputObject { + self = .some(object) + } +} diff --git a/Sources/ApolloAPI/GraphQLOperation.swift b/Sources/ApolloAPI/GraphQLOperation.swift index 66fe50b050..f968fbf12e 100644 --- a/Sources/ApolloAPI/GraphQLOperation.swift +++ b/Sources/ApolloAPI/GraphQLOperation.swift @@ -127,12 +127,21 @@ extension Dictionary: GraphQLOperationVariableValue where Key == String, Value = } } -extension GraphQLNullable: GraphQLOperationVariableValue where Wrapped: JSONEncodable { +extension GraphQLNullable: GraphQLOperationVariableValue where Wrapped: GraphQLOperationVariableValue { public var jsonEncodableValue: JSONEncodable? { switch self { case .none: return nil case .null: return NSNull() - case let .some(value): return value + case let .some(value): return value.jsonEncodableValue + } + } +} + +extension Optional: GraphQLOperationVariableValue where Wrapped: GraphQLOperationVariableValue { + public var jsonEncodableValue: JSONEncodable? { + switch self { + case .none: return nil + case let .some(value): return value.jsonEncodableValue } } } diff --git a/Sources/ApolloAPI/InputObject.swift b/Sources/ApolloAPI/InputObject.swift index 3222c7d2a7..a9e0305f1c 100644 --- a/Sources/ApolloAPI/InputObject.swift +++ b/Sources/ApolloAPI/InputObject.swift @@ -2,14 +2,15 @@ /// /// - See: [GraphQLSpec - Input Objects](https://spec.graphql.org/draft/#sec-Input-Objects) public protocol InputObject: GraphQLOperationVariableValue { - var dict: InputDict { get } + var data: InputDict { get } } extension InputObject { - public var jsonEncodableValue: JSONEncodable? { dict.jsonEncodableValue } + public var jsonEncodableValue: JSONEncodable? { data.jsonEncodableValue } } /// A structure that wraps the underlying data dictionary used by `InputObject`s. +@dynamicMemberLookup public struct InputDict: GraphQLOperationVariableValue { private var data: [String: GraphQLOperationVariableValue] @@ -20,29 +21,9 @@ public struct InputDict: GraphQLOperationVariableValue { public var jsonEncodableValue: JSONEncodable? { data.jsonEncodableObject } - public subscript(_ key: String) -> T { - data[key] as! T - } - - public subscript(_ key: String) -> T? { - get { data[key] as? T } - set { data[key] = newValue } - } - - public subscript(_ key: String) -> [T] { - data[key] as! [T] - } - - public subscript(_ key: String) -> [T]? { - data[key] as? [T] - } - - public subscript(_ key: String) -> [[T]] { - data[key] as! [[T]] - } - - public subscript(_ key: String) -> [[T]]? { - data[key] as? [[T]] + public subscript(dynamicMember key: StaticString) -> T { + get { data[key.description] as! T } + set { data[key.description] = newValue } } } diff --git a/Sources/ApolloAPI/InputValue.swift b/Sources/ApolloAPI/InputValue.swift index 5b21b3888c..3347ae9e77 100644 --- a/Sources/ApolloAPI/InputValue.swift +++ b/Sources/ApolloAPI/InputValue.swift @@ -29,33 +29,7 @@ public indirect enum InputValue { case null } -// MARK: - InputValueConvertible - -extension InputValue: InputValueConvertible { - public init(_ value: InputValueConvertible) { - self = value.asInputValue - } - - @inlinable public var asInputValue: InputValue { self } -} - -public protocol InputValueConvertible { - @inlinable var asInputValue: InputValue { get } -} - -extension Array: InputValueConvertible where Element: InputValueConvertible { - @inlinable public var asInputValue: InputValue { .list(self.map{ $0.asInputValue })} -} - -extension Dictionary: InputValueConvertible where Key == String, Value: InputValueConvertible { - @inlinable public var asInputValue: InputValue { .object(self.mapValues { $0.asInputValue })} -} - -extension InputValueConvertible where Self: RawRepresentable, RawValue == String { - @inlinable public var asInputValue: InputValue { .scalar(rawValue) } -} - -// MARK: - Expressible as literals +// MARK: - ExpressibleBy Literal Extensions extension InputValue: ExpressibleByStringLiteral { @inlinable public init(stringLiteral value: StringLiteralType) { @@ -82,14 +56,14 @@ extension InputValue: ExpressibleByBooleanLiteral { } extension InputValue: ExpressibleByArrayLiteral { - @inlinable public init(arrayLiteral elements: InputValueConvertible...) { - self = .list(Array(elements.map { $0.asInputValue })) + @inlinable public init(arrayLiteral elements: InputValue...) { + self = .list(Array(elements.map { $0 })) } } extension InputValue: ExpressibleByDictionaryLiteral { - @inlinable public init(dictionaryLiteral elements: (String, InputValueConvertible)...) { - self = .object(Dictionary(elements.map{ ($0.0, $0.1.asInputValue) }, + @inlinable public init(dictionaryLiteral elements: (String, InputValue)...) { + self = .object(Dictionary(elements.map{ ($0.0, $0.1) }, uniquingKeysWith: { (_, last) in last })) } } diff --git a/Sources/ApolloAPI/ScalarTypes.swift b/Sources/ApolloAPI/ScalarTypes.swift index 3072af2ad7..f973dd26d2 100644 --- a/Sources/ApolloAPI/ScalarTypes.swift +++ b/Sources/ApolloAPI/ScalarTypes.swift @@ -5,7 +5,6 @@ public protocol ScalarType: JSONDecodable, JSONEncodable, Cacheable, - InputValueConvertible, GraphQLOperationVariableValue {} extension String: ScalarType {} @@ -17,9 +16,7 @@ extension Double: ScalarType {} extension ScalarType { public static func value(with cacheData: JSONValue, in transaction: CacheTransaction) throws -> Self { return cacheData as! Self - } - - public var asInputValue: InputValue { .scalar(self) } + } } public protocol CustomScalarType: @@ -27,7 +24,8 @@ public protocol CustomScalarType: JSONDecodable, JSONEncodable, Cacheable, - OutputTypeConvertible + OutputTypeConvertible, + GraphQLOperationVariableValue { var jsonValue: Any { get } } diff --git a/Sources/ApolloCodegenLib/Frontend/CompilationResult.swift b/Sources/ApolloCodegenLib/Frontend/CompilationResult.swift index 3f43296750..213804b8ac 100644 --- a/Sources/ApolloCodegenLib/Frontend/CompilationResult.swift +++ b/Sources/ApolloCodegenLib/Frontend/CompilationResult.swift @@ -238,7 +238,9 @@ public class CompilationResult: JavaScriptObject { public class Argument: JavaScriptObject, Hashable { lazy var name: String = self["name"] - + + lazy var type: GraphQLType = self["type"] + lazy var value: GraphQLValue = self["value"] public func hash(into hasher: inout Hasher) { diff --git a/Sources/ApolloCodegenLib/Frontend/GraphQLSchema.swift b/Sources/ApolloCodegenLib/Frontend/GraphQLSchema.swift index a38a3da8e3..0b2ddf8744 100644 --- a/Sources/ApolloCodegenLib/Frontend/GraphQLSchema.swift +++ b/Sources/ApolloCodegenLib/Frontend/GraphQLSchema.swift @@ -75,7 +75,7 @@ public class GraphQLInputField: JavaScriptObject { private(set) lazy var description: String? = self["description"] - lazy var defaultValue: Any? = self["defaultValue"] + lazy var defaultValue: GraphQLValue? = (self["astNode"] as JavaScriptObject)["defaultValue"] private(set) lazy var deprecationReason: String? = self["deprecationReason"] } diff --git a/Sources/ApolloCodegenLib/Frontend/GraphQLValue.swift b/Sources/ApolloCodegenLib/Frontend/GraphQLValue.swift index 533c7fb0b2..c22fb4a145 100644 --- a/Sources/ApolloCodegenLib/Frontend/GraphQLValue.swift +++ b/Sources/ApolloCodegenLib/Frontend/GraphQLValue.swift @@ -1,5 +1,6 @@ import Foundation import JavaScriptCore +import OrderedCollections indirect enum GraphQLValue: Hashable { case variable(String) @@ -10,7 +11,7 @@ indirect enum GraphQLValue: Hashable { case null case `enum`(String) case list([GraphQLValue]) - case object([String: GraphQLValue]) + case object(OrderedDictionary) } extension GraphQLValue: JavaScriptValueDecodable { diff --git a/Sources/ApolloCodegenLib/Frontend/JavaScript/src/compiler/index.ts b/Sources/ApolloCodegenLib/Frontend/JavaScript/src/compiler/index.ts index 89b77f04e3..2bacb53731 100644 --- a/Sources/ApolloCodegenLib/Frontend/JavaScript/src/compiler/index.ts +++ b/Sources/ApolloCodegenLib/Frontend/JavaScript/src/compiler/index.ts @@ -10,11 +10,13 @@ import { getNamedType, GraphQLCompositeType, GraphQLError, + GraphQLInputObjectType, GraphQLNamedType, GraphQLObjectType, GraphQLSchema, GraphQLType, isCompositeType, + isInputObjectType, isUnionType, Kind, OperationDefinitionNode, @@ -82,6 +84,10 @@ export function compileToIR( referencedTypes.add(getNamedType(type)) } } + + if (isInputObjectType(type)) { + addReferencedTypesFromInputObject(type) + } } function getFragment(name: string): ir.FragmentDefinition | undefined { @@ -113,6 +119,7 @@ export function compileToIR( const variables = (operationDefinition.variableDefinitions || []).map( (node) => { const name = node.variable.name.value; + const defaultValue = node.defaultValue ? valueFromValueNode(node.defaultValue) : undefined // The casts are a workaround for the lack of support for passing a type union // to overloaded functions in TypeScript. @@ -124,7 +131,7 @@ export function compileToIR( if (!type) { throw new GraphQLError( `Couldn't get type from type node "${node.type}"`, - node + { nodes: node } ); } @@ -133,6 +140,7 @@ export function compileToIR( return { name, type, + defaultValue }; } ); @@ -212,7 +220,7 @@ export function compileToIR( if (!fieldDef) { throw new GraphQLError( `Cannot query field "${name}" on type "${String(parentType)}"`, - selectionNode + { nodes: selectionNode } ); } @@ -230,7 +238,15 @@ export function compileToIR( const argDef = fieldDef.args.find( (argDef) => argDef.name === arg.name.value ); - const argDefType = (argDef && argDef.type) || undefined; + const argDefType = argDef?.type; + + if (!argDefType) { + throw new GraphQLError( + `Cannot find argument type for argument "${name}" on field "${selectionNode.name.value}"`, + { nodes: [selectionNode, arg] } + ) + } + return { name, value: valueFromValueNode(arg.value), @@ -306,4 +322,16 @@ export function compileToIR( } } } + + function addReferencedTypesFromInputObject( + inputObject: GraphQLInputObjectType + ) { + const fields = inputObject.astNode?.fields + if (fields) { + for (const field of fields) { + const type = typeFromAST(schema, field.type) as GraphQLType + addReferencedType(getNamedType(type)) + } + } + } } diff --git a/Sources/ApolloCodegenLib/Frontend/JavaScript/src/compiler/ir.ts b/Sources/ApolloCodegenLib/Frontend/JavaScript/src/compiler/ir.ts index b78026101c..1aeae3537d 100644 --- a/Sources/ApolloCodegenLib/Frontend/JavaScript/src/compiler/ir.ts +++ b/Sources/ApolloCodegenLib/Frontend/JavaScript/src/compiler/ir.ts @@ -55,7 +55,7 @@ export interface Field { export interface Argument { name: string; value: GraphQLValue; - type?: GraphQLInputType; + type: GraphQLInputType; } export interface InlineFragment { diff --git a/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js b/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js index c5c84d92d5..158cc16098 100644 --- a/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js +++ b/Sources/ApolloCodegenLib/Frontend/dist/ApolloCodegenFrontend.bundle.js @@ -1 +1 @@ -var ApolloCodegenFrontend=function(e){"use strict";function t(e,t){if(!Boolean(e))throw new Error(t)}function n(e){return"object"==typeof e&&null!==e}function r(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}const i=/\r\n|[\n\r]/g;function o(e,t){let n=0,o=1;for(const s of e.body.matchAll(i)){if("number"==typeof s.index||r(!1),s.index>=t)break;n=s.index+s[0].length,o+=1}return{line:o,column:t+1-n}}function s(e,t){const n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,o=e.locationOffset.line-1,s=t.line+o,c=1===t.line?n:0,u=t.column+c,l=`${e.name}:${s}:${u}\n`,p=r.split(/\r\n|[\n\r]/g),d=p[i];if(d.length>120){const e=Math.floor(u/80),t=u%80,n=[];for(let e=0;e["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return l+a([[s-1+" |",p[i-1]],[`${s} |`,d],["|","^".padStart(u)],[`${s+1} |`,p[i+1]]])}function a(e){const t=e.filter((([e,t])=>void 0!==t)),n=Math.max(...t.map((([e])=>e.length)));return t.map((([e,t])=>e.padStart(n)+(t?" "+t:""))).join("\n")}class GraphQLError extends Error{constructor(e,...t){var r,i,s;const{nodes:a,source:u,positions:l,path:p,originalError:d,extensions:f}=function(e){const t=e[0];return null==t||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}(t);super(e),this.name="GraphQLError",this.path=null!=p?p:void 0,this.originalError=null!=d?d:void 0,this.nodes=c(Array.isArray(a)?a:a?[a]:void 0);const h=c(null===(r=this.nodes)||void 0===r?void 0:r.map((e=>e.loc)).filter((e=>null!=e)));this.source=null!=u?u:null==h||null===(i=h[0])||void 0===i?void 0:i.source,this.positions=null!=l?l:null==h?void 0:h.map((e=>e.start)),this.locations=l&&u?l.map((e=>o(u,e))):null==h?void 0:h.map((e=>o(e.source,e.start)));const m=n(null==d?void 0:d.extensions)?null==d?void 0:d.extensions:void 0;this.extensions=null!==(s=null!=f?f:m)&&void 0!==s?s:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),null!=d&&d.stack?Object.defineProperty(this,"stack",{value:d.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,GraphQLError):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(e+="\n\n"+s((t=n.loc).source,o(t.source,t.start)));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+s(this.source,t);var t;return e}toJSON(){const e={message:this.message};return null!=this.locations&&(e.locations=this.locations),null!=this.path&&(e.path=this.path),null!=this.extensions&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function c(e){return void 0===e||0===e.length?void 0:e}function u(e,t,n){return new GraphQLError(`Syntax Error: ${n}`,void 0,e,[t])}class Location{constructor(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class Token{constructor(e,t,n,r,i,o){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=o,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const l={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"]},p=new Set(Object.keys(l));function d(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&p.has(t)}let f,h,m,v;function y(e){return 9===e||32===e}function E(e){return e>=48&&e<=57}function T(e){return e>=97&&e<=122||e>=65&&e<=90}function N(e){return T(e)||95===e}function I(e){return T(e)||E(e)||95===e}function g(e){var t;let n=Number.MAX_SAFE_INTEGER,r=null,i=-1;for(let t=0;t0===t?e:e.slice(n))).slice(null!==(t=r)&&void 0!==t?t:0,i+1)}function _(e){let t=0;for(;t",e.EOF="",e.BANG="!",e.DOLLAR="$",e.AMP="&",e.PAREN_L="(",e.PAREN_R=")",e.SPREAD="...",e.COLON=":",e.EQUALS="=",e.AT="@",e.BRACKET_L="[",e.BRACKET_R="]",e.BRACE_L="{",e.PIPE="|",e.BRACE_R="}",e.NAME="Name",e.INT="Int",e.FLOAT="Float",e.STRING="String",e.BLOCK_STRING="BlockString",e.COMMENT="Comment"}(v||(v={}));class Lexer{constructor(e){const t=new Token(v.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){this.lastToken=this.token;return this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==v.EOF)do{if(e.next)e=e.next;else{const t=x(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===v.COMMENT);return e}}function O(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function S(e,t){return L(e.charCodeAt(t))&&A(e.charCodeAt(t+1))}function L(e){return e>=55296&&e<=56319}function A(e){return e>=56320&&e<=57343}function D(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return v.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function w(e,t,n,r,i){const o=e.line,s=1+n-e.lineStart;return new Token(t,n,r,o,s,i)}function x(e,t){const n=e.source.body,r=n.length;let i=t;for(;i=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function U(e,t){const n=e.source.body;switch(n.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:"\n",size:2};case 114:return{value:"\r",size:2};case 116:return{value:"\t",size:2}}throw u(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function V(e,t){const n=e.source.body,r=n.length;let i=e.lineStart,o=t+3,s=o,a="";const c=[];for(;o2)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.entries(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)+"]";const r=n.map((([e,n])=>e+": "+B(n,t)));return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}const Y=function(e,t){return e instanceof t};class Source{constructor(e,n="GraphQL request",r={line:1,column:1}){"string"==typeof e||t(!1,`Body must be a string. Received: ${P(e)}.`),this.body=e,this.name=n,this.locationOffset=r,this.locationOffset.line>0||t(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||t(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function J(e,t){return new Parser(e,t).parseDocument()}class Parser{constructor(e,t){const n=function(e){return Y(e,Source)}(e)?e:new Source(e);this._lexer=new Lexer(n),this._options=t}parseName(){const e=this.expectToken(v.NAME);return this.node(e,{kind:m.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:m.DOCUMENT,definitions:this.many(v.SOF,this.parseDefinition,v.EOF)})}parseDefinition(){if(this.peek(v.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===v.NAME){switch(t.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()}if(e)throw u(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(t.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(t)}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(v.BRACE_L))return this.node(e,{kind:m.OPERATION_DEFINITION,operation:f.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(v.NAME)&&(n=this.parseName()),this.node(e,{kind:m.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(v.NAME);switch(e.value){case"query":return f.QUERY;case"mutation":return f.MUTATION;case"subscription":return f.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(v.PAREN_L,this.parseVariableDefinition,v.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:m.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(v.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(v.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(v.DOLLAR),this.node(e,{kind:m.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:m.SELECTION_SET,selections:this.many(v.BRACE_L,this.parseSelection,v.BRACE_R)})}parseSelection(){return this.peek(v.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(v.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:m.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(v.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(v.PAREN_L,t,v.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(v.COLON),this.node(t,{kind:m.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(v.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(v.NAME)?this.node(e,{kind:m.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:m.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){var e;const t=this._lexer.token;return this.expectKeyword("fragment"),!0===(null===(e=this._options)||void 0===e?void 0:e.allowLegacyFragmentVariables)?this.node(t,{kind:m.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(t,{kind:m.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()}parseValueLiteral(e){const t=this._lexer.token;switch(t.kind){case v.BRACKET_L:return this.parseList(e);case v.BRACE_L:return this.parseObject(e);case v.INT:return this._lexer.advance(),this.node(t,{kind:m.INT,value:t.value});case v.FLOAT:return this._lexer.advance(),this.node(t,{kind:m.FLOAT,value:t.value});case v.STRING:case v.BLOCK_STRING:return this.parseStringLiteral();case v.NAME:switch(this._lexer.advance(),t.value){case"true":return this.node(t,{kind:m.BOOLEAN,value:!0});case"false":return this.node(t,{kind:m.BOOLEAN,value:!1});case"null":return this.node(t,{kind:m.NULL});default:return this.node(t,{kind:m.ENUM,value:t.value})}case v.DOLLAR:if(e){if(this.expectToken(v.DOLLAR),this._lexer.token.kind===v.NAME){const e=this._lexer.token.value;throw u(this._lexer.source,t.start,`Unexpected variable "$${e}" in constant value.`)}throw this.unexpected(t)}return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const e=this._lexer.token;return this._lexer.advance(),this.node(e,{kind:m.STRING,value:e.value,block:e.kind===v.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:m.LIST,values:this.any(v.BRACKET_L,(()=>this.parseValueLiteral(e)),v.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:m.OBJECT,fields:this.any(v.BRACE_L,(()=>this.parseObjectField(e)),v.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(v.COLON),this.node(t,{kind:m.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(v.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(v.AT),this.node(t,{kind:m.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(v.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(v.BRACKET_R),t=this.node(e,{kind:m.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(v.BANG)?this.node(e,{kind:m.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:m.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(v.STRING)||this.peek(v.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");const n=this.parseConstDirectives(),r=this.many(v.BRACE_L,this.parseOperationTypeDefinition,v.BRACE_R);return this.node(e,{kind:m.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(v.COLON);const n=this.parseNamedType();return this.node(e,{kind:m.OPERATION_TYPE_DEFINITION,operation:t,type:n})}parseScalarTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");const n=this.parseName(),r=this.parseConstDirectives();return this.node(e,{kind:m.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r})}parseObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(e,{kind:m.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(v.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(v.BRACE_L,this.parseFieldDefinition,v.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(v.COLON);const i=this.parseTypeReference(),o=this.parseConstDirectives();return this.node(e,{kind:m.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o})}parseArgumentDefs(){return this.optionalMany(v.PAREN_L,this.parseInputValueDef,v.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(v.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(v.EQUALS)&&(i=this.parseConstValueLiteral());const o=this.parseConstDirectives();return this.node(e,{kind:m.INPUT_VALUE_DEFINITION,description:t,name:n,type:r,defaultValue:i,directives:o})}parseInterfaceTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(e,{kind:m.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o})}parseUnionTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();return this.node(e,{kind:m.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(v.EQUALS)?this.delimitedMany(v.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();return this.node(e,{kind:m.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(v.BRACE_L,this.parseEnumValueDefinition,v.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:m.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r})}parseEnumValueName(){if("true"===this._lexer.token.value||"false"===this._lexer.token.value||"null"===this._lexer.token.value)throw u(this._lexer.source,this._lexer.token.start,`${q(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();return this.node(e,{kind:m.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(v.BRACE_L,this.parseInputValueDef,v.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===v.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.parseConstDirectives(),n=this.optionalMany(v.BRACE_L,this.parseOperationTypeDefinition,v.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:m.SCHEMA_EXTENSION,directives:t,operationTypes:n})}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const t=this.parseName(),n=this.parseConstDirectives();if(0===n.length)throw this.unexpected();return this.node(e,{kind:m.SCALAR_TYPE_EXTENSION,name:t,directives:n})}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:m.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:m.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:m.UNION_TYPE_EXTENSION,name:t,directives:n,types:r})}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:m.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r})}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:m.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(v.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const o=this.parseDirectiveLocations();return this.node(e,{kind:m.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o})}parseDirectiveLocations(){return this.delimitedMany(v.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(h,t.value))return t;throw this.unexpected(e)}node(e,t){var n;return!0!==(null===(n=this._options)||void 0===n?void 0:n.noLocation)&&(t.loc=new Location(e,this._lexer.lastToken,this._lexer.source)),t}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 u(this._lexer.source,t.start,`Expected ${X(e)}, found ${q(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this._lexer.advance(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==v.NAME||t.value!==e)throw u(this._lexer.source,t.start,`Expected "${e}", found ${q(t)}.`);this._lexer.advance()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===v.NAME&&t.value===e&&(this._lexer.advance(),!0)}unexpected(e){const t=null!=e?e:this._lexer.token;return u(this._lexer.source,t.start,`Unexpected ${q(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 q(e){const t=e.value;return X(e.kind)+(null!=t?` "${t}"`:"")}function X(e){return function(e){return e===v.BANG||e===v.DOLLAR||e===v.AMP||e===v.PAREN_L||e===v.PAREN_R||e===v.SPREAD||e===v.COLON||e===v.EQUALS||e===v.AT||e===v.BRACKET_L||e===v.BRACKET_R||e===v.BRACE_L||e===v.PIPE||e===v.BRACE_R}(e)?`"${e}"`:e}function K(e,t){const[n,r]=t?[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 z(e){return e}function H(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function W(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function Z(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function ee(e,t){let n=0,r=0;for(;n0);let a=0;do{++r,a=10*a+o-te,o=t.charCodeAt(r)}while(ne(o)&&a>0);if(sa)return 1}else{if(io)return 1;++n,++r}}return e.length-t.length}const te=48;function ne(e){return!isNaN(e)&&te<=e&&e<=57}function re(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:ee(e,t)}))}class LexicalDistance{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=ie(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=ie(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 ie(e){const t=e.length,n=new Array(t);for(let r=0;re.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>me(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=ye("(",me(e.variableDefinitions,", "),")"),n=me([e.operation,me([e.name,t]),me(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+ye(" = ",n)+ye(" ",me(r," "))},SelectionSet:{leave:({selections:e})=>ve(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const o=ye("",e,": ")+t;let s=o+ye("(",me(n,", "),")");return s.length>80&&(s=o+ye("(\n",Ee(me(n,"\n")),"\n)")),me([s,me(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+ye(" ",me(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>me(["...",ye("on ",e),me(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${ye("(",me(n,", "),")")} on ${t} ${ye("",me(r," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?function(e,t){const n=e.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),i=1===r.length,o=r.length>1&&r.slice(1).every((e=>0===e.length||y(e.charCodeAt(0)))),s=n.endsWith('\\"""'),a=e.endsWith('"')&&!s,c=e.endsWith("\\"),u=a||c,l=!(null!=t&&t.minimize)&&(!i||e.length>70||u||o||s);let p="";const d=i&&y(e.charCodeAt(0));return(l&&!d||o)&&(p+="\n"),p+=n,(l||u)&&(p+="\n"),'"""'+p+'"""'}(e):`"${e.replace(se,ae)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+me(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+me(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+ye("(",me(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>ye("",e,"\n")+me(["schema",me(t," "),ve(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>ye("",e,"\n")+me(["scalar",t,me(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ye("",e,"\n")+me(["type",t,ye("implements ",me(n," & ")),me(r," "),ve(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>ye("",e,"\n")+t+(Te(n)?ye("(\n",Ee(me(n,"\n")),"\n)"):ye("(",me(n,", "),")"))+": "+r+ye(" ",me(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>ye("",e,"\n")+me([t+": "+n,ye("= ",r),me(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ye("",e,"\n")+me(["interface",t,ye("implements ",me(n," & ")),me(r," "),ve(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>ye("",e,"\n")+me(["union",t,me(n," "),ye("= ",me(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>ye("",e,"\n")+me(["enum",t,me(n," "),ve(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>ye("",e,"\n")+me([t,me(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>ye("",e,"\n")+me(["input",t,me(n," "),ve(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>ye("",e,"\n")+"directive @"+t+(Te(n)?ye("(\n",Ee(me(n,"\n")),"\n)"):ye("(",me(n,", "),")"))+(r?" repeatable":"")+" on "+me(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>me(["extend schema",me(e," "),ve(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>me(["extend scalar",e,me(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>me(["extend type",e,ye("implements ",me(t," & ")),me(n," "),ve(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>me(["extend interface",e,ye("implements ",me(t," & ")),me(n," "),ve(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>me(["extend union",e,me(t," "),ye("= ",me(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>me(["extend enum",e,me(t," "),ve(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>me(["extend input",e,me(t," "),ve(n)]," ")}};function me(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function ve(e){return ye("{\n",Ee(me(e,"\n")),"\n}")}function ye(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function Ee(e){return ye(" ",e.replace(/\n/g,"\n "))}function Te(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}function Ne(e,t){switch(e.kind){case m.NULL:return null;case m.INT:return parseInt(e.value,10);case m.FLOAT:return parseFloat(e.value);case m.STRING:case m.ENUM:case m.BOOLEAN:return e.value;case m.LIST:return e.values.map((e=>Ne(e,t)));case m.OBJECT:return W(e.fields,(e=>e.name.value),(e=>Ne(e.value,t)));case m.VARIABLE:return null==t?void 0:t[e.name.value]}}function Ie(e){if(null!=e||t(!1,"Must provide name."),"string"==typeof e||t(!1,"Expected name to be a string."),0===e.length)throw new GraphQLError("Expected name to be a non-empty string.");for(let t=1;ts(Ne(e,t)),this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(o=e.extensionASTNodes)&&void 0!==o?o:[],null==e.specifiedByURL||"string"==typeof e.specifiedByURL||t(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${P(e.specifiedByURL)}.`),null==e.serialize||"function"==typeof e.serialize||t(!1,`${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||t(!1,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`))}get[Symbol.toStringTag](){return"GraphQLScalarType"}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()}}class GraphQLObjectType{constructor(e){var n;this.name=Ie(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(n=e.extensionASTNodes)&&void 0!==n?n:[],this._fields=()=>Ye(e),this._interfaces=()=>Be(e),null==e.isTypeOf||"function"==typeof e.isTypeOf||t(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${P(e.isTypeOf)}.`)}get[Symbol.toStringTag](){return"GraphQLObjectType"}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:Xe(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Be(e){var n;const r=Me(null!==(n=e.interfaces)&&void 0!==n?n:[]);return Array.isArray(r)||t(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),r}function Ye(e){const n=Pe(e.fields);return qe(n)||t(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Z(n,((n,r)=>{var i;qe(n)||t(!1,`${e.name}.${r} field config must be an object.`),null==n.resolve||"function"==typeof n.resolve||t(!1,`${e.name}.${r} field resolver must be a function if provided, but got: ${P(n.resolve)}.`);const o=null!==(i=n.args)&&void 0!==i?i:{};return qe(o)||t(!1,`${e.name}.${r} args must be an object with argument names as keys.`),{name:Ie(r),description:n.description,type:n.type,args:Je(o),resolve:n.resolve,subscribe:n.subscribe,deprecationReason:n.deprecationReason,extensions:oe(n.extensions),astNode:n.astNode}}))}function Je(e){return Object.entries(e).map((([e,t])=>({name:Ie(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:oe(t.extensions),astNode:t.astNode})))}function qe(e){return n(e)&&!Array.isArray(e)}function Xe(e){return Z(e,(e=>({description:e.description,type:e.type,args:Ke(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Ke(e){return W(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function ze(e){return xe(e.type)&&void 0===e.defaultValue}class GraphQLInterfaceType{constructor(e){var n;this.name=Ie(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(n=e.extensionASTNodes)&&void 0!==n?n:[],this._fields=Ye.bind(void 0,e),this._interfaces=Be.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||t(!1,`${this.name} must provide "resolveType" as a function, but got: ${P(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}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:Xe(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class GraphQLUnionType{constructor(e){var n;this.name=Ie(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(n=e.extensionASTNodes)&&void 0!==n?n:[],this._types=He.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||t(!1,`${this.name} must provide "resolveType" as a function, but got: ${P(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLUnionType"}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()}}function He(e){const n=Me(e.types);return Array.isArray(n)||t(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),n}class GraphQLEnumType{constructor(e){var n,r,i;this.name=Ie(e.name),this.description=e.description,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(n=e.extensionASTNodes)&&void 0!==n?n:[],this._values=(r=this.name,qe(i=e.values)||t(!1,`${r} values must be an object with value names as keys.`),Object.entries(i).map((([e,n])=>(qe(n)||t(!1,`${r}.${e} must refer to an object with a "value" key representing an internal value but got: ${P(n)}.`),{name:ge(e),description:n.description,value:void 0!==n.value?n.value:e,deprecationReason:n.deprecationReason,extensions:oe(n.extensions),astNode:n.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=H(this._values,(e=>e.name))}get[Symbol.toStringTag](){return"GraphQLEnumType"}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: ${P(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=P(e);throw new GraphQLError(`Enum "${this.name}" cannot represent non-string value: ${t}.`+We(this,t))}const t=this.getValue(e);if(null==t)throw new GraphQLError(`Value "${e}" does not exist in "${this.name}" enum.`+We(this,e));return t.value}parseLiteral(e,t){if(e.kind!==m.ENUM){const t=fe(e);throw new GraphQLError(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+We(this,t),e)}const n=this.getValue(e.value);if(null==n){const t=fe(e);throw new GraphQLError(`Value "${t}" does not exist in "${this.name}" enum.`+We(this,t),e)}return n.value}toConfig(){const e=W(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()}}function We(e,t){return K("the enum value",re(t,e.getValues().map((e=>e.name))))}class GraphQLInputObjectType{constructor(e){var t;this.name=Ie(e.name),this.description=e.description,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=Ze.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=Z(this.getFields(),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,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()}}function Ze(e){const n=Pe(e.fields);return qe(n)||t(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Z(n,((n,r)=>(!("resolve"in n)||t(!1,`${e.name}.${r} field has a resolve property, but Input Types cannot define resolvers.`),{name:Ie(r),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:oe(n.extensions),astNode:n.astNode})))}function et(e){return xe(e.type)&&void 0===e.defaultValue}function tt(e,t){return e===t||(xe(e)&&xe(t)||!(!we(e)||!we(t)))&&tt(e.ofType,t.ofType)}function nt(e,t,n){return t===n||(xe(n)?!!xe(t)&&nt(e,t.ofType,n.ofType):xe(t)?nt(e,t.ofType,n):we(n)?!!we(t)&&nt(e,t.ofType,n.ofType):!we(t)&&(Ge(n)&&(Se(t)||Oe(t))&&e.isSubType(n,t)))}function rt(e,t,n){return t===n||(Ge(t)?Ge(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!Ge(n)&&e.isSubType(n,t))}const it=2147483647,ot=-2147483648,st=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(e){const t=ft(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: ${P(t)}`);if(n>it||nit||eit||te.name===t))}function ft(e){if(n(e)){if("function"==typeof e.valueOf){const t=e.valueOf();if(!n(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}function ht(e){return Y(e,GraphQLDirective)}class GraphQLDirective{constructor(e){var r,i;this.name=Ie(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=null!==(r=e.isRepeatable)&&void 0!==r&&r,this.extensions=oe(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||t(!1,`@${e.name} locations must be an Array.`);const o=null!==(i=e.args)&&void 0!==i?i:{};n(o)&&!Array.isArray(o)||t(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=Je(o)}get[Symbol.toStringTag](){return"GraphQLDirective"}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:Ke(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const mt=new GraphQLDirective({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[h.FIELD,h.FRAGMENT_SPREAD,h.INLINE_FRAGMENT],args:{if:{type:new GraphQLNonNull(ut),description:"Included when true."}}}),vt=new GraphQLDirective({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[h.FIELD,h.FRAGMENT_SPREAD,h.INLINE_FRAGMENT],args:{if:{type:new GraphQLNonNull(ut),description:"Skipped when true."}}}),yt="No longer supported",Et=new GraphQLDirective({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[h.FIELD_DEFINITION,h.ARGUMENT_DEFINITION,h.INPUT_FIELD_DEFINITION,h.ENUM_VALUE],args:{reason:{type:ct,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:yt}}}),Tt=new GraphQLDirective({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[h.SCALAR],args:{url:{type:new GraphQLNonNull(ct),description:"The URL that specifies the behavior of this scalar."}}}),Nt=Object.freeze([mt,vt,Et,Tt]);function It(e,t){if(xe(t)){const n=It(e,t.ofType);return(null==n?void 0:n.kind)===m.NULL?null:n}if(null===e)return{kind:m.NULL};if(void 0===e)return null;if(we(t)){const n=t.ofType;if("object"==typeof(i=e)&&"function"==typeof(null==i?void 0:i[Symbol.iterator])){const t=[];for(const r of e){const e=It(r,n);null!=e&&t.push(e)}return{kind:m.LIST,values:t}}return It(e,n)}var i;if(De(t)){if(!n(e))return null;const r=[];for(const n of Object.values(t.getFields())){const t=It(e[n.name],n.type);t&&r.push({kind:m.OBJECT_FIELD,name:{kind:m.NAME,value:n.name},value:t})}return{kind:m.OBJECT,fields:r}}if(Re(t)){const n=t.serialize(e);if(null==n)return null;if("boolean"==typeof n)return{kind:m.BOOLEAN,value:n};if("number"==typeof n&&Number.isFinite(n)){const e=String(n);return gt.test(e)?{kind:m.INT,value:e}:{kind:m.FLOAT,value:e}}if("string"==typeof n)return Ae(t)?{kind:m.ENUM,value:n}:t===lt&>.test(n)?{kind:m.INT,value:n}:{kind:m.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${P(n)}.`)}r(!1,"Unexpected input type: "+P(t))}const gt=/^-?(?:0|[1-9][0-9]*)$/,_t=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:ct,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(St))),resolve:e=>Object.values(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new GraphQLNonNull(St),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:St,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:St,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(bt))),resolve:e=>e.getDirectives()}})}),bt=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(ct),resolve:e=>e.name},description:{type:ct,resolve:e=>e.description},isRepeatable:{type:new GraphQLNonNull(ut),resolve:e=>e.isRepeatable},locations:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(Ot))),resolve:e=>e.locations},args:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(At))),args:{includeDeprecated:{type:ut,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))}})}),Ot=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:h.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:h.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:h.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:h.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:h.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:h.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:h.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:h.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:h.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:h.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:h.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:h.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:h.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:h.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:h.UNION,description:"Location adjacent to a union definition."},ENUM:{value:h.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:h.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:h.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:h.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),St=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(xt),resolve:e=>be(e)?wt.SCALAR:Oe(e)?wt.OBJECT:Se(e)?wt.INTERFACE:Le(e)?wt.UNION:Ae(e)?wt.ENUM:De(e)?wt.INPUT_OBJECT:we(e)?wt.LIST:xe(e)?wt.NON_NULL:void r(!1,`Unexpected type: "${P(e)}".`)},name:{type:ct,resolve:e=>"name"in e?e.name:void 0},description:{type:ct,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:ct,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new GraphQLList(new GraphQLNonNull(Lt)),args:{includeDeprecated:{type:ut,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Oe(e)||Se(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new GraphQLList(new GraphQLNonNull(St)),resolve(e){if(Oe(e)||Se(e))return e.getInterfaces()}},possibleTypes:{type:new GraphQLList(new GraphQLNonNull(St)),resolve(e,t,n,{schema:r}){if(Ge(e))return r.getPossibleTypes(e)}},enumValues:{type:new GraphQLList(new GraphQLNonNull(Dt)),args:{includeDeprecated:{type:ut,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Ae(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new GraphQLList(new GraphQLNonNull(At)),args:{includeDeprecated:{type:ut,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(De(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:St,resolve:e=>"ofType"in e?e.ofType:void 0}})}),Lt=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(ct),resolve:e=>e.name},description:{type:ct,resolve:e=>e.description},args:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(At))),args:{includeDeprecated:{type:ut,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new GraphQLNonNull(St),resolve:e=>e.type},isDeprecated:{type:new GraphQLNonNull(ut),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:ct,resolve:e=>e.deprecationReason}})}),At=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(ct),resolve:e=>e.name},description:{type:ct,resolve:e=>e.description},type:{type:new GraphQLNonNull(St),resolve:e=>e.type},defaultValue:{type:ct,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=It(n,t);return r?fe(r):null}},isDeprecated:{type:new GraphQLNonNull(ut),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:ct,resolve:e=>e.deprecationReason}})}),Dt=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(ct),resolve:e=>e.name},description:{type:ct,resolve:e=>e.description},isDeprecated:{type:new GraphQLNonNull(ut),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:ct,resolve:e=>e.deprecationReason}})});let wt;!function(e){e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.INPUT_OBJECT="INPUT_OBJECT",e.LIST="LIST",e.NON_NULL="NON_NULL"}(wt||(wt={}));const xt=new GraphQLEnumType({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:wt.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:wt.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:wt.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:wt.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:wt.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:wt.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:wt.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:wt.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),kt={name:"__schema",type:new GraphQLNonNull(_t),description:"Access the current type schema of this server.",args:[],resolve:(e,t,n,{schema:r})=>r,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Ft={name:"__type",type:St,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new GraphQLNonNull(ct),defaultValue:void 0,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0}],resolve:(e,{name:t},n,{schema:r})=>r.getType(t),deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Rt={name:"__typename",type:new GraphQLNonNull(ct),description:"The name of the current Object type at runtime.",args:[],resolve:(e,t,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Ct=Object.freeze([_t,bt,Ot,St,Lt,At,Dt,xt]);function Gt(e){return Ct.some((({name:t})=>e.name===t))}function $t(e){if(!function(e){return Y(e,GraphQLSchema)}(e))throw new Error(`Expected ${P(e)} to be a GraphQL schema.`);return e}class GraphQLSchema{constructor(e){var r,i;this.__validationErrors=!0===e.assumeValid?[]:void 0,n(e)||t(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||t(!1,`"types" must be Array if provided but got: ${P(e.types)}.`),!e.directives||Array.isArray(e.directives)||t(!1,`"directives" must be Array if provided but got: ${P(e.directives)}.`),this.description=e.description,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(r=e.extensionASTNodes)&&void 0!==r?r:[],this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=null!==(i=e.directives)&&void 0!==i?i:Nt;const o=new Set(e.types);if(null!=e.types)for(const t of e.types)o.delete(t),Qt(t,o);null!=this._queryType&&Qt(this._queryType,o),null!=this._mutationType&&Qt(this._mutationType,o),null!=this._subscriptionType&&Qt(this._subscriptionType,o);for(const e of this._directives)if(ht(e))for(const t of e.args)Qt(t.type,o);Qt(_t,o),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const e of o){if(null==e)continue;const n=e.name;if(n||t(!1,"One of the provided types for building the Schema is missing a name."),void 0!==this._typeMap[n])throw new Error(`Schema must contain uniquely named types but contains multiple types named "${n}".`);if(this._typeMap[n]=e,Se(e)){for(const t of e.getInterfaces())if(Se(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(Oe(e))for(const t of e.getInterfaces())if(Se(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.objects.push(e)}}}get[Symbol.toStringTag](){return"GraphQLSchema"}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getRootType(e){switch(e){case f.QUERY:return this.getQueryType();case f.MUTATION:return this.getMutationType();case f.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return Le(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){const t=this._implementationsMap[e.name];return null!=t?t:{objects:[],interfaces:[]}}isSubType(e,t){let n=this._subTypeMap[e.name];if(void 0===n){if(n=Object.create(null),Le(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:Object.values(this.getTypeMap()),directives:this.getDirectives(),extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,assumeValid:void 0!==this.__validationErrors}}}function Qt(e,t){const n=Ve(e);if(!t.has(n))if(t.add(n),Le(n))for(const e of n.getTypes())Qt(e,t);else if(Oe(n)||Se(n)){for(const e of n.getInterfaces())Qt(e,t);for(const e of Object.values(n.getFields())){Qt(e.type,t);for(const n of e.args)Qt(n.type,t)}}else if(De(n))for(const e of Object.values(n.getFields()))Qt(e.type,t);return t}function jt(e){if($t(e),e.__validationErrors)return e.__validationErrors;const t=new SchemaValidationContext(e);!function(e){const t=e.schema,n=t.getQueryType();if(n){if(!Oe(n)){var r;e.reportError(`Query root type must be Object type, it cannot be ${P(n)}.`,null!==(r=Ut(t,f.QUERY))&&void 0!==r?r:n.astNode)}}else e.reportError("Query root type must be provided.",t.astNode);const i=t.getMutationType();var o;i&&!Oe(i)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${P(i)}.`,null!==(o=Ut(t,f.MUTATION))&&void 0!==o?o:i.astNode);const s=t.getSubscriptionType();var a;s&&!Oe(s)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${P(s)}.`,null!==(a=Ut(t,f.SUBSCRIPTION))&&void 0!==a?a:s.astNode)}(t),function(e){for(const n of e.schema.getDirectives())if(ht(n)){Vt(e,n);for(const r of n.args){var t;if(Vt(e,r),ke(r.type)||e.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${P(r.type)}.`,r.astNode),ze(r)&&null!=r.deprecationReason)e.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[Ht(r.astNode),null===(t=r.astNode)||void 0===t?void 0:t.type])}}else e.reportError(`Expected directive but got: ${P(n)}.`,null==n?void 0:n.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=Object.values(o.getFields());for(const t of s)if(xe(t.type)&&De(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 Object.values(n))Ue(r)?(Gt(r)||Vt(e,r),Oe(r)||Se(r)?(Mt(e,r),Pt(e,r)):Le(r)?Jt(e,r):Ae(r)?qt(e,r):De(r)&&(Xt(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${P(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._errors.push(new GraphQLError(e,n))}getErrors(){return this._errors}}function Ut(e,t){var n;return null===(n=[e.astNode,...e.extensionASTNodes].flatMap((e=>{var t;return null!==(t=null==e?void 0:e.operationTypes)&&void 0!==t?t:[]})).find((e=>e.operation===t)))||void 0===n?void 0:n.type}function Vt(e,t){t.name.startsWith("__")&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function Mt(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const s of n){var r;if(Vt(e,s),!Fe(s.type))e.reportError(`The type of ${t.name}.${s.name} must be Output Type but got: ${P(s.type)}.`,null===(r=s.astNode)||void 0===r?void 0:r.type);for(const n of s.args){const r=n.name;var i,o;if(Vt(e,n),!ke(n.type))e.reportError(`The type of ${t.name}.${s.name}(${r}:) must be Input Type but got: ${P(n.type)}.`,null===(i=n.astNode)||void 0===i?void 0:i.type);if(ze(n)&&null!=n.deprecationReason)e.reportError(`Required argument ${t.name}.${s.name}(${r}:) cannot be deprecated.`,[Ht(n.astNode),null===(o=n.astNode)||void 0===o?void 0:o.type])}}}function Pt(e,t){const n=Object.create(null);for(const r of t.getInterfaces())Se(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,Kt(t,r)):(n[r.name]=!0,Yt(e,t,r),Bt(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,Kt(t,r)):e.reportError(`Type ${P(t)} must only implement Interface types, it cannot implement ${P(r)}.`,Kt(t,r))}function Bt(e,t,n){const r=t.getFields();for(const c of Object.values(n.getFields())){const u=c.name,l=r[u];if(l){var i,o;if(!nt(e.schema,l.type,c.type))e.reportError(`Interface field ${n.name}.${u} expects type ${P(c.type)} but ${t.name}.${u} is type ${P(l.type)}.`,[null===(i=c.astNode)||void 0===i?void 0:i.type,null===(o=l.astNode)||void 0===o?void 0:o.type]);for(const r of c.args){const i=r.name,o=l.args.find((e=>e.name===i));var s,a;if(o){if(!tt(r.type,o.type))e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expects type ${P(r.type)} but ${t.name}.${u}(${i}:) is type ${P(o.type)}.`,[null===(s=r.astNode)||void 0===s?void 0:s.type,null===(a=o.astNode)||void 0===a?void 0:a.type])}else e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expected but ${t.name}.${u} does not provide it.`,[r.astNode,l.astNode])}for(const r of l.args){const i=r.name;!c.args.find((e=>e.name===i))&&ze(r)&&e.reportError(`Object field ${t.name}.${u} includes required argument ${i} that is missing from the Interface field ${n.name}.${u}.`,[r.astNode,c.astNode])}}else e.reportError(`Interface field ${n.name}.${u} expected but ${t.name} does not provide it.`,[c.astNode,t.astNode,...t.extensionASTNodes])}}function Yt(e,t,n){const r=t.getInterfaces();for(const i of n.getInterfaces())r.includes(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}.`,[...Kt(n,i),...Kt(t,n)])}function Jt(e,t){const n=t.getTypes();0===n.length&&e.reportError(`Union type ${t.name} must define one or more member types.`,[t.astNode,...t.extensionASTNodes]);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.`,zt(t,i.name)):(r[i.name]=!0,Oe(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${P(i)}.`,zt(t,String(i))))}function qt(e,t){const n=t.getValues();0===n.length&&e.reportError(`Enum type ${t.name} must define one or more values.`,[t.astNode,...t.extensionASTNodes]);for(const t of n)Vt(e,t)}function Xt(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Input Object type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const o of n){var r,i;if(Vt(e,o),!ke(o.type))e.reportError(`The type of ${t.name}.${o.name} must be Input Type but got: ${P(o.type)}.`,null===(r=o.astNode)||void 0===r?void 0:r.type);if(et(o)&&null!=o.deprecationReason)e.reportError(`Required input field ${t.name}.${o.name} cannot be deprecated.`,[Ht(o.astNode),null===(i=o.astNode)||void 0===i?void 0:i.type])}}function Kt(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.interfaces)&&void 0!==t?t:[]})).filter((e=>e.name.value===t.name))}function zt(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.types)&&void 0!==t?t:[]})).filter((e=>e.name.value===t))}function Ht(e){var t;return null==e||null===(t=e.directives)||void 0===t?void 0:t.find((e=>e.name.value===Et.name))}function Wt(e,t){switch(t.kind){case m.LIST_TYPE:{const n=Wt(e,t.type);return n&&new GraphQLList(n)}case m.NON_NULL_TYPE:{const n=Wt(e,t.type);return n&&new GraphQLNonNull(n)}case m.NAMED_TYPE:return e.getType(t.name.value)}}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=null!=n?n:Zt,t&&(ke(t)&&this._inputTypeStack.push(t),Ce(t)&&this._parentTypeStack.push(t),Fe(t)&&this._typeStack.push(t))}get[Symbol.toStringTag](){return"TypeInfo"}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 m.SELECTION_SET:{const e=Ve(this.getType());this._parentTypeStack.push(Ce(e)?e:void 0);break}case m.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(Fe(i)?i:void 0);break}case m.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case m.OPERATION_DEFINITION:{const n=t.getRootType(e.operation);this._typeStack.push(Oe(n)?n:void 0);break}case m.INLINE_FRAGMENT:case m.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?Wt(t,n):Ve(this.getType());this._typeStack.push(Fe(r)?r:void 0);break}case m.VARIABLE_DEFINITION:{const n=Wt(t,e.type);this._inputTypeStack.push(ke(n)?n:void 0);break}case m.ARGUMENT:{var n;let t,r;const i=null!==(n=this.getDirective())&&void 0!==n?n:this.getFieldDef();i&&(t=i.args.find((t=>t.name===e.name.value)),t&&(r=t.type)),this._argument=t,this._defaultValueStack.push(t?t.defaultValue:void 0),this._inputTypeStack.push(ke(r)?r:void 0);break}case m.LIST:{const e=je(this.getInputType()),t=we(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(ke(t)?t:void 0);break}case m.OBJECT_FIELD:{const t=Ve(this.getInputType());let n,r;De(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(ke(n)?n:void 0);break}case m.ENUM:{const t=Ve(this.getInputType());let n;Ae(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case m.SELECTION_SET:this._parentTypeStack.pop();break;case m.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case m.DIRECTIVE:this._directive=null;break;case m.OPERATION_DEFINITION:case m.INLINE_FRAGMENT:case m.FRAGMENT_DEFINITION:this._typeStack.pop();break;case m.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case m.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case m.LIST:case m.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case m.ENUM:this._enumValue=null}}}function Zt(e,t,n){const r=n.name.value;return r===kt.name&&e.getQueryType()===t?kt:r===Ft.name&&e.getQueryType()===t?Ft:r===Rt.name&&Ce(t)?Rt:Oe(t)||Se(t)?t.getFields()[r]:void 0}function en(e,t){return{enter(...n){const r=n[0];e.enter(r);const i=de(t,r.kind).enter;if(i){const o=i.apply(t,n);return void 0!==o&&(e.leave(r),d(o)&&e.enter(o)),o}},leave(...n){const r=n[0],i=de(t,r.kind).leave;let o;return i&&(o=i.apply(t,n)),e.leave(r),o}}}function tn(e){return e.kind===m.OPERATION_DEFINITION||e.kind===m.FRAGMENT_DEFINITION}function nn(e){return e.kind===m.SCALAR_TYPE_DEFINITION||e.kind===m.OBJECT_TYPE_DEFINITION||e.kind===m.INTERFACE_TYPE_DEFINITION||e.kind===m.UNION_TYPE_DEFINITION||e.kind===m.ENUM_TYPE_DEFINITION||e.kind===m.INPUT_OBJECT_TYPE_DEFINITION}function rn(e){return e.kind===m.SCALAR_TYPE_EXTENSION||e.kind===m.OBJECT_TYPE_EXTENSION||e.kind===m.INTERFACE_TYPE_EXTENSION||e.kind===m.UNION_TYPE_EXTENSION||e.kind===m.ENUM_TYPE_EXTENSION||e.kind===m.INPUT_OBJECT_TYPE_EXTENSION}function on(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Nt;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===m.DIRECTIVE_DEFINITION){var o;const n=null!==(o=e.arguments)&&void 0!==o?o:[];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(!i.includes(n)){const o=re(n,i);e.reportError(new GraphQLError(`Unknown argument "${n}" on directive "@${r}".`+K(o),t))}}return!1}}}function sn(e){const t=Object.create(null),n=e.getSchema(),i=n?n.getDirectives():Nt;for(const e of i)t[e.name]=e.locations;const o=e.getDocument().definitions;for(const e of o)e.kind===m.DIRECTIVE_DEFINITION&&(t[e.name.value]=e.locations.map((e=>e.value)));return{Directive(n,i,o,s,a){const c=n.name.value,u=t[c];if(!u)return void e.reportError(new GraphQLError(`Unknown directive "@${c}".`,n));const l=function(e){const t=e[e.length-1];switch("kind"in t||r(!1),t.kind){case m.OPERATION_DEFINITION:return function(e){switch(e){case f.QUERY:return h.QUERY;case f.MUTATION:return h.MUTATION;case f.SUBSCRIPTION:return h.SUBSCRIPTION}}(t.operation);case m.FIELD:return h.FIELD;case m.FRAGMENT_SPREAD:return h.FRAGMENT_SPREAD;case m.INLINE_FRAGMENT:return h.INLINE_FRAGMENT;case m.FRAGMENT_DEFINITION:return h.FRAGMENT_DEFINITION;case m.VARIABLE_DEFINITION:return h.VARIABLE_DEFINITION;case m.SCHEMA_DEFINITION:case m.SCHEMA_EXTENSION:return h.SCHEMA;case m.SCALAR_TYPE_DEFINITION:case m.SCALAR_TYPE_EXTENSION:return h.SCALAR;case m.OBJECT_TYPE_DEFINITION:case m.OBJECT_TYPE_EXTENSION:return h.OBJECT;case m.FIELD_DEFINITION:return h.FIELD_DEFINITION;case m.INTERFACE_TYPE_DEFINITION:case m.INTERFACE_TYPE_EXTENSION:return h.INTERFACE;case m.UNION_TYPE_DEFINITION:case m.UNION_TYPE_EXTENSION:return h.UNION;case m.ENUM_TYPE_DEFINITION:case m.ENUM_TYPE_EXTENSION:return h.ENUM;case m.ENUM_VALUE_DEFINITION:return h.ENUM_VALUE;case m.INPUT_OBJECT_TYPE_DEFINITION:case m.INPUT_OBJECT_TYPE_EXTENSION:return h.INPUT_OBJECT;case m.INPUT_VALUE_DEFINITION:{const t=e[e.length-3];return"kind"in t||r(!1),t.kind===m.INPUT_OBJECT_TYPE_DEFINITION?h.INPUT_FIELD_DEFINITION:h.ARGUMENT_DEFINITION}default:r(!1,"Unexpected kind: "+P(t.kind))}}(a);l&&!u.includes(l)&&e.reportError(new GraphQLError(`Directive "@${c}" may not be used on ${l}.`,n))}}}function an(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);for(const t of e.getDocument().definitions)nn(t)&&(r[t.name.value]=!0);const i=[...Object.keys(n),...Object.keys(r)];return{NamedType(t,o,s,a,c){const u=t.name.value;if(!n[u]&&!r[u]){var l;const n=null!==(l=c[2])&&void 0!==l?l:s,r=null!=n&&("kind"in(p=n)&&(function(e){return e.kind===m.SCHEMA_DEFINITION||nn(e)||e.kind===m.DIRECTIVE_DEFINITION}(p)||function(e){return e.kind===m.SCHEMA_EXTENSION||rn(e)}(p)));if(r&&cn.includes(u))return;const o=re(u,r?cn.concat(i):i);e.reportError(new GraphQLError(`Unknown type "${u}".`+K(o),t))}var p}}}const cn=[...pt,...Ct].map((e=>e.name));function un(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 ln(e){switch(e.kind){case m.OBJECT:return{...e,fields:(t=e.fields,t.map((e=>({...e,value:ln(e.value)}))).sort(((e,t)=>ee(e.name.value,t.name.value))))};case m.LIST:return{...e,values:e.values.map(ln)};case m.INT:case m.FLOAT:case m.STRING:case m.BOOLEAN:case m.NULL:case m.ENUM:case m.VARIABLE:return e}var t}function pn(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+pn(t))).join(" and "):e}function dn(e,t,n,r,i,o,s){const a=e.getFragment(s);if(!a)return;const[c,u]=Tn(e,n,a);if(o!==c){hn(e,t,n,r,i,o,c);for(const a of u)r.has(a,s,i)||(r.add(a,s,i),dn(e,t,n,r,i,o,a))}}function fn(e,t,n,r,i,o,s){if(o===s)return;if(r.has(o,s,i))return;r.add(o,s,i);const a=e.getFragment(o),c=e.getFragment(s);if(!a||!c)return;const[u,l]=Tn(e,n,a),[p,d]=Tn(e,n,c);hn(e,t,n,r,i,u,p);for(const s of d)fn(e,t,n,r,i,o,s);for(const o of l)fn(e,t,n,r,i,o,s)}function hn(e,t,n,r,i,o,s){for(const[a,c]of Object.entries(o)){const o=s[a];if(o)for(const s of c)for(const c of o){const o=mn(e,n,r,i,a,s,c);o&&t.push(o)}}}function mn(e,t,n,r,i,o,s){const[a,c,u]=o,[l,p,d]=s,f=r||a!==l&&Oe(a)&&Oe(l);if(!f){const e=c.name.value,t=p.name.value;if(e!==t)return[[i,`"${e}" and "${t}" are different fields`],[c],[p]];if(vn(c)!==vn(p))return[[i,"they have differing arguments"],[c],[p]]}const h=null==u?void 0:u.type,m=null==d?void 0:d.type;if(h&&m&&yn(h,m))return[[i,`they return conflicting types "${P(h)}" and "${P(m)}"`],[c],[p]];const v=c.selectionSet,y=p.selectionSet;if(v&&y){const r=function(e,t,n,r,i,o,s,a){const c=[],[u,l]=En(e,t,i,o),[p,d]=En(e,t,s,a);hn(e,c,t,n,r,u,p);for(const i of d)dn(e,c,t,n,r,u,i);for(const i of l)dn(e,c,t,n,r,p,i);for(const i of l)for(const o of d)fn(e,c,t,n,r,i,o);return c}(e,t,n,f,Ve(h),v,Ve(m),y);return function(e,t,n,r){if(e.length>0)return[[t,e.map((([e])=>e))],[n,...e.map((([,e])=>e)).flat()],[r,...e.map((([,,e])=>e)).flat()]]}(r,i,c,p)}}function vn(e){var t;const n=null!==(t=e.arguments)&&void 0!==t?t:[];return fe(ln({kind:m.OBJECT,fields:n.map((e=>({kind:m.OBJECT_FIELD,name:e.name,value:e.value})))}))}function yn(e,t){return we(e)?!we(t)||yn(e.ofType,t.ofType):!!we(t)||(xe(e)?!xe(t)||yn(e.ofType,t.ofType):!!xe(t)||!(!Re(e)&&!Re(t))&&e!==t)}function En(e,t,n,r){const i=t.get(r);if(i)return i;const o=Object.create(null),s=Object.create(null);Nn(e,n,r,o,s);const a=[o,Object.keys(s)];return t.set(r,a),a}function Tn(e,t,n){const r=t.get(n.selectionSet);if(r)return r;const i=Wt(e.getSchema(),n.typeCondition);return En(e,t,i,n.selectionSet)}function Nn(e,t,n,r,i){for(const o of n.selections)switch(o.kind){case m.FIELD:{const e=o.name.value;let n;(Oe(t)||Se(t))&&(n=t.getFields()[e]);const i=o.alias?o.alias.value:e;r[i]||(r[i]=[]),r[i].push([t,o,n]);break}case m.FRAGMENT_SPREAD:i[o.name.value]=!0;break;case m.INLINE_FRAGMENT:{const n=o.typeCondition,s=n?Wt(e.getSchema(),n):t;Nn(e,s,o.selectionSet,r,i);break}}}class PairSet{constructor(){this._data=new Map}has(e,t,n){var r;const[i,o]=ee.name));const o=e.getDocument().definitions;for(const e of o)if(e.kind===m.DIRECTIVE_DEFINITION){var s;const t=null!==(s=e.arguments)&&void 0!==s?s:[];n[e.name.value]=H(t.filter(_n),(e=>e.name.value))}return{Directive:{leave(t){const r=t.name.value,i=n[r];if(i){var o;const n=null!==(o=t.arguments)&&void 0!==o?o:[],s=new Set(n.map((e=>e.name.value)));for(const[n,o]of Object.entries(i))if(!s.has(n)){const i=_e(o.type)?P(o.type):fe(o.type);e.reportError(new GraphQLError(`Directive "@${r}" argument "${n}" of type "${i}" is required, but it was not provided.`,t))}}}}}}function _n(e){return e.type.kind===m.NON_NULL_TYPE&&null==e.defaultValue}function bn(e,t,n){if(e){if(e.kind===m.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&xe(t))return;return i}if(xe(t)){if(e.kind===m.NULL)return;return bn(e,t.ofType,n)}if(e.kind===m.NULL)return null;if(we(t)){const r=t.ofType;if(e.kind===m.LIST){const t=[];for(const i of e.values)if(On(i,n)){if(xe(r))return;t.push(null)}else{const e=bn(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=bn(e,r,n);if(void 0===i)return;return[i]}if(De(t)){if(e.kind!==m.OBJECT)return;const r=Object.create(null),i=H(e.fields,(e=>e.name.value));for(const e of Object.values(t.getFields())){const t=i[e.name];if(!t||On(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(xe(e.type))return;continue}const o=bn(t.value,e.type,n);if(void 0===o)return;r[e.name]=o}return r}if(Re(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}r(!1,"Unexpected input type: "+P(t))}}function On(e,t){return e.kind===m.VARIABLE&&(null==t||void 0===t[e.name.value])}function Sn(e,t,n){var r;const i=null===(r=t.directives)||void 0===r?void 0:r.find((t=>t.name.value===e.name));if(i)return function(e,t,n){var r;const i={},o=H(null!==(r=t.arguments)&&void 0!==r?r:[],(e=>e.name.value));for(const r of e.args){const e=r.name,c=r.type,u=o[e];if(!u){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(xe(c))throw new GraphQLError(`Argument "${e}" of required type "${P(c)}" was not provided.`,t);continue}const l=u.value;let p=l.kind===m.NULL;if(l.kind===m.VARIABLE){const t=l.name.value;if(null==n||(s=n,a=t,!Object.prototype.hasOwnProperty.call(s,a))){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(xe(c))throw new GraphQLError(`Argument "${e}" of required type "${P(c)}" was provided the variable "$${t}" which was not provided a runtime value.`,l);continue}p=null==n[t]}if(p&&xe(c))throw new GraphQLError(`Argument "${e}" of non-null type "${P(c)}" must not be null.`,l);const d=bn(l,c,n);if(void 0===d)throw new GraphQLError(`Argument "${e}" has invalid value ${fe(l)}.`,l);i[e]=d}var s,a;return i}(e,i,n)}function Ln(e,t,n,r,i){const o=new Map;return An(e,t,n,r,i,o,new Set),o}function An(e,t,n,r,i,o,s){for(const c of i.selections)switch(c.kind){case m.FIELD:{if(!Dn(n,c))continue;const e=(a=c).alias?a.alias.value:a.name.value,t=o.get(e);void 0!==t?t.push(c):o.set(e,[c]);break}case m.INLINE_FRAGMENT:if(!Dn(n,c)||!wn(e,c,r))continue;An(e,t,n,r,c.selectionSet,o,s);break;case m.FRAGMENT_SPREAD:{const i=c.name.value;if(s.has(i)||!Dn(n,c))continue;s.add(i);const a=t[i];if(!a||!wn(e,a,r))continue;An(e,t,n,r,a.selectionSet,o,s);break}}var a}function Dn(e,t){const n=Sn(vt,t,e);if(!0===(null==n?void 0:n.if))return!1;const r=Sn(mt,t,e);return!1!==(null==r?void 0:r.if)}function wn(e,t,n){const r=t.typeCondition;if(!r)return!0;const i=Wt(e,r);return i===n||!!Ge(i)&&e.isSubType(i,n)}function xn(e,t){const n=new Map;for(const r of e){const e=t(r),i=n.get(e);void 0===i?n.set(e,[r]):i.push(r)}return n}function kn(e){return{Field:t,Directive:t};function t(t){var n;const r=xn(null!==(n=t.arguments)&&void 0!==n?n:[],(e=>e.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new GraphQLError(`There can be only one argument named "${t}".`,n.map((e=>e.name))))}}function Fn(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Nt;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===m.DIRECTIVE_DEFINITION&&(t[e.name.value]=!e.repeatable);const o=Object.create(null),s=Object.create(null);return{enter(n){if(!("directives"in n)||!n.directives)return;let r;if(n.kind===m.SCHEMA_DEFINITION||n.kind===m.SCHEMA_EXTENSION)r=o;else if(nn(n)||rn(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 Rn(e,t){return!!(Oe(e)||Se(e)||De(e))&&null!=e.getFields()[t]}function Cn(e){const t=[];let n=Object.create(null);return{ObjectValue:{enter(){t.push(n),n=Object.create(null)},leave(){const e=t.pop();e||r(!1),n=e}},ObjectField(t){const r=t.name.value;n[r]?e.reportError(new GraphQLError(`There can be only one input field named "${r}".`,[n[r],t.name])):n[r]=t.name}}}function Gn(e,t){const n=e.getInputType();if(!n)return;const r=Ve(n);if(Re(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=P(n);e.reportError(new GraphQLError(`Expected value of type "${r}", found ${fe(t)}.`,t))}}catch(r){const i=P(n);r instanceof GraphQLError?e.reportError(r):e.reportError(new GraphQLError(`Expected value of type "${i}", found ${fe(t)}; `+r.message,t,void 0,void 0,void 0,r))}else{const r=P(n);e.reportError(new GraphQLError(`Expected value of type "${r}", found ${fe(t)}.`,t))}}function $n(e,t,n,r,i){if(xe(r)&&!xe(t)){const o=void 0!==i;if(!(null!=n&&n.kind!==m.NULL)&&!o)return!1;return nt(e,t,r.ofType)}return nt(e,t,r)}const Qn=Object.freeze([function(e){return{Document(t){for(const n of t.definitions)if(!tn(n)){const t=n.kind===m.SCHEMA_DEFINITION||n.kind===m.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';e.reportError(new GraphQLError(`The ${t} definition is not executable.`,n))}return!1}}},function(e){const t=Object.create(null);return{OperationDefinition(n){const r=n.name;return r&&(t[r.value]?e.reportError(new GraphQLError(`There can be only one operation named "${r.value}".`,[t[r.value],r])):t[r.value]=r),!1},FragmentDefinition:()=>!1}},function(e){let t=0;return{Document(e){t=e.definitions.filter((e=>e.kind===m.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){if("subscription"===t.operation){const n=e.getSchema(),r=n.getSubscriptionType();if(r){const i=t.name?t.name.value:null,o=Object.create(null),s=e.getDocument(),a=Object.create(null);for(const e of s.definitions)e.kind===m.FRAGMENT_DEFINITION&&(a[e.name.value]=e);const c=Ln(n,a,o,r,t.selectionSet);if(c.size>1){const t=[...c.values()].slice(1).flat();e.reportError(new GraphQLError(null!=i?`Subscription "${i}" must select only one top level field.`:"Anonymous Subscription must select only one top level field.",t))}for(const t of c.values()){t[0].name.value.startsWith("__")&&e.reportError(new GraphQLError(null!=i?`Subscription "${i}" must not select an introspection top level field.`:"Anonymous Subscription must not select an introspection top level field.",t))}}}}}},an,function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=Wt(e.getSchema(),n);if(t&&!Ce(t)){const t=fe(n);e.reportError(new GraphQLError(`Fragment cannot condition on non composite type "${t}".`,n))}}},FragmentDefinition(t){const n=Wt(e.getSchema(),t.typeCondition);if(n&&!Ce(n)){const n=fe(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=Wt(e.getSchema(),t.type);if(void 0!==n&&!ke(n)){const n=t.variable.name.value,r=fe(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(Re(Ve(n))){if(r){const i=t.name.value,o=P(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=P(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=K("to use an inline fragment on",function(e,t,n){if(!Ge(t))return[];const r=new Set,i=Object.create(null);for(const s of e.getPossibleTypes(t))if(s.getFields()[n]){r.add(s),i[s.name]=1;for(const e of s.getInterfaces()){var o;e.getFields()[n]&&(r.add(e),i[e.name]=(null!==(o=i[e.name])&&void 0!==o?o:0)+1)}}return[...r].sort(((t,n)=>{const r=i[n.name]-i[t.name];return 0!==r?r:Se(t)&&e.isSubType(t,n)?-1:Se(n)&&e.isSubType(n,t)?1:ee(t.name,n.name)})).map((e=>e.name))}(r,n,i));""===o&&(o=K(function(e,t){if(Oe(e)||Se(e)){return re(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))}}},un,function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(Ce(n)&&Ce(r)&&!rt(e.getSchema(),n,r)){const i=P(r),o=P(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=Wt(e.getSchema(),n.typeCondition);if(Ce(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!rt(e.getSchema(),r,i)){const o=P(i),s=P(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){return{OperationDefinition(t){var n;const r=xn(null!==(n=t.variableDefinitions)&&void 0!==n?n:[],(e=>e.variable.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new GraphQLError(`There can be only one variable named "$${t}".`,n.map((e=>e.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)}}},sn,Fn,function(e){return{...on(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,o=re(n,r.args.map((e=>e.name)));e.reportError(new GraphQLError(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+K(o),t))}}}},kn,function(e){return{ListValue(t){if(!we(je(e.getParentInputType())))return Gn(e,t),!1},ObjectValue(t){const n=Ve(e.getInputType());if(!De(n))return Gn(e,t),!1;const r=H(t.fields,(e=>e.name.value));for(const i of Object.values(n.getFields())){if(!r[i.name]&&et(i)){const r=P(i.type);e.reportError(new GraphQLError(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,t))}}},ObjectField(t){const n=Ve(e.getParentInputType());if(!e.getInputType()&&De(n)){const r=re(t.name.value,Object.keys(n.getFields()));e.reportError(new GraphQLError(`Field "${t.name.value}" is not defined by type "${n.name}".`+K(r),t))}},NullValue(t){const n=e.getInputType();xe(n)&&e.reportError(new GraphQLError(`Expected value of type "${P(n)}", found ${fe(t)}.`,t))},EnumValue:t=>Gn(e,t),IntValue:t=>Gn(e,t),FloatValue:t=>Gn(e,t),StringValue:t=>Gn(e,t),BooleanValue:t=>Gn(e,t)}},function(e){return{...gn(e),Field:{leave(t){var n;const r=e.getFieldDef();if(!r)return!1;const i=new Set(null===(n=t.arguments)||void 0===n?void 0:n.map((e=>e.name.value)));for(const n of r.args)if(!i.has(n.name)&&ze(n)){const i=P(n.type);e.reportError(new GraphQLError(`Field "${r.name}" argument "${n.name}" of type "${i}" 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=Wt(t,s.type);if(a&&!$n(t,a,s.defaultValue,i,o)){const t=P(a),o=P(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]=En(e,t,r,i);if(function(e,t,n,r,i){for(const[o,s]of Object.entries(i))if(s.length>1)for(let i=0;i0&&e.reportError(new GraphQLError("Must provide only one schema definition.",t)),++s)}}},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){var i;const o=null!==(i=t.operationTypes)&&void 0!==i?i:[];for(const t of o){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(null==n||!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){var i;const o=t.name.value;r[o]||(r[o]=Object.create(null));const s=null!==(i=t.values)&&void 0!==i?i:[],a=r[o];for(const t of s){const r=t.name.value,i=n[o];Ae(i)&&i.getValue(r)?e.reportError(new GraphQLError(`Enum value "${o}.${r}" already exists in the schema. It cannot also be defined in this type extension.`,t.name)):a[r]?e.reportError(new GraphQLError(`Enum value "${o}.${r}" can only be defined once.`,[a[r],t.name])):a[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){var i;const o=t.name.value;r[o]||(r[o]=Object.create(null));const s=null!==(i=t.fields)&&void 0!==i?i:[],a=r[o];for(const t of s){const r=t.name.value;Rn(n[o],r)?e.reportError(new GraphQLError(`Field "${o}.${r}" already exists in the schema. It cannot also be defined in this type extension.`,t.name)):a[r]?e.reportError(new GraphQLError(`Field "${o}.${r}" can only be defined once.`,[a[r],t.name])):a[r]=t.name}return!1}},function(e){return{DirectiveDefinition(e){var t;const r=null!==(t=e.arguments)&&void 0!==t?t:[];return n(`@${e.name.value}`,r)},InterfaceTypeDefinition:t,InterfaceTypeExtension:t,ObjectTypeDefinition:t,ObjectTypeExtension:t};function t(e){var t;const r=e.name.value,i=null!==(t=e.fields)&&void 0!==t?t:[];for(const e of i){var o;n(`${r}.${e.name.value}`,null!==(o=e.arguments)&&void 0!==o?o:[])}return!1}function n(t,n){const r=xn(n,(e=>e.name.value));for(const[n,i]of r)i.length>1&&e.reportError(new GraphQLError(`Argument "${t}(${n}:)" can only be defined once.`,i.map((e=>e.name))));return!1}},function(e){const t=Object.create(null),n=e.getSchema();return{DirectiveDefinition(r){const i=r.name.value;if(null==n||!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))}}},an,sn,Fn,function(e){const t=e.getSchema(),n=Object.create(null);for(const t of e.getDocument().definitions)nn(t)&&(n[t.name.value]=t);return{ScalarTypeExtension:i,ObjectTypeExtension:i,InterfaceTypeExtension:i,UnionTypeExtension:i,EnumTypeExtension:i,InputObjectTypeExtension:i};function i(i){const o=i.name.value,s=n[o],a=null==t?void 0:t.getType(o);let c;if(s?c=In[s.kind]:a&&(c=function(e){if(be(e))return m.SCALAR_TYPE_EXTENSION;if(Oe(e))return m.OBJECT_TYPE_EXTENSION;if(Se(e))return m.INTERFACE_TYPE_EXTENSION;if(Le(e))return m.UNION_TYPE_EXTENSION;if(Ae(e))return m.ENUM_TYPE_EXTENSION;if(De(e))return m.INPUT_OBJECT_TYPE_EXTENSION;r(!1,"Unexpected type: "+P(e))}(a)),c){if(c!==i.kind){const t=function(e){switch(e){case m.SCALAR_TYPE_EXTENSION:return"scalar";case m.OBJECT_TYPE_EXTENSION:return"object";case m.INTERFACE_TYPE_EXTENSION:return"interface";case m.UNION_TYPE_EXTENSION:return"union";case m.ENUM_TYPE_EXTENSION:return"enum";case m.INPUT_OBJECT_TYPE_EXTENSION:return"input object";default:r(!1,"Unexpected kind: "+P(e))}}(i.kind);e.reportError(new GraphQLError(`Cannot extend non-${t} type "${o}".`,s?[s,i]:i))}}else{const r=re(o,Object.keys({...n,...null==t?void 0:t.getTypeMap()}));e.reportError(new GraphQLError(`Cannot extend type "${o}" because it is not defined.`+K(r),i.name))}}},on,kn,Cn,gn]);class ASTValidationContext{constructor(e,t){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=t}get[Symbol.toStringTag](){return"ASTValidationContext"}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let t;if(this._fragments)t=this._fragments;else{t=Object.create(null);for(const e of this.getDocument().definitions)e.kind===m.FRAGMENT_DEFINITION&&(t[e.name.value]=e);this._fragments=t}return t[e]}getFragmentSpreads(e){let t=this._fragmentSpreads.get(e);if(!t){t=[];const n=[e];let r;for(;r=n.pop();)for(const e of r.selections)e.kind===m.FRAGMENT_SPREAD?t.push(e):e.selectionSet&&n.push(e.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];let i;for(;i=r.pop();)for(const e of this.getFragmentSpreads(i)){const i=e.name.value;if(!0!==n[i]){n[i]=!0;const e=this.getFragment(i);e&&(t.push(e),r.push(e.selectionSet))}}this._recursivelyReferencedFragments.set(e,t)}return t}}class SDLValidationContext extends ASTValidationContext{constructor(e,t,n){super(e,n),this._schema=t}get[Symbol.toStringTag](){return"SDLValidationContext"}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}get[Symbol.toStringTag](){return"ValidationContext"}getSchema(){return this._schema}getVariableUsages(e){let t=this._variableUsages.get(e);if(!t){const n=[],r=new TypeInfo(this._schema);le(e,en(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 Un(e,n,r=Qn,i,o=new TypeInfo(e)){var s;const a=null!==(s=null==i?void 0:i.maxErrors)&&void 0!==s?s:100;n||t(!1,"Must provide document."),function(e){const t=jt(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}(e);const c=Object.freeze({}),u=[],l=new ValidationContext(e,n,o,(e=>{if(u.length>=a)throw u.push(new GraphQLError("Too many validation errors, error limit reached. Validation aborted.")),c;u.push(e)})),p=pe(r.map((e=>e(l))));try{le(n,en(o,p))}catch(e){if(e!==c)throw e}return u}function Vn(e,t,n=jn){const r=[],i=new SDLValidationContext(e,t,(e=>{r.push(e)}));return le(e,pe(n.map((e=>e(i))))),r}function Mn(e,r){n(e)&&n(e.__schema)||t(!1,`Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${P(e)}.`);const i=e.__schema,o=W(i.types,(e=>e.name),(e=>function(e){if(null!=e&&null!=e.name&&null!=e.kind)switch(e.kind){case wt.SCALAR:return new GraphQLScalarType({name:(r=e).name,description:r.description,specifiedByURL:r.specifiedByURL});case wt.OBJECT:return new GraphQLObjectType({name:(n=e).name,description:n.description,interfaces:()=>h(n),fields:()=>m(n)});case wt.INTERFACE:return new GraphQLInterfaceType({name:(t=e).name,description:t.description,interfaces:()=>h(t),fields:()=>m(t)});case wt.UNION:return function(e){if(!e.possibleTypes){const t=P(e);throw new Error(`Introspection result missing possibleTypes: ${t}.`)}return new GraphQLUnionType({name:e.name,description:e.description,types:()=>e.possibleTypes.map(d)})}(e);case wt.ENUM:return function(e){if(!e.enumValues){const t=P(e);throw new Error(`Introspection result missing enumValues: ${t}.`)}return new GraphQLEnumType({name:e.name,description:e.description,values:W(e.enumValues,(e=>e.name),(e=>({description:e.description,deprecationReason:e.deprecationReason})))})}(e);case wt.INPUT_OBJECT:return function(e){if(!e.inputFields){const t=P(e);throw new Error(`Introspection result missing inputFields: ${t}.`)}return new GraphQLInputObjectType({name:e.name,description:e.description,fields:()=>E(e.inputFields)})}(e)}var t;var n;var r;const i=P(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[...pt,...Ct])o[e.name]&&(o[e.name]=e);const s=i.queryType?d(i.queryType):null,a=i.mutationType?d(i.mutationType):null,c=i.subscriptionType?d(i.subscriptionType):null,u=i.directives?i.directives.map((function(e){if(!e.args){const t=P(e);throw new Error(`Introspection result missing directive args: ${t}.`)}if(!e.locations){const t=P(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:E(e.args)})})):[];return new GraphQLSchema({description:i.description,query:s,mutation:a,subscription:c,types:Object.values(o),directives:u,assumeValid:null==r?void 0:r.assumeValid});function l(e){if(e.kind===wt.LIST){const t=e.ofType;if(!t)throw new Error("Decorated type deeper than introspection query.");return new GraphQLList(l(t))}if(e.kind===wt.NON_NULL){const t=e.ofType;if(!t)throw new Error("Decorated type deeper than introspection query.");const n=l(t);return new GraphQLNonNull(function(e){if(!Qe(e))throw new Error(`Expected ${P(e)} to be a GraphQL nullable type.`);return e}(n))}return p(e)}function p(e){const t=e.name;if(!t)throw new Error(`Unknown type reference: ${P(e)}.`);const n=o[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 d(e){return function(e){if(!Oe(e))throw new Error(`Expected ${P(e)} to be a GraphQL Object type.`);return e}(p(e))}function f(e){return function(e){if(!Se(e))throw new Error(`Expected ${P(e)} to be a GraphQL Interface type.`);return e}(p(e))}function h(e){if(null===e.interfaces&&e.kind===wt.INTERFACE)return[];if(!e.interfaces){const t=P(e);throw new Error(`Introspection result missing interfaces: ${t}.`)}return e.interfaces.map(f)}function m(e){if(!e.fields)throw new Error(`Introspection result missing fields: ${P(e)}.`);return W(e.fields,(e=>e.name),y)}function y(e){const t=l(e.type);if(!Fe(t)){const e=P(t);throw new Error(`Introspection must provide output type for fields, but received: ${e}.`)}if(!e.args){const t=P(e);throw new Error(`Introspection result missing field args: ${t}.`)}return{description:e.description,deprecationReason:e.deprecationReason,type:t,args:E(e.args)}}function E(e){return W(e,(e=>e.name),T)}function T(e){const t=l(e.type);if(!ke(t)){const e=P(t);throw new Error(`Introspection must provide input type for arguments, but received: ${e}.`)}const n=null!=e.defaultValue?bn(function(e,t){const n=new Parser(e,t);n.expectToken(v.SOF);const r=n.parseValueLiteral(!1);return n.expectToken(v.EOF),r}(e.defaultValue),t):void 0;return{description:e.description,type:t,defaultValue:n,deprecationReason:e.deprecationReason}}}function Pn(e,t,n){var i,o,s,a;const c=[],u=Object.create(null),l=[];let p;const d=[];for(const e of t.definitions)if(e.kind===m.SCHEMA_DEFINITION)p=e;else if(e.kind===m.SCHEMA_EXTENSION)d.push(e);else if(nn(e))c.push(e);else if(rn(e)){const t=e.name.value,n=u[t];u[t]=n?n.concat([e]):[e]}else e.kind===m.DIRECTIVE_DEFINITION&&l.push(e);if(0===Object.keys(u).length&&0===c.length&&0===l.length&&0===d.length&&null==p)return e;const f=Object.create(null);for(const t of e.types)f[t.name]=T(t);for(const e of c){var h;const t=e.name.value;f[t]=null!==(h=Bn[t])&&void 0!==h?h:x(e)}const v={query:e.query&&E(e.query),mutation:e.mutation&&E(e.mutation),subscription:e.subscription&&E(e.subscription),...p&&g([p]),...g(d)};return{description:null===(i=p)||void 0===i||null===(o=i.description)||void 0===o?void 0:o.value,...v,types:Object.values(f),directives:[...e.directives.map((function(e){const t=e.toConfig();return new GraphQLDirective({...t,args:Z(t.args,I)})})),...l.map((function(e){var t;return new GraphQLDirective({name:e.name.value,description:null===(t=e.description)||void 0===t?void 0:t.value,locations:e.locations.map((({value:e})=>e)),isRepeatable:e.repeatable,args:S(e.arguments),astNode:e})}))],extensions:Object.create(null),astNode:null!==(s=p)&&void 0!==s?s:e.astNode,extensionASTNodes:e.extensionASTNodes.concat(d),assumeValid:null!==(a=null==n?void 0:n.assumeValid)&&void 0!==a&&a};function y(e){return we(e)?new GraphQLList(y(e.ofType)):xe(e)?new GraphQLNonNull(y(e.ofType)):E(e)}function E(e){return f[e.name]}function T(e){return Gt(e)||dt(e)?e:be(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[n.name])&&void 0!==t?t:[];let i=n.specifiedByURL;for(const e of r){var o;i=null!==(o=Jn(e))&&void 0!==o?o:i}return new GraphQLScalarType({...n,specifiedByURL:i,extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):Oe(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[n.name])&&void 0!==t?t:[];return new GraphQLObjectType({...n,interfaces:()=>[...e.getInterfaces().map(E),...D(r)],fields:()=>({...Z(n.fields,N),...O(r)}),extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):Se(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[n.name])&&void 0!==t?t:[];return new GraphQLInterfaceType({...n,interfaces:()=>[...e.getInterfaces().map(E),...D(r)],fields:()=>({...Z(n.fields,N),...O(r)}),extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):Le(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[n.name])&&void 0!==t?t:[];return new GraphQLUnionType({...n,types:()=>[...e.getTypes().map(E),...w(r)],extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):Ae(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[e.name])&&void 0!==t?t:[];return new GraphQLEnumType({...n,values:{...n.values,...A(r)},extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):De(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[n.name])&&void 0!==t?t:[];return new GraphQLInputObjectType({...n,fields:()=>({...Z(n.fields,(e=>({...e,type:y(e.type)}))),...L(r)}),extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):void r(!1,"Unexpected type: "+P(e))}function N(e){return{...e,type:y(e.type),args:e.args&&Z(e.args,I)}}function I(e){return{...e,type:y(e.type)}}function g(e){const t={};for(const r of e){var n;const e=null!==(n=r.operationTypes)&&void 0!==n?n:[];for(const n of e)t[n.operation]=_(n.type)}return t}function _(e){var t;const n=e.name.value,r=null!==(t=Bn[n])&&void 0!==t?t:f[n];if(void 0===r)throw new Error(`Unknown type: "${n}".`);return r}function b(e){return e.kind===m.LIST_TYPE?new GraphQLList(b(e.type)):e.kind===m.NON_NULL_TYPE?new GraphQLNonNull(b(e.type)):_(e)}function O(e){const t=Object.create(null);for(const i of e){var n;const e=null!==(n=i.fields)&&void 0!==n?n:[];for(const n of e){var r;t[n.name.value]={type:b(n.type),description:null===(r=n.description)||void 0===r?void 0:r.value,args:S(n.arguments),deprecationReason:Yn(n),astNode:n}}}return t}function S(e){const t=null!=e?e:[],n=Object.create(null);for(const e of t){var r;const t=b(e.type);n[e.name.value]={type:t,description:null===(r=e.description)||void 0===r?void 0:r.value,defaultValue:bn(e.defaultValue,t),deprecationReason:Yn(e),astNode:e}}return n}function L(e){const t=Object.create(null);for(const i of e){var n;const e=null!==(n=i.fields)&&void 0!==n?n:[];for(const n of e){var r;const e=b(n.type);t[n.name.value]={type:e,description:null===(r=n.description)||void 0===r?void 0:r.value,defaultValue:bn(n.defaultValue,e),deprecationReason:Yn(n),astNode:n}}}return t}function A(e){const t=Object.create(null);for(const i of e){var n;const e=null!==(n=i.values)&&void 0!==n?n:[];for(const n of e){var r;t[n.name.value]={description:null===(r=n.description)||void 0===r?void 0:r.value,deprecationReason:Yn(n),astNode:n}}}return t}function D(e){return e.flatMap((e=>{var t,n;return null!==(t=null===(n=e.interfaces)||void 0===n?void 0:n.map(_))&&void 0!==t?t:[]}))}function w(e){return e.flatMap((e=>{var t,n;return null!==(t=null===(n=e.types)||void 0===n?void 0:n.map(_))&&void 0!==t?t:[]}))}function x(e){var t;const n=e.name.value,r=null!==(t=u[n])&&void 0!==t?t:[];switch(e.kind){case m.OBJECT_TYPE_DEFINITION:{var i;const t=[e,...r];return new GraphQLObjectType({name:n,description:null===(i=e.description)||void 0===i?void 0:i.value,interfaces:()=>D(t),fields:()=>O(t),astNode:e,extensionASTNodes:r})}case m.INTERFACE_TYPE_DEFINITION:{var o;const t=[e,...r];return new GraphQLInterfaceType({name:n,description:null===(o=e.description)||void 0===o?void 0:o.value,interfaces:()=>D(t),fields:()=>O(t),astNode:e,extensionASTNodes:r})}case m.ENUM_TYPE_DEFINITION:{var s;const t=[e,...r];return new GraphQLEnumType({name:n,description:null===(s=e.description)||void 0===s?void 0:s.value,values:A(t),astNode:e,extensionASTNodes:r})}case m.UNION_TYPE_DEFINITION:{var a;const t=[e,...r];return new GraphQLUnionType({name:n,description:null===(a=e.description)||void 0===a?void 0:a.value,types:()=>w(t),astNode:e,extensionASTNodes:r})}case m.SCALAR_TYPE_DEFINITION:var c;return new GraphQLScalarType({name:n,description:null===(c=e.description)||void 0===c?void 0:c.value,specifiedByURL:Jn(e),astNode:e,extensionASTNodes:r});case m.INPUT_OBJECT_TYPE_DEFINITION:{var l;const t=[e,...r];return new GraphQLInputObjectType({name:n,description:null===(l=e.description)||void 0===l?void 0:l.value,fields:()=>L(t),astNode:e,extensionASTNodes:r})}}}}const Bn=H([...pt,...Ct],(e=>e.name));function Yn(e){const t=Sn(Et,e);return null==t?void 0:t.reason}function Jn(e){const t=Sn(Tt,e);return null==t?void 0:t.url}function qn(e,n){null!=e&&e.kind===m.DOCUMENT||t(!1,"Must provide valid Document AST."),!0!==(null==n?void 0:n.assumeValid)&&!0!==(null==n?void 0:n.assumeValidSDL)&&function(e){const t=Vn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}(e);const r=Pn({description:void 0,types:[],directives:[],extensions:Object.create(null),extensionASTNodes:[],assumeValid:!1},e,n);if(null==r.astNode)for(const e of r.types)switch(e.name){case"Query":r.query=e;break;case"Mutation":r.mutation=e;break;case"Subscription":r.subscription=e}const i=[...r.directives,...Nt.filter((e=>r.directives.every((t=>t.name!==e.name))))];return new GraphQLSchema({...r,directives:i})}function Xn(e){return function(e,t,n){const i=e.getDirectives().filter(t),o=Object.values(e.getTypeMap()).filter(n);return[zn(e),...i.map((e=>function(e){return rr(e)+"directive @"+e.name+er(e.args)+(e.isRepeatable?" repeatable":"")+" on "+e.locations.join(" | ")}(e))),...o.map((e=>function(e){if(be(e))return function(e){return rr(e)+`scalar ${e.name}`+function(e){if(null==e.specifiedByURL)return"";return` @specifiedBy(url: ${fe({kind:m.STRING,value:e.specifiedByURL})})`}(e)}(e);if(Oe(e))return function(e){return rr(e)+`type ${e.name}`+Hn(e)+Wn(e)}(e);if(Se(e))return function(e){return rr(e)+`interface ${e.name}`+Hn(e)+Wn(e)}(e);if(Le(e))return function(e){const t=e.getTypes(),n=t.length?" = "+t.join(" | "):"";return rr(e)+"union "+e.name+n}(e);if(Ae(e))return function(e){const t=e.getValues().map(((e,t)=>rr(e," ",!t)+" "+e.name+nr(e.deprecationReason)));return rr(e)+`enum ${e.name}`+Zn(t)}(e);if(De(e))return function(e){const t=Object.values(e.getFields()).map(((e,t)=>rr(e," ",!t)+" "+tr(e)));return rr(e)+`input ${e.name}`+Zn(t)}(e);r(!1,"Unexpected type: "+P(e))}(e)))].filter(Boolean).join("\n\n")}(e,(e=>{return t=e,!Nt.some((({name:e})=>e===t.name));var t}),Kn)}function Kn(e){return!dt(e)&&!Gt(e)}function zn(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}`),rr(e)+`schema {\n${t.join("\n")}\n}`}function Hn(e){const t=e.getInterfaces();return t.length?" implements "+t.map((e=>e.name)).join(" & "):""}function Wn(e){return Zn(Object.values(e.getFields()).map(((e,t)=>rr(e," ",!t)+" "+e.name+er(e.args," ")+": "+String(e.type)+nr(e.deprecationReason))))}function Zn(e){return 0!==e.length?" {\n"+e.join("\n")+"\n}":""}function er(e,t=""){return 0===e.length?"":e.every((e=>!e.description))?"("+e.map(tr).join(", ")+")":"(\n"+e.map(((e,n)=>rr(e," "+t,!n)+" "+t+tr(e))).join("\n")+"\n"+t+")"}function tr(e){const t=It(e.defaultValue,e.type);let n=e.name+": "+String(e.type);return t&&(n+=` = ${fe(t)}`),n+nr(e.deprecationReason)}function nr(e){if(null==e)return"";if(e!==yt){return` @deprecated(reason: ${fe({kind:m.STRING,value:e})})`}return" @deprecated"}function rr(e,t="",n=!0){const{description:r}=e;if(null==r)return"";return(t&&!n?"\n"+t:t)+fe({kind:m.STRING,value:r,block:b(r)}).replace(/\n/g,"\n"+t)+"\n"}const ir=[un],or=[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))}}},...Qn.filter((e=>!ir.includes(e)))];class GraphQLSchemaValidationError extends Error{constructor(e){super(e.map((e=>e.message)).join("\n\n")),this.validationErrors=e,this.name="GraphQLSchemaValidationError"}}function sr(e){const t=jt(e);if(0!==t.length)throw new GraphQLSchemaValidationError(t)}function ar(e){return e.startsWith("__")}function cr(e){return null!=e}function ur(e){switch(e.kind){case m.VARIABLE:return{kind:e.kind,value:e.name.value};case m.LIST:return{kind:e.kind,value:e.values.map(ur)};case m.OBJECT:return{kind:e.kind,value:e.fields.reduce(((e,t)=>(e[t.name.value]=ur(t.value),e)),{})};default:return e}}function lr(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 pr(e,t){const n=new Map;for(const e of t.definitions)e.kind===m.FRAGMENT_DEFINITION&&n.set(e.name.value,e);const r=[],i=new Map,o=new Set;for(const e of t.definitions)e.kind===m.OPERATION_DEFINITION&&r.push(a(e));for(const[e,t]of n.entries())i.set(e,c(t));return{operations:r,fragments:Array.from(i.values()),referencedTypes:Array.from(o.values())};function s(e){if(o.add(e),Le(e)){const t=e.getTypes();for(e of t)o.add(Ve(e))}}function a(t){if(!t.name)throw new GraphQLError("Operations should be named",t);const n=lr(t),r=t.name.value,i=t.operation,a=(t.variableDefinitions||[]).map((t=>{const n=t.variable.name.value,r=Wt(e,t.type);if(!r)throw new GraphQLError(`Couldn't get type from type node "${t.type}"`,t);return s(Ve(r)),{name:n,type:r}})),c=fe(t),l=e.getRootType(i);return o.add(Ve(l)),{filePath:n,name:r,operationType:i,rootType:l,variables:a,source:c,selectionSet:u(t.selectionSet,l)}}function c(t){const n=t.name.value,r=lr(t),i=fe(t),o=Wt(e,t.typeCondition);return s(Ve(o)),{name:n,filePath:r,source:i,typeCondition:o,selectionSet:u(t.selectionSet,o)}}function u(t,r,o=new Set){return{parentType:r,selections:t.selections.map((t=>function(t,r,o){var a;switch(t.kind){case m.FIELD:{const n=t.name.value,i=null===(a=t.alias)||void 0===a?void 0:a.value,o=function(e,t,n){return n===kt.name&&e.getQueryType()===t?kt:n===Ft.name&&e.getQueryType()===t?Ft:n===Rt.name&&(Oe(t)||Se(t)||Le(t))?Rt:Oe(t)||Se(t)?t.getFields()[n]:void 0}(e,r,n);if(!o)throw new GraphQLError(`Cannot query field "${n}" on type "${String(r)}"`,t);const c=o.type,l=Ve(c);s(Ve(l));const{description:p,deprecationReason:d}=o,f=t.arguments&&t.arguments.length>0?t.arguments.map((e=>{const t=e.name.value,n=o.args.find((t=>t.name===e.name.value)),r=n&&n.type||void 0;return{name:t,value:ur(e.value),type:r}})):void 0;let h={kind:"Field",name:n,alias:i,arguments:f,type:c,description:!ar(n)&&p?p:void 0,deprecationReason:d||void 0};if(Ce(l)){const e=t.selectionSet;if(!e)throw new GraphQLError(`Composite field "${n}" on type "${String(r)}" requires selection set`,t);h.selectionSet=u(e,l)}return h}case m.INLINE_FRAGMENT:{const n=t.typeCondition,i=n?Wt(e,n):r;return s(i),{kind:"InlineFragment",selectionSet:u(t.selectionSet,i)}}case m.FRAGMENT_SPREAD:{const e=t.name.value;if(o.has(e))return;o.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=c(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,o))).filter(cr)}}}return m.FIELD,m.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 pr(e,t)},e.loadSchemaFromIntrospectionResult=function(e){let t=JSON.parse(e);t.data&&(t=t.data);const n=Mn(t);return sr(n),n},e.loadSchemaFromSDL=function(e){const t=J(e);!function(e){const t=Vn(e);if(0!==t.length)throw new GraphQLSchemaValidationError(t)}(t);const n=qn(t,{assumeValidSDL:!0});return sr(n),n},e.mergeDocuments=function(e){return function(e){const t=[];for(const n of e)t.push(...n.definitions);return{kind:m.DOCUMENT,definitions:t}}(e)},e.parseDocument=function(e){return J(e)},e.printSchemaToSDL=function(e){return Xn(e)},e.validateDocument=function(e,t){return Un(e,t,or)},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); +var ApolloCodegenFrontend=function(e){"use strict";function t(e,t){if(!Boolean(e))throw new Error(t)}function n(e){return"object"==typeof e&&null!==e}function r(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}const i=/\r\n|[\n\r]/g;function o(e,t){let n=0,o=1;for(const s of e.body.matchAll(i)){if("number"==typeof s.index||r(!1),s.index>=t)break;n=s.index+s[0].length,o+=1}return{line:o,column:t+1-n}}function s(e,t){const n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,o=e.locationOffset.line-1,s=t.line+o,c=1===t.line?n:0,u=t.column+c,l=`${e.name}:${s}:${u}\n`,p=r.split(/\r\n|[\n\r]/g),d=p[i];if(d.length>120){const e=Math.floor(u/80),t=u%80,n=[];for(let e=0;e["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return l+a([[s-1+" |",p[i-1]],[`${s} |`,d],["|","^".padStart(u)],[`${s+1} |`,p[i+1]]])}function a(e){const t=e.filter((([e,t])=>void 0!==t)),n=Math.max(...t.map((([e])=>e.length)));return t.map((([e,t])=>e.padStart(n)+(t?" "+t:""))).join("\n")}class GraphQLError extends Error{constructor(e,...t){var r,i,s;const{nodes:a,source:u,positions:l,path:p,originalError:d,extensions:f}=function(e){const t=e[0];return null==t||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}(t);super(e),this.name="GraphQLError",this.path=null!=p?p:void 0,this.originalError=null!=d?d:void 0,this.nodes=c(Array.isArray(a)?a:a?[a]:void 0);const h=c(null===(r=this.nodes)||void 0===r?void 0:r.map((e=>e.loc)).filter((e=>null!=e)));this.source=null!=u?u:null==h||null===(i=h[0])||void 0===i?void 0:i.source,this.positions=null!=l?l:null==h?void 0:h.map((e=>e.start)),this.locations=l&&u?l.map((e=>o(u,e))):null==h?void 0:h.map((e=>o(e.source,e.start)));const m=n(null==d?void 0:d.extensions)?null==d?void 0:d.extensions:void 0;this.extensions=null!==(s=null!=f?f:m)&&void 0!==s?s:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),null!=d&&d.stack?Object.defineProperty(this,"stack",{value:d.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,GraphQLError):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(e+="\n\n"+s((t=n.loc).source,o(t.source,t.start)));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+s(this.source,t);var t;return e}toJSON(){const e={message:this.message};return null!=this.locations&&(e.locations=this.locations),null!=this.path&&(e.path=this.path),null!=this.extensions&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function c(e){return void 0===e||0===e.length?void 0:e}function u(e,t,n){return new GraphQLError(`Syntax Error: ${n}`,void 0,e,[t])}class Location{constructor(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class Token{constructor(e,t,n,r,i,o){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=o,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const l={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"]},p=new Set(Object.keys(l));function d(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&p.has(t)}let f,h,m,v;function y(e){return 9===e||32===e}function E(e){return e>=48&&e<=57}function T(e){return e>=97&&e<=122||e>=65&&e<=90}function N(e){return T(e)||95===e}function I(e){return T(e)||E(e)||95===e}function g(e){var t;let n=Number.MAX_SAFE_INTEGER,r=null,i=-1;for(let t=0;t0===t?e:e.slice(n))).slice(null!==(t=r)&&void 0!==t?t:0,i+1)}function _(e){let t=0;for(;t",e.EOF="",e.BANG="!",e.DOLLAR="$",e.AMP="&",e.PAREN_L="(",e.PAREN_R=")",e.SPREAD="...",e.COLON=":",e.EQUALS="=",e.AT="@",e.BRACKET_L="[",e.BRACKET_R="]",e.BRACE_L="{",e.PIPE="|",e.BRACE_R="}",e.NAME="Name",e.INT="Int",e.FLOAT="Float",e.STRING="String",e.BLOCK_STRING="BlockString",e.COMMENT="Comment"}(v||(v={}));class Lexer{constructor(e){const t=new Token(v.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){this.lastToken=this.token;return this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==v.EOF)do{if(e.next)e=e.next;else{const t=x(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===v.COMMENT);return e}}function O(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function S(e,t){return L(e.charCodeAt(t))&&A(e.charCodeAt(t+1))}function L(e){return e>=55296&&e<=56319}function A(e){return e>=56320&&e<=57343}function D(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return v.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function w(e,t,n,r,i){const o=e.line,s=1+n-e.lineStart;return new Token(t,n,r,o,s,i)}function x(e,t){const n=e.source.body,r=n.length;let i=t;for(;i=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function U(e,t){const n=e.source.body;switch(n.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:"\n",size:2};case 114:return{value:"\r",size:2};case 116:return{value:"\t",size:2}}throw u(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function V(e,t){const n=e.source.body,r=n.length;let i=e.lineStart,o=t+3,s=o,a="";const c=[];for(;o2)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.entries(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)+"]";const r=n.map((([e,n])=>e+": "+B(n,t)));return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}const Y=function(e,t){return e instanceof t};class Source{constructor(e,n="GraphQL request",r={line:1,column:1}){"string"==typeof e||t(!1,`Body must be a string. Received: ${P(e)}.`),this.body=e,this.name=n,this.locationOffset=r,this.locationOffset.line>0||t(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||t(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function J(e,t){return new Parser(e,t).parseDocument()}class Parser{constructor(e,t){const n=function(e){return Y(e,Source)}(e)?e:new Source(e);this._lexer=new Lexer(n),this._options=t}parseName(){const e=this.expectToken(v.NAME);return this.node(e,{kind:m.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:m.DOCUMENT,definitions:this.many(v.SOF,this.parseDefinition,v.EOF)})}parseDefinition(){if(this.peek(v.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===v.NAME){switch(t.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()}if(e)throw u(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(t.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(t)}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(v.BRACE_L))return this.node(e,{kind:m.OPERATION_DEFINITION,operation:f.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(v.NAME)&&(n=this.parseName()),this.node(e,{kind:m.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(v.NAME);switch(e.value){case"query":return f.QUERY;case"mutation":return f.MUTATION;case"subscription":return f.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(v.PAREN_L,this.parseVariableDefinition,v.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:m.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(v.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(v.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(v.DOLLAR),this.node(e,{kind:m.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:m.SELECTION_SET,selections:this.many(v.BRACE_L,this.parseSelection,v.BRACE_R)})}parseSelection(){return this.peek(v.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(v.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:m.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(v.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(v.PAREN_L,t,v.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(v.COLON),this.node(t,{kind:m.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(v.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(v.NAME)?this.node(e,{kind:m.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:m.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){var e;const t=this._lexer.token;return this.expectKeyword("fragment"),!0===(null===(e=this._options)||void 0===e?void 0:e.allowLegacyFragmentVariables)?this.node(t,{kind:m.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(t,{kind:m.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()}parseValueLiteral(e){const t=this._lexer.token;switch(t.kind){case v.BRACKET_L:return this.parseList(e);case v.BRACE_L:return this.parseObject(e);case v.INT:return this._lexer.advance(),this.node(t,{kind:m.INT,value:t.value});case v.FLOAT:return this._lexer.advance(),this.node(t,{kind:m.FLOAT,value:t.value});case v.STRING:case v.BLOCK_STRING:return this.parseStringLiteral();case v.NAME:switch(this._lexer.advance(),t.value){case"true":return this.node(t,{kind:m.BOOLEAN,value:!0});case"false":return this.node(t,{kind:m.BOOLEAN,value:!1});case"null":return this.node(t,{kind:m.NULL});default:return this.node(t,{kind:m.ENUM,value:t.value})}case v.DOLLAR:if(e){if(this.expectToken(v.DOLLAR),this._lexer.token.kind===v.NAME){const e=this._lexer.token.value;throw u(this._lexer.source,t.start,`Unexpected variable "$${e}" in constant value.`)}throw this.unexpected(t)}return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const e=this._lexer.token;return this._lexer.advance(),this.node(e,{kind:m.STRING,value:e.value,block:e.kind===v.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:m.LIST,values:this.any(v.BRACKET_L,(()=>this.parseValueLiteral(e)),v.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:m.OBJECT,fields:this.any(v.BRACE_L,(()=>this.parseObjectField(e)),v.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(v.COLON),this.node(t,{kind:m.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(v.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(v.AT),this.node(t,{kind:m.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(v.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(v.BRACKET_R),t=this.node(e,{kind:m.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(v.BANG)?this.node(e,{kind:m.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:m.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(v.STRING)||this.peek(v.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");const n=this.parseConstDirectives(),r=this.many(v.BRACE_L,this.parseOperationTypeDefinition,v.BRACE_R);return this.node(e,{kind:m.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(v.COLON);const n=this.parseNamedType();return this.node(e,{kind:m.OPERATION_TYPE_DEFINITION,operation:t,type:n})}parseScalarTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");const n=this.parseName(),r=this.parseConstDirectives();return this.node(e,{kind:m.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r})}parseObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(e,{kind:m.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(v.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(v.BRACE_L,this.parseFieldDefinition,v.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(v.COLON);const i=this.parseTypeReference(),o=this.parseConstDirectives();return this.node(e,{kind:m.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o})}parseArgumentDefs(){return this.optionalMany(v.PAREN_L,this.parseInputValueDef,v.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(v.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(v.EQUALS)&&(i=this.parseConstValueLiteral());const o=this.parseConstDirectives();return this.node(e,{kind:m.INPUT_VALUE_DEFINITION,description:t,name:n,type:r,defaultValue:i,directives:o})}parseInterfaceTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(e,{kind:m.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o})}parseUnionTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();return this.node(e,{kind:m.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(v.EQUALS)?this.delimitedMany(v.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();return this.node(e,{kind:m.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(v.BRACE_L,this.parseEnumValueDefinition,v.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:m.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r})}parseEnumValueName(){if("true"===this._lexer.token.value||"false"===this._lexer.token.value||"null"===this._lexer.token.value)throw u(this._lexer.source,this._lexer.token.start,`${q(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();return this.node(e,{kind:m.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(v.BRACE_L,this.parseInputValueDef,v.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===v.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.parseConstDirectives(),n=this.optionalMany(v.BRACE_L,this.parseOperationTypeDefinition,v.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:m.SCHEMA_EXTENSION,directives:t,operationTypes:n})}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const t=this.parseName(),n=this.parseConstDirectives();if(0===n.length)throw this.unexpected();return this.node(e,{kind:m.SCALAR_TYPE_EXTENSION,name:t,directives:n})}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:m.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:m.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:m.UNION_TYPE_EXTENSION,name:t,directives:n,types:r})}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:m.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r})}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:m.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(v.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const o=this.parseDirectiveLocations();return this.node(e,{kind:m.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o})}parseDirectiveLocations(){return this.delimitedMany(v.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(h,t.value))return t;throw this.unexpected(e)}node(e,t){var n;return!0!==(null===(n=this._options)||void 0===n?void 0:n.noLocation)&&(t.loc=new Location(e,this._lexer.lastToken,this._lexer.source)),t}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 u(this._lexer.source,t.start,`Expected ${X(e)}, found ${q(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this._lexer.advance(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==v.NAME||t.value!==e)throw u(this._lexer.source,t.start,`Expected "${e}", found ${q(t)}.`);this._lexer.advance()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===v.NAME&&t.value===e&&(this._lexer.advance(),!0)}unexpected(e){const t=null!=e?e:this._lexer.token;return u(this._lexer.source,t.start,`Unexpected ${q(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 q(e){const t=e.value;return X(e.kind)+(null!=t?` "${t}"`:"")}function X(e){return function(e){return e===v.BANG||e===v.DOLLAR||e===v.AMP||e===v.PAREN_L||e===v.PAREN_R||e===v.SPREAD||e===v.COLON||e===v.EQUALS||e===v.AT||e===v.BRACKET_L||e===v.BRACKET_R||e===v.BRACE_L||e===v.PIPE||e===v.BRACE_R}(e)?`"${e}"`:e}function K(e,t){const[n,r]=t?[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 z(e){return e}function H(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function W(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function Z(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function ee(e,t){let n=0,r=0;for(;n0);let a=0;do{++r,a=10*a+o-te,o=t.charCodeAt(r)}while(ne(o)&&a>0);if(sa)return 1}else{if(io)return 1;++n,++r}}return e.length-t.length}const te=48;function ne(e){return!isNaN(e)&&te<=e&&e<=57}function re(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:ee(e,t)}))}class LexicalDistance{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=ie(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=ie(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 ie(e){const t=e.length,n=new Array(t);for(let r=0;re.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>me(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=ye("(",me(e.variableDefinitions,", "),")"),n=me([e.operation,me([e.name,t]),me(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+ye(" = ",n)+ye(" ",me(r," "))},SelectionSet:{leave:({selections:e})=>ve(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const o=ye("",e,": ")+t;let s=o+ye("(",me(n,", "),")");return s.length>80&&(s=o+ye("(\n",Ee(me(n,"\n")),"\n)")),me([s,me(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+ye(" ",me(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>me(["...",ye("on ",e),me(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${ye("(",me(n,", "),")")} on ${t} ${ye("",me(r," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?function(e,t){const n=e.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),i=1===r.length,o=r.length>1&&r.slice(1).every((e=>0===e.length||y(e.charCodeAt(0)))),s=n.endsWith('\\"""'),a=e.endsWith('"')&&!s,c=e.endsWith("\\"),u=a||c,l=!(null!=t&&t.minimize)&&(!i||e.length>70||u||o||s);let p="";const d=i&&y(e.charCodeAt(0));return(l&&!d||o)&&(p+="\n"),p+=n,(l||u)&&(p+="\n"),'"""'+p+'"""'}(e):`"${e.replace(se,ae)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+me(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+me(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+ye("(",me(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>ye("",e,"\n")+me(["schema",me(t," "),ve(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>ye("",e,"\n")+me(["scalar",t,me(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ye("",e,"\n")+me(["type",t,ye("implements ",me(n," & ")),me(r," "),ve(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>ye("",e,"\n")+t+(Te(n)?ye("(\n",Ee(me(n,"\n")),"\n)"):ye("(",me(n,", "),")"))+": "+r+ye(" ",me(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>ye("",e,"\n")+me([t+": "+n,ye("= ",r),me(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ye("",e,"\n")+me(["interface",t,ye("implements ",me(n," & ")),me(r," "),ve(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>ye("",e,"\n")+me(["union",t,me(n," "),ye("= ",me(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>ye("",e,"\n")+me(["enum",t,me(n," "),ve(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>ye("",e,"\n")+me([t,me(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>ye("",e,"\n")+me(["input",t,me(n," "),ve(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>ye("",e,"\n")+"directive @"+t+(Te(n)?ye("(\n",Ee(me(n,"\n")),"\n)"):ye("(",me(n,", "),")"))+(r?" repeatable":"")+" on "+me(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>me(["extend schema",me(e," "),ve(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>me(["extend scalar",e,me(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>me(["extend type",e,ye("implements ",me(t," & ")),me(n," "),ve(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>me(["extend interface",e,ye("implements ",me(t," & ")),me(n," "),ve(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>me(["extend union",e,me(t," "),ye("= ",me(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>me(["extend enum",e,me(t," "),ve(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>me(["extend input",e,me(t," "),ve(n)]," ")}};function me(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function ve(e){return ye("{\n",Ee(me(e,"\n")),"\n}")}function ye(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function Ee(e){return ye(" ",e.replace(/\n/g,"\n "))}function Te(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}function Ne(e,t){switch(e.kind){case m.NULL:return null;case m.INT:return parseInt(e.value,10);case m.FLOAT:return parseFloat(e.value);case m.STRING:case m.ENUM:case m.BOOLEAN:return e.value;case m.LIST:return e.values.map((e=>Ne(e,t)));case m.OBJECT:return W(e.fields,(e=>e.name.value),(e=>Ne(e.value,t)));case m.VARIABLE:return null==t?void 0:t[e.name.value]}}function Ie(e){if(null!=e||t(!1,"Must provide name."),"string"==typeof e||t(!1,"Expected name to be a string."),0===e.length)throw new GraphQLError("Expected name to be a non-empty string.");for(let t=1;ts(Ne(e,t)),this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(o=e.extensionASTNodes)&&void 0!==o?o:[],null==e.specifiedByURL||"string"==typeof e.specifiedByURL||t(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${P(e.specifiedByURL)}.`),null==e.serialize||"function"==typeof e.serialize||t(!1,`${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||t(!1,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`))}get[Symbol.toStringTag](){return"GraphQLScalarType"}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()}}class GraphQLObjectType{constructor(e){var n;this.name=Ie(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(n=e.extensionASTNodes)&&void 0!==n?n:[],this._fields=()=>Ye(e),this._interfaces=()=>Be(e),null==e.isTypeOf||"function"==typeof e.isTypeOf||t(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${P(e.isTypeOf)}.`)}get[Symbol.toStringTag](){return"GraphQLObjectType"}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:Xe(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Be(e){var n;const r=Me(null!==(n=e.interfaces)&&void 0!==n?n:[]);return Array.isArray(r)||t(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),r}function Ye(e){const n=Pe(e.fields);return qe(n)||t(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Z(n,((n,r)=>{var i;qe(n)||t(!1,`${e.name}.${r} field config must be an object.`),null==n.resolve||"function"==typeof n.resolve||t(!1,`${e.name}.${r} field resolver must be a function if provided, but got: ${P(n.resolve)}.`);const o=null!==(i=n.args)&&void 0!==i?i:{};return qe(o)||t(!1,`${e.name}.${r} args must be an object with argument names as keys.`),{name:Ie(r),description:n.description,type:n.type,args:Je(o),resolve:n.resolve,subscribe:n.subscribe,deprecationReason:n.deprecationReason,extensions:oe(n.extensions),astNode:n.astNode}}))}function Je(e){return Object.entries(e).map((([e,t])=>({name:Ie(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:oe(t.extensions),astNode:t.astNode})))}function qe(e){return n(e)&&!Array.isArray(e)}function Xe(e){return Z(e,(e=>({description:e.description,type:e.type,args:Ke(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Ke(e){return W(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function ze(e){return xe(e.type)&&void 0===e.defaultValue}class GraphQLInterfaceType{constructor(e){var n;this.name=Ie(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(n=e.extensionASTNodes)&&void 0!==n?n:[],this._fields=Ye.bind(void 0,e),this._interfaces=Be.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||t(!1,`${this.name} must provide "resolveType" as a function, but got: ${P(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}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:Xe(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class GraphQLUnionType{constructor(e){var n;this.name=Ie(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(n=e.extensionASTNodes)&&void 0!==n?n:[],this._types=He.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||t(!1,`${this.name} must provide "resolveType" as a function, but got: ${P(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLUnionType"}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()}}function He(e){const n=Me(e.types);return Array.isArray(n)||t(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),n}class GraphQLEnumType{constructor(e){var n,r,i;this.name=Ie(e.name),this.description=e.description,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(n=e.extensionASTNodes)&&void 0!==n?n:[],this._values=(r=this.name,qe(i=e.values)||t(!1,`${r} values must be an object with value names as keys.`),Object.entries(i).map((([e,n])=>(qe(n)||t(!1,`${r}.${e} must refer to an object with a "value" key representing an internal value but got: ${P(n)}.`),{name:ge(e),description:n.description,value:void 0!==n.value?n.value:e,deprecationReason:n.deprecationReason,extensions:oe(n.extensions),astNode:n.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=H(this._values,(e=>e.name))}get[Symbol.toStringTag](){return"GraphQLEnumType"}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: ${P(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=P(e);throw new GraphQLError(`Enum "${this.name}" cannot represent non-string value: ${t}.`+We(this,t))}const t=this.getValue(e);if(null==t)throw new GraphQLError(`Value "${e}" does not exist in "${this.name}" enum.`+We(this,e));return t.value}parseLiteral(e,t){if(e.kind!==m.ENUM){const t=fe(e);throw new GraphQLError(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+We(this,t),e)}const n=this.getValue(e.value);if(null==n){const t=fe(e);throw new GraphQLError(`Value "${t}" does not exist in "${this.name}" enum.`+We(this,t),e)}return n.value}toConfig(){const e=W(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()}}function We(e,t){return K("the enum value",re(t,e.getValues().map((e=>e.name))))}class GraphQLInputObjectType{constructor(e){var t;this.name=Ie(e.name),this.description=e.description,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=Ze.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=Z(this.getFields(),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,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()}}function Ze(e){const n=Pe(e.fields);return qe(n)||t(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Z(n,((n,r)=>(!("resolve"in n)||t(!1,`${e.name}.${r} field has a resolve property, but Input Types cannot define resolvers.`),{name:Ie(r),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:oe(n.extensions),astNode:n.astNode})))}function et(e){return xe(e.type)&&void 0===e.defaultValue}function tt(e,t){return e===t||(xe(e)&&xe(t)||!(!we(e)||!we(t)))&&tt(e.ofType,t.ofType)}function nt(e,t,n){return t===n||(xe(n)?!!xe(t)&&nt(e,t.ofType,n.ofType):xe(t)?nt(e,t.ofType,n):we(n)?!!we(t)&&nt(e,t.ofType,n.ofType):!we(t)&&(Ge(n)&&(Se(t)||Oe(t))&&e.isSubType(n,t)))}function rt(e,t,n){return t===n||(Ge(t)?Ge(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!Ge(n)&&e.isSubType(n,t))}const it=2147483647,ot=-2147483648,st=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(e){const t=ft(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: ${P(t)}`);if(n>it||nit||eit||te.name===t))}function ft(e){if(n(e)){if("function"==typeof e.valueOf){const t=e.valueOf();if(!n(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}function ht(e){return Y(e,GraphQLDirective)}class GraphQLDirective{constructor(e){var r,i;this.name=Ie(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=null!==(r=e.isRepeatable)&&void 0!==r&&r,this.extensions=oe(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||t(!1,`@${e.name} locations must be an Array.`);const o=null!==(i=e.args)&&void 0!==i?i:{};n(o)&&!Array.isArray(o)||t(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=Je(o)}get[Symbol.toStringTag](){return"GraphQLDirective"}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:Ke(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const mt=new GraphQLDirective({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[h.FIELD,h.FRAGMENT_SPREAD,h.INLINE_FRAGMENT],args:{if:{type:new GraphQLNonNull(ut),description:"Included when true."}}}),vt=new GraphQLDirective({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[h.FIELD,h.FRAGMENT_SPREAD,h.INLINE_FRAGMENT],args:{if:{type:new GraphQLNonNull(ut),description:"Skipped when true."}}}),yt="No longer supported",Et=new GraphQLDirective({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[h.FIELD_DEFINITION,h.ARGUMENT_DEFINITION,h.INPUT_FIELD_DEFINITION,h.ENUM_VALUE],args:{reason:{type:ct,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:yt}}}),Tt=new GraphQLDirective({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[h.SCALAR],args:{url:{type:new GraphQLNonNull(ct),description:"The URL that specifies the behavior of this scalar."}}}),Nt=Object.freeze([mt,vt,Et,Tt]);function It(e,t){if(xe(t)){const n=It(e,t.ofType);return(null==n?void 0:n.kind)===m.NULL?null:n}if(null===e)return{kind:m.NULL};if(void 0===e)return null;if(we(t)){const n=t.ofType;if("object"==typeof(i=e)&&"function"==typeof(null==i?void 0:i[Symbol.iterator])){const t=[];for(const r of e){const e=It(r,n);null!=e&&t.push(e)}return{kind:m.LIST,values:t}}return It(e,n)}var i;if(De(t)){if(!n(e))return null;const r=[];for(const n of Object.values(t.getFields())){const t=It(e[n.name],n.type);t&&r.push({kind:m.OBJECT_FIELD,name:{kind:m.NAME,value:n.name},value:t})}return{kind:m.OBJECT,fields:r}}if(Re(t)){const n=t.serialize(e);if(null==n)return null;if("boolean"==typeof n)return{kind:m.BOOLEAN,value:n};if("number"==typeof n&&Number.isFinite(n)){const e=String(n);return gt.test(e)?{kind:m.INT,value:e}:{kind:m.FLOAT,value:e}}if("string"==typeof n)return Ae(t)?{kind:m.ENUM,value:n}:t===lt&>.test(n)?{kind:m.INT,value:n}:{kind:m.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${P(n)}.`)}r(!1,"Unexpected input type: "+P(t))}const gt=/^-?(?:0|[1-9][0-9]*)$/,_t=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:ct,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(St))),resolve:e=>Object.values(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new GraphQLNonNull(St),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:St,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:St,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(bt))),resolve:e=>e.getDirectives()}})}),bt=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(ct),resolve:e=>e.name},description:{type:ct,resolve:e=>e.description},isRepeatable:{type:new GraphQLNonNull(ut),resolve:e=>e.isRepeatable},locations:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(Ot))),resolve:e=>e.locations},args:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(At))),args:{includeDeprecated:{type:ut,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))}})}),Ot=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:h.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:h.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:h.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:h.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:h.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:h.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:h.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:h.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:h.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:h.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:h.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:h.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:h.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:h.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:h.UNION,description:"Location adjacent to a union definition."},ENUM:{value:h.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:h.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:h.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:h.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),St=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(xt),resolve:e=>be(e)?wt.SCALAR:Oe(e)?wt.OBJECT:Se(e)?wt.INTERFACE:Le(e)?wt.UNION:Ae(e)?wt.ENUM:De(e)?wt.INPUT_OBJECT:we(e)?wt.LIST:xe(e)?wt.NON_NULL:void r(!1,`Unexpected type: "${P(e)}".`)},name:{type:ct,resolve:e=>"name"in e?e.name:void 0},description:{type:ct,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:ct,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new GraphQLList(new GraphQLNonNull(Lt)),args:{includeDeprecated:{type:ut,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Oe(e)||Se(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new GraphQLList(new GraphQLNonNull(St)),resolve(e){if(Oe(e)||Se(e))return e.getInterfaces()}},possibleTypes:{type:new GraphQLList(new GraphQLNonNull(St)),resolve(e,t,n,{schema:r}){if(Ge(e))return r.getPossibleTypes(e)}},enumValues:{type:new GraphQLList(new GraphQLNonNull(Dt)),args:{includeDeprecated:{type:ut,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Ae(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new GraphQLList(new GraphQLNonNull(At)),args:{includeDeprecated:{type:ut,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(De(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:St,resolve:e=>"ofType"in e?e.ofType:void 0}})}),Lt=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(ct),resolve:e=>e.name},description:{type:ct,resolve:e=>e.description},args:{type:new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(At))),args:{includeDeprecated:{type:ut,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new GraphQLNonNull(St),resolve:e=>e.type},isDeprecated:{type:new GraphQLNonNull(ut),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:ct,resolve:e=>e.deprecationReason}})}),At=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(ct),resolve:e=>e.name},description:{type:ct,resolve:e=>e.description},type:{type:new GraphQLNonNull(St),resolve:e=>e.type},defaultValue:{type:ct,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=It(n,t);return r?fe(r):null}},isDeprecated:{type:new GraphQLNonNull(ut),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:ct,resolve:e=>e.deprecationReason}})}),Dt=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(ct),resolve:e=>e.name},description:{type:ct,resolve:e=>e.description},isDeprecated:{type:new GraphQLNonNull(ut),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:ct,resolve:e=>e.deprecationReason}})});let wt;!function(e){e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.INPUT_OBJECT="INPUT_OBJECT",e.LIST="LIST",e.NON_NULL="NON_NULL"}(wt||(wt={}));const xt=new GraphQLEnumType({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:wt.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:wt.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:wt.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:wt.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:wt.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:wt.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:wt.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:wt.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),kt={name:"__schema",type:new GraphQLNonNull(_t),description:"Access the current type schema of this server.",args:[],resolve:(e,t,n,{schema:r})=>r,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Ft={name:"__type",type:St,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new GraphQLNonNull(ct),defaultValue:void 0,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0}],resolve:(e,{name:t},n,{schema:r})=>r.getType(t),deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Rt={name:"__typename",type:new GraphQLNonNull(ct),description:"The name of the current Object type at runtime.",args:[],resolve:(e,t,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Ct=Object.freeze([_t,bt,Ot,St,Lt,At,Dt,xt]);function Gt(e){return Ct.some((({name:t})=>e.name===t))}function $t(e){if(!function(e){return Y(e,GraphQLSchema)}(e))throw new Error(`Expected ${P(e)} to be a GraphQL schema.`);return e}class GraphQLSchema{constructor(e){var r,i;this.__validationErrors=!0===e.assumeValid?[]:void 0,n(e)||t(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||t(!1,`"types" must be Array if provided but got: ${P(e.types)}.`),!e.directives||Array.isArray(e.directives)||t(!1,`"directives" must be Array if provided but got: ${P(e.directives)}.`),this.description=e.description,this.extensions=oe(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(r=e.extensionASTNodes)&&void 0!==r?r:[],this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=null!==(i=e.directives)&&void 0!==i?i:Nt;const o=new Set(e.types);if(null!=e.types)for(const t of e.types)o.delete(t),Qt(t,o);null!=this._queryType&&Qt(this._queryType,o),null!=this._mutationType&&Qt(this._mutationType,o),null!=this._subscriptionType&&Qt(this._subscriptionType,o);for(const e of this._directives)if(ht(e))for(const t of e.args)Qt(t.type,o);Qt(_t,o),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const e of o){if(null==e)continue;const n=e.name;if(n||t(!1,"One of the provided types for building the Schema is missing a name."),void 0!==this._typeMap[n])throw new Error(`Schema must contain uniquely named types but contains multiple types named "${n}".`);if(this._typeMap[n]=e,Se(e)){for(const t of e.getInterfaces())if(Se(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(Oe(e))for(const t of e.getInterfaces())if(Se(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.objects.push(e)}}}get[Symbol.toStringTag](){return"GraphQLSchema"}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getRootType(e){switch(e){case f.QUERY:return this.getQueryType();case f.MUTATION:return this.getMutationType();case f.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return Le(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){const t=this._implementationsMap[e.name];return null!=t?t:{objects:[],interfaces:[]}}isSubType(e,t){let n=this._subTypeMap[e.name];if(void 0===n){if(n=Object.create(null),Le(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:Object.values(this.getTypeMap()),directives:this.getDirectives(),extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,assumeValid:void 0!==this.__validationErrors}}}function Qt(e,t){const n=Ve(e);if(!t.has(n))if(t.add(n),Le(n))for(const e of n.getTypes())Qt(e,t);else if(Oe(n)||Se(n)){for(const e of n.getInterfaces())Qt(e,t);for(const e of Object.values(n.getFields())){Qt(e.type,t);for(const n of e.args)Qt(n.type,t)}}else if(De(n))for(const e of Object.values(n.getFields()))Qt(e.type,t);return t}function jt(e){if($t(e),e.__validationErrors)return e.__validationErrors;const t=new SchemaValidationContext(e);!function(e){const t=e.schema,n=t.getQueryType();if(n){if(!Oe(n)){var r;e.reportError(`Query root type must be Object type, it cannot be ${P(n)}.`,null!==(r=Ut(t,f.QUERY))&&void 0!==r?r:n.astNode)}}else e.reportError("Query root type must be provided.",t.astNode);const i=t.getMutationType();var o;i&&!Oe(i)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${P(i)}.`,null!==(o=Ut(t,f.MUTATION))&&void 0!==o?o:i.astNode);const s=t.getSubscriptionType();var a;s&&!Oe(s)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${P(s)}.`,null!==(a=Ut(t,f.SUBSCRIPTION))&&void 0!==a?a:s.astNode)}(t),function(e){for(const n of e.schema.getDirectives())if(ht(n)){Vt(e,n);for(const r of n.args){var t;if(Vt(e,r),ke(r.type)||e.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${P(r.type)}.`,r.astNode),ze(r)&&null!=r.deprecationReason)e.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[Ht(r.astNode),null===(t=r.astNode)||void 0===t?void 0:t.type])}}else e.reportError(`Expected directive but got: ${P(n)}.`,null==n?void 0:n.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=Object.values(o.getFields());for(const t of s)if(xe(t.type)&&De(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 Object.values(n))Ue(r)?(Gt(r)||Vt(e,r),Oe(r)||Se(r)?(Mt(e,r),Pt(e,r)):Le(r)?Jt(e,r):Ae(r)?qt(e,r):De(r)&&(Xt(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${P(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._errors.push(new GraphQLError(e,n))}getErrors(){return this._errors}}function Ut(e,t){var n;return null===(n=[e.astNode,...e.extensionASTNodes].flatMap((e=>{var t;return null!==(t=null==e?void 0:e.operationTypes)&&void 0!==t?t:[]})).find((e=>e.operation===t)))||void 0===n?void 0:n.type}function Vt(e,t){t.name.startsWith("__")&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function Mt(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const s of n){var r;if(Vt(e,s),!Fe(s.type))e.reportError(`The type of ${t.name}.${s.name} must be Output Type but got: ${P(s.type)}.`,null===(r=s.astNode)||void 0===r?void 0:r.type);for(const n of s.args){const r=n.name;var i,o;if(Vt(e,n),!ke(n.type))e.reportError(`The type of ${t.name}.${s.name}(${r}:) must be Input Type but got: ${P(n.type)}.`,null===(i=n.astNode)||void 0===i?void 0:i.type);if(ze(n)&&null!=n.deprecationReason)e.reportError(`Required argument ${t.name}.${s.name}(${r}:) cannot be deprecated.`,[Ht(n.astNode),null===(o=n.astNode)||void 0===o?void 0:o.type])}}}function Pt(e,t){const n=Object.create(null);for(const r of t.getInterfaces())Se(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,Kt(t,r)):(n[r.name]=!0,Yt(e,t,r),Bt(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,Kt(t,r)):e.reportError(`Type ${P(t)} must only implement Interface types, it cannot implement ${P(r)}.`,Kt(t,r))}function Bt(e,t,n){const r=t.getFields();for(const c of Object.values(n.getFields())){const u=c.name,l=r[u];if(l){var i,o;if(!nt(e.schema,l.type,c.type))e.reportError(`Interface field ${n.name}.${u} expects type ${P(c.type)} but ${t.name}.${u} is type ${P(l.type)}.`,[null===(i=c.astNode)||void 0===i?void 0:i.type,null===(o=l.astNode)||void 0===o?void 0:o.type]);for(const r of c.args){const i=r.name,o=l.args.find((e=>e.name===i));var s,a;if(o){if(!tt(r.type,o.type))e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expects type ${P(r.type)} but ${t.name}.${u}(${i}:) is type ${P(o.type)}.`,[null===(s=r.astNode)||void 0===s?void 0:s.type,null===(a=o.astNode)||void 0===a?void 0:a.type])}else e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expected but ${t.name}.${u} does not provide it.`,[r.astNode,l.astNode])}for(const r of l.args){const i=r.name;!c.args.find((e=>e.name===i))&&ze(r)&&e.reportError(`Object field ${t.name}.${u} includes required argument ${i} that is missing from the Interface field ${n.name}.${u}.`,[r.astNode,c.astNode])}}else e.reportError(`Interface field ${n.name}.${u} expected but ${t.name} does not provide it.`,[c.astNode,t.astNode,...t.extensionASTNodes])}}function Yt(e,t,n){const r=t.getInterfaces();for(const i of n.getInterfaces())r.includes(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}.`,[...Kt(n,i),...Kt(t,n)])}function Jt(e,t){const n=t.getTypes();0===n.length&&e.reportError(`Union type ${t.name} must define one or more member types.`,[t.astNode,...t.extensionASTNodes]);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.`,zt(t,i.name)):(r[i.name]=!0,Oe(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${P(i)}.`,zt(t,String(i))))}function qt(e,t){const n=t.getValues();0===n.length&&e.reportError(`Enum type ${t.name} must define one or more values.`,[t.astNode,...t.extensionASTNodes]);for(const t of n)Vt(e,t)}function Xt(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Input Object type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const o of n){var r,i;if(Vt(e,o),!ke(o.type))e.reportError(`The type of ${t.name}.${o.name} must be Input Type but got: ${P(o.type)}.`,null===(r=o.astNode)||void 0===r?void 0:r.type);if(et(o)&&null!=o.deprecationReason)e.reportError(`Required input field ${t.name}.${o.name} cannot be deprecated.`,[Ht(o.astNode),null===(i=o.astNode)||void 0===i?void 0:i.type])}}function Kt(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.interfaces)&&void 0!==t?t:[]})).filter((e=>e.name.value===t.name))}function zt(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.types)&&void 0!==t?t:[]})).filter((e=>e.name.value===t))}function Ht(e){var t;return null==e||null===(t=e.directives)||void 0===t?void 0:t.find((e=>e.name.value===Et.name))}function Wt(e,t){switch(t.kind){case m.LIST_TYPE:{const n=Wt(e,t.type);return n&&new GraphQLList(n)}case m.NON_NULL_TYPE:{const n=Wt(e,t.type);return n&&new GraphQLNonNull(n)}case m.NAMED_TYPE:return e.getType(t.name.value)}}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=null!=n?n:Zt,t&&(ke(t)&&this._inputTypeStack.push(t),Ce(t)&&this._parentTypeStack.push(t),Fe(t)&&this._typeStack.push(t))}get[Symbol.toStringTag](){return"TypeInfo"}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 m.SELECTION_SET:{const e=Ve(this.getType());this._parentTypeStack.push(Ce(e)?e:void 0);break}case m.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(Fe(i)?i:void 0);break}case m.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case m.OPERATION_DEFINITION:{const n=t.getRootType(e.operation);this._typeStack.push(Oe(n)?n:void 0);break}case m.INLINE_FRAGMENT:case m.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?Wt(t,n):Ve(this.getType());this._typeStack.push(Fe(r)?r:void 0);break}case m.VARIABLE_DEFINITION:{const n=Wt(t,e.type);this._inputTypeStack.push(ke(n)?n:void 0);break}case m.ARGUMENT:{var n;let t,r;const i=null!==(n=this.getDirective())&&void 0!==n?n:this.getFieldDef();i&&(t=i.args.find((t=>t.name===e.name.value)),t&&(r=t.type)),this._argument=t,this._defaultValueStack.push(t?t.defaultValue:void 0),this._inputTypeStack.push(ke(r)?r:void 0);break}case m.LIST:{const e=je(this.getInputType()),t=we(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(ke(t)?t:void 0);break}case m.OBJECT_FIELD:{const t=Ve(this.getInputType());let n,r;De(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(ke(n)?n:void 0);break}case m.ENUM:{const t=Ve(this.getInputType());let n;Ae(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case m.SELECTION_SET:this._parentTypeStack.pop();break;case m.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case m.DIRECTIVE:this._directive=null;break;case m.OPERATION_DEFINITION:case m.INLINE_FRAGMENT:case m.FRAGMENT_DEFINITION:this._typeStack.pop();break;case m.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case m.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case m.LIST:case m.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case m.ENUM:this._enumValue=null}}}function Zt(e,t,n){const r=n.name.value;return r===kt.name&&e.getQueryType()===t?kt:r===Ft.name&&e.getQueryType()===t?Ft:r===Rt.name&&Ce(t)?Rt:Oe(t)||Se(t)?t.getFields()[r]:void 0}function en(e,t){return{enter(...n){const r=n[0];e.enter(r);const i=de(t,r.kind).enter;if(i){const o=i.apply(t,n);return void 0!==o&&(e.leave(r),d(o)&&e.enter(o)),o}},leave(...n){const r=n[0],i=de(t,r.kind).leave;let o;return i&&(o=i.apply(t,n)),e.leave(r),o}}}function tn(e){return e.kind===m.OPERATION_DEFINITION||e.kind===m.FRAGMENT_DEFINITION}function nn(e){return e.kind===m.SCALAR_TYPE_DEFINITION||e.kind===m.OBJECT_TYPE_DEFINITION||e.kind===m.INTERFACE_TYPE_DEFINITION||e.kind===m.UNION_TYPE_DEFINITION||e.kind===m.ENUM_TYPE_DEFINITION||e.kind===m.INPUT_OBJECT_TYPE_DEFINITION}function rn(e){return e.kind===m.SCALAR_TYPE_EXTENSION||e.kind===m.OBJECT_TYPE_EXTENSION||e.kind===m.INTERFACE_TYPE_EXTENSION||e.kind===m.UNION_TYPE_EXTENSION||e.kind===m.ENUM_TYPE_EXTENSION||e.kind===m.INPUT_OBJECT_TYPE_EXTENSION}function on(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Nt;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===m.DIRECTIVE_DEFINITION){var o;const n=null!==(o=e.arguments)&&void 0!==o?o:[];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(!i.includes(n)){const o=re(n,i);e.reportError(new GraphQLError(`Unknown argument "${n}" on directive "@${r}".`+K(o),t))}}return!1}}}function sn(e){const t=Object.create(null),n=e.getSchema(),i=n?n.getDirectives():Nt;for(const e of i)t[e.name]=e.locations;const o=e.getDocument().definitions;for(const e of o)e.kind===m.DIRECTIVE_DEFINITION&&(t[e.name.value]=e.locations.map((e=>e.value)));return{Directive(n,i,o,s,a){const c=n.name.value,u=t[c];if(!u)return void e.reportError(new GraphQLError(`Unknown directive "@${c}".`,n));const l=function(e){const t=e[e.length-1];switch("kind"in t||r(!1),t.kind){case m.OPERATION_DEFINITION:return function(e){switch(e){case f.QUERY:return h.QUERY;case f.MUTATION:return h.MUTATION;case f.SUBSCRIPTION:return h.SUBSCRIPTION}}(t.operation);case m.FIELD:return h.FIELD;case m.FRAGMENT_SPREAD:return h.FRAGMENT_SPREAD;case m.INLINE_FRAGMENT:return h.INLINE_FRAGMENT;case m.FRAGMENT_DEFINITION:return h.FRAGMENT_DEFINITION;case m.VARIABLE_DEFINITION:return h.VARIABLE_DEFINITION;case m.SCHEMA_DEFINITION:case m.SCHEMA_EXTENSION:return h.SCHEMA;case m.SCALAR_TYPE_DEFINITION:case m.SCALAR_TYPE_EXTENSION:return h.SCALAR;case m.OBJECT_TYPE_DEFINITION:case m.OBJECT_TYPE_EXTENSION:return h.OBJECT;case m.FIELD_DEFINITION:return h.FIELD_DEFINITION;case m.INTERFACE_TYPE_DEFINITION:case m.INTERFACE_TYPE_EXTENSION:return h.INTERFACE;case m.UNION_TYPE_DEFINITION:case m.UNION_TYPE_EXTENSION:return h.UNION;case m.ENUM_TYPE_DEFINITION:case m.ENUM_TYPE_EXTENSION:return h.ENUM;case m.ENUM_VALUE_DEFINITION:return h.ENUM_VALUE;case m.INPUT_OBJECT_TYPE_DEFINITION:case m.INPUT_OBJECT_TYPE_EXTENSION:return h.INPUT_OBJECT;case m.INPUT_VALUE_DEFINITION:{const t=e[e.length-3];return"kind"in t||r(!1),t.kind===m.INPUT_OBJECT_TYPE_DEFINITION?h.INPUT_FIELD_DEFINITION:h.ARGUMENT_DEFINITION}default:r(!1,"Unexpected kind: "+P(t.kind))}}(a);l&&!u.includes(l)&&e.reportError(new GraphQLError(`Directive "@${c}" may not be used on ${l}.`,n))}}}function an(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);for(const t of e.getDocument().definitions)nn(t)&&(r[t.name.value]=!0);const i=[...Object.keys(n),...Object.keys(r)];return{NamedType(t,o,s,a,c){const u=t.name.value;if(!n[u]&&!r[u]){var l;const n=null!==(l=c[2])&&void 0!==l?l:s,r=null!=n&&("kind"in(p=n)&&(function(e){return e.kind===m.SCHEMA_DEFINITION||nn(e)||e.kind===m.DIRECTIVE_DEFINITION}(p)||function(e){return e.kind===m.SCHEMA_EXTENSION||rn(e)}(p)));if(r&&cn.includes(u))return;const o=re(u,r?cn.concat(i):i);e.reportError(new GraphQLError(`Unknown type "${u}".`+K(o),t))}var p}}}const cn=[...pt,...Ct].map((e=>e.name));function un(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 ln(e){switch(e.kind){case m.OBJECT:return{...e,fields:(t=e.fields,t.map((e=>({...e,value:ln(e.value)}))).sort(((e,t)=>ee(e.name.value,t.name.value))))};case m.LIST:return{...e,values:e.values.map(ln)};case m.INT:case m.FLOAT:case m.STRING:case m.BOOLEAN:case m.NULL:case m.ENUM:case m.VARIABLE:return e}var t}function pn(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+pn(t))).join(" and "):e}function dn(e,t,n,r,i,o,s){const a=e.getFragment(s);if(!a)return;const[c,u]=Tn(e,n,a);if(o!==c){hn(e,t,n,r,i,o,c);for(const a of u)r.has(a,s,i)||(r.add(a,s,i),dn(e,t,n,r,i,o,a))}}function fn(e,t,n,r,i,o,s){if(o===s)return;if(r.has(o,s,i))return;r.add(o,s,i);const a=e.getFragment(o),c=e.getFragment(s);if(!a||!c)return;const[u,l]=Tn(e,n,a),[p,d]=Tn(e,n,c);hn(e,t,n,r,i,u,p);for(const s of d)fn(e,t,n,r,i,o,s);for(const o of l)fn(e,t,n,r,i,o,s)}function hn(e,t,n,r,i,o,s){for(const[a,c]of Object.entries(o)){const o=s[a];if(o)for(const s of c)for(const c of o){const o=mn(e,n,r,i,a,s,c);o&&t.push(o)}}}function mn(e,t,n,r,i,o,s){const[a,c,u]=o,[l,p,d]=s,f=r||a!==l&&Oe(a)&&Oe(l);if(!f){const e=c.name.value,t=p.name.value;if(e!==t)return[[i,`"${e}" and "${t}" are different fields`],[c],[p]];if(vn(c)!==vn(p))return[[i,"they have differing arguments"],[c],[p]]}const h=null==u?void 0:u.type,m=null==d?void 0:d.type;if(h&&m&&yn(h,m))return[[i,`they return conflicting types "${P(h)}" and "${P(m)}"`],[c],[p]];const v=c.selectionSet,y=p.selectionSet;if(v&&y){const r=function(e,t,n,r,i,o,s,a){const c=[],[u,l]=En(e,t,i,o),[p,d]=En(e,t,s,a);hn(e,c,t,n,r,u,p);for(const i of d)dn(e,c,t,n,r,u,i);for(const i of l)dn(e,c,t,n,r,p,i);for(const i of l)for(const o of d)fn(e,c,t,n,r,i,o);return c}(e,t,n,f,Ve(h),v,Ve(m),y);return function(e,t,n,r){if(e.length>0)return[[t,e.map((([e])=>e))],[n,...e.map((([,e])=>e)).flat()],[r,...e.map((([,,e])=>e)).flat()]]}(r,i,c,p)}}function vn(e){var t;const n=null!==(t=e.arguments)&&void 0!==t?t:[];return fe(ln({kind:m.OBJECT,fields:n.map((e=>({kind:m.OBJECT_FIELD,name:e.name,value:e.value})))}))}function yn(e,t){return we(e)?!we(t)||yn(e.ofType,t.ofType):!!we(t)||(xe(e)?!xe(t)||yn(e.ofType,t.ofType):!!xe(t)||!(!Re(e)&&!Re(t))&&e!==t)}function En(e,t,n,r){const i=t.get(r);if(i)return i;const o=Object.create(null),s=Object.create(null);Nn(e,n,r,o,s);const a=[o,Object.keys(s)];return t.set(r,a),a}function Tn(e,t,n){const r=t.get(n.selectionSet);if(r)return r;const i=Wt(e.getSchema(),n.typeCondition);return En(e,t,i,n.selectionSet)}function Nn(e,t,n,r,i){for(const o of n.selections)switch(o.kind){case m.FIELD:{const e=o.name.value;let n;(Oe(t)||Se(t))&&(n=t.getFields()[e]);const i=o.alias?o.alias.value:e;r[i]||(r[i]=[]),r[i].push([t,o,n]);break}case m.FRAGMENT_SPREAD:i[o.name.value]=!0;break;case m.INLINE_FRAGMENT:{const n=o.typeCondition,s=n?Wt(e.getSchema(),n):t;Nn(e,s,o.selectionSet,r,i);break}}}class PairSet{constructor(){this._data=new Map}has(e,t,n){var r;const[i,o]=ee.name));const o=e.getDocument().definitions;for(const e of o)if(e.kind===m.DIRECTIVE_DEFINITION){var s;const t=null!==(s=e.arguments)&&void 0!==s?s:[];n[e.name.value]=H(t.filter(_n),(e=>e.name.value))}return{Directive:{leave(t){const r=t.name.value,i=n[r];if(i){var o;const n=null!==(o=t.arguments)&&void 0!==o?o:[],s=new Set(n.map((e=>e.name.value)));for(const[n,o]of Object.entries(i))if(!s.has(n)){const i=_e(o.type)?P(o.type):fe(o.type);e.reportError(new GraphQLError(`Directive "@${r}" argument "${n}" of type "${i}" is required, but it was not provided.`,t))}}}}}}function _n(e){return e.type.kind===m.NON_NULL_TYPE&&null==e.defaultValue}function bn(e,t,n){if(e){if(e.kind===m.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&xe(t))return;return i}if(xe(t)){if(e.kind===m.NULL)return;return bn(e,t.ofType,n)}if(e.kind===m.NULL)return null;if(we(t)){const r=t.ofType;if(e.kind===m.LIST){const t=[];for(const i of e.values)if(On(i,n)){if(xe(r))return;t.push(null)}else{const e=bn(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=bn(e,r,n);if(void 0===i)return;return[i]}if(De(t)){if(e.kind!==m.OBJECT)return;const r=Object.create(null),i=H(e.fields,(e=>e.name.value));for(const e of Object.values(t.getFields())){const t=i[e.name];if(!t||On(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(xe(e.type))return;continue}const o=bn(t.value,e.type,n);if(void 0===o)return;r[e.name]=o}return r}if(Re(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}r(!1,"Unexpected input type: "+P(t))}}function On(e,t){return e.kind===m.VARIABLE&&(null==t||void 0===t[e.name.value])}function Sn(e,t,n){var r;const i=null===(r=t.directives)||void 0===r?void 0:r.find((t=>t.name.value===e.name));if(i)return function(e,t,n){var r;const i={},o=H(null!==(r=t.arguments)&&void 0!==r?r:[],(e=>e.name.value));for(const r of e.args){const e=r.name,c=r.type,u=o[e];if(!u){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(xe(c))throw new GraphQLError(`Argument "${e}" of required type "${P(c)}" was not provided.`,t);continue}const l=u.value;let p=l.kind===m.NULL;if(l.kind===m.VARIABLE){const t=l.name.value;if(null==n||(s=n,a=t,!Object.prototype.hasOwnProperty.call(s,a))){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(xe(c))throw new GraphQLError(`Argument "${e}" of required type "${P(c)}" was provided the variable "$${t}" which was not provided a runtime value.`,l);continue}p=null==n[t]}if(p&&xe(c))throw new GraphQLError(`Argument "${e}" of non-null type "${P(c)}" must not be null.`,l);const d=bn(l,c,n);if(void 0===d)throw new GraphQLError(`Argument "${e}" has invalid value ${fe(l)}.`,l);i[e]=d}var s,a;return i}(e,i,n)}function Ln(e,t,n,r,i){const o=new Map;return An(e,t,n,r,i,o,new Set),o}function An(e,t,n,r,i,o,s){for(const c of i.selections)switch(c.kind){case m.FIELD:{if(!Dn(n,c))continue;const e=(a=c).alias?a.alias.value:a.name.value,t=o.get(e);void 0!==t?t.push(c):o.set(e,[c]);break}case m.INLINE_FRAGMENT:if(!Dn(n,c)||!wn(e,c,r))continue;An(e,t,n,r,c.selectionSet,o,s);break;case m.FRAGMENT_SPREAD:{const i=c.name.value;if(s.has(i)||!Dn(n,c))continue;s.add(i);const a=t[i];if(!a||!wn(e,a,r))continue;An(e,t,n,r,a.selectionSet,o,s);break}}var a}function Dn(e,t){const n=Sn(vt,t,e);if(!0===(null==n?void 0:n.if))return!1;const r=Sn(mt,t,e);return!1!==(null==r?void 0:r.if)}function wn(e,t,n){const r=t.typeCondition;if(!r)return!0;const i=Wt(e,r);return i===n||!!Ge(i)&&e.isSubType(i,n)}function xn(e,t){const n=new Map;for(const r of e){const e=t(r),i=n.get(e);void 0===i?n.set(e,[r]):i.push(r)}return n}function kn(e){return{Field:t,Directive:t};function t(t){var n;const r=xn(null!==(n=t.arguments)&&void 0!==n?n:[],(e=>e.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new GraphQLError(`There can be only one argument named "${t}".`,n.map((e=>e.name))))}}function Fn(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Nt;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===m.DIRECTIVE_DEFINITION&&(t[e.name.value]=!e.repeatable);const o=Object.create(null),s=Object.create(null);return{enter(n){if(!("directives"in n)||!n.directives)return;let r;if(n.kind===m.SCHEMA_DEFINITION||n.kind===m.SCHEMA_EXTENSION)r=o;else if(nn(n)||rn(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 Rn(e,t){return!!(Oe(e)||Se(e)||De(e))&&null!=e.getFields()[t]}function Cn(e){const t=[];let n=Object.create(null);return{ObjectValue:{enter(){t.push(n),n=Object.create(null)},leave(){const e=t.pop();e||r(!1),n=e}},ObjectField(t){const r=t.name.value;n[r]?e.reportError(new GraphQLError(`There can be only one input field named "${r}".`,[n[r],t.name])):n[r]=t.name}}}function Gn(e,t){const n=e.getInputType();if(!n)return;const r=Ve(n);if(Re(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=P(n);e.reportError(new GraphQLError(`Expected value of type "${r}", found ${fe(t)}.`,t))}}catch(r){const i=P(n);r instanceof GraphQLError?e.reportError(r):e.reportError(new GraphQLError(`Expected value of type "${i}", found ${fe(t)}; `+r.message,t,void 0,void 0,void 0,r))}else{const r=P(n);e.reportError(new GraphQLError(`Expected value of type "${r}", found ${fe(t)}.`,t))}}function $n(e,t,n,r,i){if(xe(r)&&!xe(t)){const o=void 0!==i;if(!(null!=n&&n.kind!==m.NULL)&&!o)return!1;return nt(e,t,r.ofType)}return nt(e,t,r)}const Qn=Object.freeze([function(e){return{Document(t){for(const n of t.definitions)if(!tn(n)){const t=n.kind===m.SCHEMA_DEFINITION||n.kind===m.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';e.reportError(new GraphQLError(`The ${t} definition is not executable.`,n))}return!1}}},function(e){const t=Object.create(null);return{OperationDefinition(n){const r=n.name;return r&&(t[r.value]?e.reportError(new GraphQLError(`There can be only one operation named "${r.value}".`,[t[r.value],r])):t[r.value]=r),!1},FragmentDefinition:()=>!1}},function(e){let t=0;return{Document(e){t=e.definitions.filter((e=>e.kind===m.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){if("subscription"===t.operation){const n=e.getSchema(),r=n.getSubscriptionType();if(r){const i=t.name?t.name.value:null,o=Object.create(null),s=e.getDocument(),a=Object.create(null);for(const e of s.definitions)e.kind===m.FRAGMENT_DEFINITION&&(a[e.name.value]=e);const c=Ln(n,a,o,r,t.selectionSet);if(c.size>1){const t=[...c.values()].slice(1).flat();e.reportError(new GraphQLError(null!=i?`Subscription "${i}" must select only one top level field.`:"Anonymous Subscription must select only one top level field.",t))}for(const t of c.values()){t[0].name.value.startsWith("__")&&e.reportError(new GraphQLError(null!=i?`Subscription "${i}" must not select an introspection top level field.`:"Anonymous Subscription must not select an introspection top level field.",t))}}}}}},an,function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=Wt(e.getSchema(),n);if(t&&!Ce(t)){const t=fe(n);e.reportError(new GraphQLError(`Fragment cannot condition on non composite type "${t}".`,n))}}},FragmentDefinition(t){const n=Wt(e.getSchema(),t.typeCondition);if(n&&!Ce(n)){const n=fe(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=Wt(e.getSchema(),t.type);if(void 0!==n&&!ke(n)){const n=t.variable.name.value,r=fe(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(Re(Ve(n))){if(r){const i=t.name.value,o=P(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=P(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=K("to use an inline fragment on",function(e,t,n){if(!Ge(t))return[];const r=new Set,i=Object.create(null);for(const s of e.getPossibleTypes(t))if(s.getFields()[n]){r.add(s),i[s.name]=1;for(const e of s.getInterfaces()){var o;e.getFields()[n]&&(r.add(e),i[e.name]=(null!==(o=i[e.name])&&void 0!==o?o:0)+1)}}return[...r].sort(((t,n)=>{const r=i[n.name]-i[t.name];return 0!==r?r:Se(t)&&e.isSubType(t,n)?-1:Se(n)&&e.isSubType(n,t)?1:ee(t.name,n.name)})).map((e=>e.name))}(r,n,i));""===o&&(o=K(function(e,t){if(Oe(e)||Se(e)){return re(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))}}},un,function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(Ce(n)&&Ce(r)&&!rt(e.getSchema(),n,r)){const i=P(r),o=P(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=Wt(e.getSchema(),n.typeCondition);if(Ce(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!rt(e.getSchema(),r,i)){const o=P(i),s=P(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){return{OperationDefinition(t){var n;const r=xn(null!==(n=t.variableDefinitions)&&void 0!==n?n:[],(e=>e.variable.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new GraphQLError(`There can be only one variable named "$${t}".`,n.map((e=>e.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)}}},sn,Fn,function(e){return{...on(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,o=re(n,r.args.map((e=>e.name)));e.reportError(new GraphQLError(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+K(o),t))}}}},kn,function(e){return{ListValue(t){if(!we(je(e.getParentInputType())))return Gn(e,t),!1},ObjectValue(t){const n=Ve(e.getInputType());if(!De(n))return Gn(e,t),!1;const r=H(t.fields,(e=>e.name.value));for(const i of Object.values(n.getFields())){if(!r[i.name]&&et(i)){const r=P(i.type);e.reportError(new GraphQLError(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,t))}}},ObjectField(t){const n=Ve(e.getParentInputType());if(!e.getInputType()&&De(n)){const r=re(t.name.value,Object.keys(n.getFields()));e.reportError(new GraphQLError(`Field "${t.name.value}" is not defined by type "${n.name}".`+K(r),t))}},NullValue(t){const n=e.getInputType();xe(n)&&e.reportError(new GraphQLError(`Expected value of type "${P(n)}", found ${fe(t)}.`,t))},EnumValue:t=>Gn(e,t),IntValue:t=>Gn(e,t),FloatValue:t=>Gn(e,t),StringValue:t=>Gn(e,t),BooleanValue:t=>Gn(e,t)}},function(e){return{...gn(e),Field:{leave(t){var n;const r=e.getFieldDef();if(!r)return!1;const i=new Set(null===(n=t.arguments)||void 0===n?void 0:n.map((e=>e.name.value)));for(const n of r.args)if(!i.has(n.name)&&ze(n)){const i=P(n.type);e.reportError(new GraphQLError(`Field "${r.name}" argument "${n.name}" of type "${i}" 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=Wt(t,s.type);if(a&&!$n(t,a,s.defaultValue,i,o)){const t=P(a),o=P(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]=En(e,t,r,i);if(function(e,t,n,r,i){for(const[o,s]of Object.entries(i))if(s.length>1)for(let i=0;i0&&e.reportError(new GraphQLError("Must provide only one schema definition.",t)),++s)}}},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){var i;const o=null!==(i=t.operationTypes)&&void 0!==i?i:[];for(const t of o){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(null==n||!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){var i;const o=t.name.value;r[o]||(r[o]=Object.create(null));const s=null!==(i=t.values)&&void 0!==i?i:[],a=r[o];for(const t of s){const r=t.name.value,i=n[o];Ae(i)&&i.getValue(r)?e.reportError(new GraphQLError(`Enum value "${o}.${r}" already exists in the schema. It cannot also be defined in this type extension.`,t.name)):a[r]?e.reportError(new GraphQLError(`Enum value "${o}.${r}" can only be defined once.`,[a[r],t.name])):a[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){var i;const o=t.name.value;r[o]||(r[o]=Object.create(null));const s=null!==(i=t.fields)&&void 0!==i?i:[],a=r[o];for(const t of s){const r=t.name.value;Rn(n[o],r)?e.reportError(new GraphQLError(`Field "${o}.${r}" already exists in the schema. It cannot also be defined in this type extension.`,t.name)):a[r]?e.reportError(new GraphQLError(`Field "${o}.${r}" can only be defined once.`,[a[r],t.name])):a[r]=t.name}return!1}},function(e){return{DirectiveDefinition(e){var t;const r=null!==(t=e.arguments)&&void 0!==t?t:[];return n(`@${e.name.value}`,r)},InterfaceTypeDefinition:t,InterfaceTypeExtension:t,ObjectTypeDefinition:t,ObjectTypeExtension:t};function t(e){var t;const r=e.name.value,i=null!==(t=e.fields)&&void 0!==t?t:[];for(const e of i){var o;n(`${r}.${e.name.value}`,null!==(o=e.arguments)&&void 0!==o?o:[])}return!1}function n(t,n){const r=xn(n,(e=>e.name.value));for(const[n,i]of r)i.length>1&&e.reportError(new GraphQLError(`Argument "${t}(${n}:)" can only be defined once.`,i.map((e=>e.name))));return!1}},function(e){const t=Object.create(null),n=e.getSchema();return{DirectiveDefinition(r){const i=r.name.value;if(null==n||!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))}}},an,sn,Fn,function(e){const t=e.getSchema(),n=Object.create(null);for(const t of e.getDocument().definitions)nn(t)&&(n[t.name.value]=t);return{ScalarTypeExtension:i,ObjectTypeExtension:i,InterfaceTypeExtension:i,UnionTypeExtension:i,EnumTypeExtension:i,InputObjectTypeExtension:i};function i(i){const o=i.name.value,s=n[o],a=null==t?void 0:t.getType(o);let c;if(s?c=In[s.kind]:a&&(c=function(e){if(be(e))return m.SCALAR_TYPE_EXTENSION;if(Oe(e))return m.OBJECT_TYPE_EXTENSION;if(Se(e))return m.INTERFACE_TYPE_EXTENSION;if(Le(e))return m.UNION_TYPE_EXTENSION;if(Ae(e))return m.ENUM_TYPE_EXTENSION;if(De(e))return m.INPUT_OBJECT_TYPE_EXTENSION;r(!1,"Unexpected type: "+P(e))}(a)),c){if(c!==i.kind){const t=function(e){switch(e){case m.SCALAR_TYPE_EXTENSION:return"scalar";case m.OBJECT_TYPE_EXTENSION:return"object";case m.INTERFACE_TYPE_EXTENSION:return"interface";case m.UNION_TYPE_EXTENSION:return"union";case m.ENUM_TYPE_EXTENSION:return"enum";case m.INPUT_OBJECT_TYPE_EXTENSION:return"input object";default:r(!1,"Unexpected kind: "+P(e))}}(i.kind);e.reportError(new GraphQLError(`Cannot extend non-${t} type "${o}".`,s?[s,i]:i))}}else{const r=re(o,Object.keys({...n,...null==t?void 0:t.getTypeMap()}));e.reportError(new GraphQLError(`Cannot extend type "${o}" because it is not defined.`+K(r),i.name))}}},on,kn,Cn,gn]);class ASTValidationContext{constructor(e,t){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=t}get[Symbol.toStringTag](){return"ASTValidationContext"}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let t;if(this._fragments)t=this._fragments;else{t=Object.create(null);for(const e of this.getDocument().definitions)e.kind===m.FRAGMENT_DEFINITION&&(t[e.name.value]=e);this._fragments=t}return t[e]}getFragmentSpreads(e){let t=this._fragmentSpreads.get(e);if(!t){t=[];const n=[e];let r;for(;r=n.pop();)for(const e of r.selections)e.kind===m.FRAGMENT_SPREAD?t.push(e):e.selectionSet&&n.push(e.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];let i;for(;i=r.pop();)for(const e of this.getFragmentSpreads(i)){const i=e.name.value;if(!0!==n[i]){n[i]=!0;const e=this.getFragment(i);e&&(t.push(e),r.push(e.selectionSet))}}this._recursivelyReferencedFragments.set(e,t)}return t}}class SDLValidationContext extends ASTValidationContext{constructor(e,t,n){super(e,n),this._schema=t}get[Symbol.toStringTag](){return"SDLValidationContext"}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}get[Symbol.toStringTag](){return"ValidationContext"}getSchema(){return this._schema}getVariableUsages(e){let t=this._variableUsages.get(e);if(!t){const n=[],r=new TypeInfo(this._schema);le(e,en(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 Un(e,n,r=Qn,i,o=new TypeInfo(e)){var s;const a=null!==(s=null==i?void 0:i.maxErrors)&&void 0!==s?s:100;n||t(!1,"Must provide document."),function(e){const t=jt(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}(e);const c=Object.freeze({}),u=[],l=new ValidationContext(e,n,o,(e=>{if(u.length>=a)throw u.push(new GraphQLError("Too many validation errors, error limit reached. Validation aborted.")),c;u.push(e)})),p=pe(r.map((e=>e(l))));try{le(n,en(o,p))}catch(e){if(e!==c)throw e}return u}function Vn(e,t,n=jn){const r=[],i=new SDLValidationContext(e,t,(e=>{r.push(e)}));return le(e,pe(n.map((e=>e(i))))),r}function Mn(e,r){n(e)&&n(e.__schema)||t(!1,`Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${P(e)}.`);const i=e.__schema,o=W(i.types,(e=>e.name),(e=>function(e){if(null!=e&&null!=e.name&&null!=e.kind)switch(e.kind){case wt.SCALAR:return new GraphQLScalarType({name:(r=e).name,description:r.description,specifiedByURL:r.specifiedByURL});case wt.OBJECT:return new GraphQLObjectType({name:(n=e).name,description:n.description,interfaces:()=>h(n),fields:()=>m(n)});case wt.INTERFACE:return new GraphQLInterfaceType({name:(t=e).name,description:t.description,interfaces:()=>h(t),fields:()=>m(t)});case wt.UNION:return function(e){if(!e.possibleTypes){const t=P(e);throw new Error(`Introspection result missing possibleTypes: ${t}.`)}return new GraphQLUnionType({name:e.name,description:e.description,types:()=>e.possibleTypes.map(d)})}(e);case wt.ENUM:return function(e){if(!e.enumValues){const t=P(e);throw new Error(`Introspection result missing enumValues: ${t}.`)}return new GraphQLEnumType({name:e.name,description:e.description,values:W(e.enumValues,(e=>e.name),(e=>({description:e.description,deprecationReason:e.deprecationReason})))})}(e);case wt.INPUT_OBJECT:return function(e){if(!e.inputFields){const t=P(e);throw new Error(`Introspection result missing inputFields: ${t}.`)}return new GraphQLInputObjectType({name:e.name,description:e.description,fields:()=>E(e.inputFields)})}(e)}var t;var n;var r;const i=P(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[...pt,...Ct])o[e.name]&&(o[e.name]=e);const s=i.queryType?d(i.queryType):null,a=i.mutationType?d(i.mutationType):null,c=i.subscriptionType?d(i.subscriptionType):null,u=i.directives?i.directives.map((function(e){if(!e.args){const t=P(e);throw new Error(`Introspection result missing directive args: ${t}.`)}if(!e.locations){const t=P(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:E(e.args)})})):[];return new GraphQLSchema({description:i.description,query:s,mutation:a,subscription:c,types:Object.values(o),directives:u,assumeValid:null==r?void 0:r.assumeValid});function l(e){if(e.kind===wt.LIST){const t=e.ofType;if(!t)throw new Error("Decorated type deeper than introspection query.");return new GraphQLList(l(t))}if(e.kind===wt.NON_NULL){const t=e.ofType;if(!t)throw new Error("Decorated type deeper than introspection query.");const n=l(t);return new GraphQLNonNull(function(e){if(!Qe(e))throw new Error(`Expected ${P(e)} to be a GraphQL nullable type.`);return e}(n))}return p(e)}function p(e){const t=e.name;if(!t)throw new Error(`Unknown type reference: ${P(e)}.`);const n=o[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 d(e){return function(e){if(!Oe(e))throw new Error(`Expected ${P(e)} to be a GraphQL Object type.`);return e}(p(e))}function f(e){return function(e){if(!Se(e))throw new Error(`Expected ${P(e)} to be a GraphQL Interface type.`);return e}(p(e))}function h(e){if(null===e.interfaces&&e.kind===wt.INTERFACE)return[];if(!e.interfaces){const t=P(e);throw new Error(`Introspection result missing interfaces: ${t}.`)}return e.interfaces.map(f)}function m(e){if(!e.fields)throw new Error(`Introspection result missing fields: ${P(e)}.`);return W(e.fields,(e=>e.name),y)}function y(e){const t=l(e.type);if(!Fe(t)){const e=P(t);throw new Error(`Introspection must provide output type for fields, but received: ${e}.`)}if(!e.args){const t=P(e);throw new Error(`Introspection result missing field args: ${t}.`)}return{description:e.description,deprecationReason:e.deprecationReason,type:t,args:E(e.args)}}function E(e){return W(e,(e=>e.name),T)}function T(e){const t=l(e.type);if(!ke(t)){const e=P(t);throw new Error(`Introspection must provide input type for arguments, but received: ${e}.`)}const n=null!=e.defaultValue?bn(function(e,t){const n=new Parser(e,t);n.expectToken(v.SOF);const r=n.parseValueLiteral(!1);return n.expectToken(v.EOF),r}(e.defaultValue),t):void 0;return{description:e.description,type:t,defaultValue:n,deprecationReason:e.deprecationReason}}}function Pn(e,t,n){var i,o,s,a;const c=[],u=Object.create(null),l=[];let p;const d=[];for(const e of t.definitions)if(e.kind===m.SCHEMA_DEFINITION)p=e;else if(e.kind===m.SCHEMA_EXTENSION)d.push(e);else if(nn(e))c.push(e);else if(rn(e)){const t=e.name.value,n=u[t];u[t]=n?n.concat([e]):[e]}else e.kind===m.DIRECTIVE_DEFINITION&&l.push(e);if(0===Object.keys(u).length&&0===c.length&&0===l.length&&0===d.length&&null==p)return e;const f=Object.create(null);for(const t of e.types)f[t.name]=T(t);for(const e of c){var h;const t=e.name.value;f[t]=null!==(h=Bn[t])&&void 0!==h?h:x(e)}const v={query:e.query&&E(e.query),mutation:e.mutation&&E(e.mutation),subscription:e.subscription&&E(e.subscription),...p&&g([p]),...g(d)};return{description:null===(i=p)||void 0===i||null===(o=i.description)||void 0===o?void 0:o.value,...v,types:Object.values(f),directives:[...e.directives.map((function(e){const t=e.toConfig();return new GraphQLDirective({...t,args:Z(t.args,I)})})),...l.map((function(e){var t;return new GraphQLDirective({name:e.name.value,description:null===(t=e.description)||void 0===t?void 0:t.value,locations:e.locations.map((({value:e})=>e)),isRepeatable:e.repeatable,args:S(e.arguments),astNode:e})}))],extensions:Object.create(null),astNode:null!==(s=p)&&void 0!==s?s:e.astNode,extensionASTNodes:e.extensionASTNodes.concat(d),assumeValid:null!==(a=null==n?void 0:n.assumeValid)&&void 0!==a&&a};function y(e){return we(e)?new GraphQLList(y(e.ofType)):xe(e)?new GraphQLNonNull(y(e.ofType)):E(e)}function E(e){return f[e.name]}function T(e){return Gt(e)||dt(e)?e:be(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[n.name])&&void 0!==t?t:[];let i=n.specifiedByURL;for(const e of r){var o;i=null!==(o=Jn(e))&&void 0!==o?o:i}return new GraphQLScalarType({...n,specifiedByURL:i,extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):Oe(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[n.name])&&void 0!==t?t:[];return new GraphQLObjectType({...n,interfaces:()=>[...e.getInterfaces().map(E),...D(r)],fields:()=>({...Z(n.fields,N),...O(r)}),extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):Se(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[n.name])&&void 0!==t?t:[];return new GraphQLInterfaceType({...n,interfaces:()=>[...e.getInterfaces().map(E),...D(r)],fields:()=>({...Z(n.fields,N),...O(r)}),extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):Le(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[n.name])&&void 0!==t?t:[];return new GraphQLUnionType({...n,types:()=>[...e.getTypes().map(E),...w(r)],extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):Ae(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[e.name])&&void 0!==t?t:[];return new GraphQLEnumType({...n,values:{...n.values,...A(r)},extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):De(e)?function(e){var t;const n=e.toConfig(),r=null!==(t=u[n.name])&&void 0!==t?t:[];return new GraphQLInputObjectType({...n,fields:()=>({...Z(n.fields,(e=>({...e,type:y(e.type)}))),...L(r)}),extensionASTNodes:n.extensionASTNodes.concat(r)})}(e):void r(!1,"Unexpected type: "+P(e))}function N(e){return{...e,type:y(e.type),args:e.args&&Z(e.args,I)}}function I(e){return{...e,type:y(e.type)}}function g(e){const t={};for(const r of e){var n;const e=null!==(n=r.operationTypes)&&void 0!==n?n:[];for(const n of e)t[n.operation]=_(n.type)}return t}function _(e){var t;const n=e.name.value,r=null!==(t=Bn[n])&&void 0!==t?t:f[n];if(void 0===r)throw new Error(`Unknown type: "${n}".`);return r}function b(e){return e.kind===m.LIST_TYPE?new GraphQLList(b(e.type)):e.kind===m.NON_NULL_TYPE?new GraphQLNonNull(b(e.type)):_(e)}function O(e){const t=Object.create(null);for(const i of e){var n;const e=null!==(n=i.fields)&&void 0!==n?n:[];for(const n of e){var r;t[n.name.value]={type:b(n.type),description:null===(r=n.description)||void 0===r?void 0:r.value,args:S(n.arguments),deprecationReason:Yn(n),astNode:n}}}return t}function S(e){const t=null!=e?e:[],n=Object.create(null);for(const e of t){var r;const t=b(e.type);n[e.name.value]={type:t,description:null===(r=e.description)||void 0===r?void 0:r.value,defaultValue:bn(e.defaultValue,t),deprecationReason:Yn(e),astNode:e}}return n}function L(e){const t=Object.create(null);for(const i of e){var n;const e=null!==(n=i.fields)&&void 0!==n?n:[];for(const n of e){var r;const e=b(n.type);t[n.name.value]={type:e,description:null===(r=n.description)||void 0===r?void 0:r.value,defaultValue:bn(n.defaultValue,e),deprecationReason:Yn(n),astNode:n}}}return t}function A(e){const t=Object.create(null);for(const i of e){var n;const e=null!==(n=i.values)&&void 0!==n?n:[];for(const n of e){var r;t[n.name.value]={description:null===(r=n.description)||void 0===r?void 0:r.value,deprecationReason:Yn(n),astNode:n}}}return t}function D(e){return e.flatMap((e=>{var t,n;return null!==(t=null===(n=e.interfaces)||void 0===n?void 0:n.map(_))&&void 0!==t?t:[]}))}function w(e){return e.flatMap((e=>{var t,n;return null!==(t=null===(n=e.types)||void 0===n?void 0:n.map(_))&&void 0!==t?t:[]}))}function x(e){var t;const n=e.name.value,r=null!==(t=u[n])&&void 0!==t?t:[];switch(e.kind){case m.OBJECT_TYPE_DEFINITION:{var i;const t=[e,...r];return new GraphQLObjectType({name:n,description:null===(i=e.description)||void 0===i?void 0:i.value,interfaces:()=>D(t),fields:()=>O(t),astNode:e,extensionASTNodes:r})}case m.INTERFACE_TYPE_DEFINITION:{var o;const t=[e,...r];return new GraphQLInterfaceType({name:n,description:null===(o=e.description)||void 0===o?void 0:o.value,interfaces:()=>D(t),fields:()=>O(t),astNode:e,extensionASTNodes:r})}case m.ENUM_TYPE_DEFINITION:{var s;const t=[e,...r];return new GraphQLEnumType({name:n,description:null===(s=e.description)||void 0===s?void 0:s.value,values:A(t),astNode:e,extensionASTNodes:r})}case m.UNION_TYPE_DEFINITION:{var a;const t=[e,...r];return new GraphQLUnionType({name:n,description:null===(a=e.description)||void 0===a?void 0:a.value,types:()=>w(t),astNode:e,extensionASTNodes:r})}case m.SCALAR_TYPE_DEFINITION:var c;return new GraphQLScalarType({name:n,description:null===(c=e.description)||void 0===c?void 0:c.value,specifiedByURL:Jn(e),astNode:e,extensionASTNodes:r});case m.INPUT_OBJECT_TYPE_DEFINITION:{var l;const t=[e,...r];return new GraphQLInputObjectType({name:n,description:null===(l=e.description)||void 0===l?void 0:l.value,fields:()=>L(t),astNode:e,extensionASTNodes:r})}}}}const Bn=H([...pt,...Ct],(e=>e.name));function Yn(e){const t=Sn(Et,e);return null==t?void 0:t.reason}function Jn(e){const t=Sn(Tt,e);return null==t?void 0:t.url}function qn(e,n){null!=e&&e.kind===m.DOCUMENT||t(!1,"Must provide valid Document AST."),!0!==(null==n?void 0:n.assumeValid)&&!0!==(null==n?void 0:n.assumeValidSDL)&&function(e){const t=Vn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}(e);const r=Pn({description:void 0,types:[],directives:[],extensions:Object.create(null),extensionASTNodes:[],assumeValid:!1},e,n);if(null==r.astNode)for(const e of r.types)switch(e.name){case"Query":r.query=e;break;case"Mutation":r.mutation=e;break;case"Subscription":r.subscription=e}const i=[...r.directives,...Nt.filter((e=>r.directives.every((t=>t.name!==e.name))))];return new GraphQLSchema({...r,directives:i})}function Xn(e){return function(e,t,n){const i=e.getDirectives().filter(t),o=Object.values(e.getTypeMap()).filter(n);return[zn(e),...i.map((e=>function(e){return rr(e)+"directive @"+e.name+er(e.args)+(e.isRepeatable?" repeatable":"")+" on "+e.locations.join(" | ")}(e))),...o.map((e=>function(e){if(be(e))return function(e){return rr(e)+`scalar ${e.name}`+function(e){if(null==e.specifiedByURL)return"";return` @specifiedBy(url: ${fe({kind:m.STRING,value:e.specifiedByURL})})`}(e)}(e);if(Oe(e))return function(e){return rr(e)+`type ${e.name}`+Hn(e)+Wn(e)}(e);if(Se(e))return function(e){return rr(e)+`interface ${e.name}`+Hn(e)+Wn(e)}(e);if(Le(e))return function(e){const t=e.getTypes(),n=t.length?" = "+t.join(" | "):"";return rr(e)+"union "+e.name+n}(e);if(Ae(e))return function(e){const t=e.getValues().map(((e,t)=>rr(e," ",!t)+" "+e.name+nr(e.deprecationReason)));return rr(e)+`enum ${e.name}`+Zn(t)}(e);if(De(e))return function(e){const t=Object.values(e.getFields()).map(((e,t)=>rr(e," ",!t)+" "+tr(e)));return rr(e)+`input ${e.name}`+Zn(t)}(e);r(!1,"Unexpected type: "+P(e))}(e)))].filter(Boolean).join("\n\n")}(e,(e=>{return t=e,!Nt.some((({name:e})=>e===t.name));var t}),Kn)}function Kn(e){return!dt(e)&&!Gt(e)}function zn(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}`),rr(e)+`schema {\n${t.join("\n")}\n}`}function Hn(e){const t=e.getInterfaces();return t.length?" implements "+t.map((e=>e.name)).join(" & "):""}function Wn(e){return Zn(Object.values(e.getFields()).map(((e,t)=>rr(e," ",!t)+" "+e.name+er(e.args," ")+": "+String(e.type)+nr(e.deprecationReason))))}function Zn(e){return 0!==e.length?" {\n"+e.join("\n")+"\n}":""}function er(e,t=""){return 0===e.length?"":e.every((e=>!e.description))?"("+e.map(tr).join(", ")+")":"(\n"+e.map(((e,n)=>rr(e," "+t,!n)+" "+t+tr(e))).join("\n")+"\n"+t+")"}function tr(e){const t=It(e.defaultValue,e.type);let n=e.name+": "+String(e.type);return t&&(n+=` = ${fe(t)}`),n+nr(e.deprecationReason)}function nr(e){if(null==e)return"";if(e!==yt){return` @deprecated(reason: ${fe({kind:m.STRING,value:e})})`}return" @deprecated"}function rr(e,t="",n=!0){const{description:r}=e;if(null==r)return"";return(t&&!n?"\n"+t:t)+fe({kind:m.STRING,value:r,block:b(r)}).replace(/\n/g,"\n"+t)+"\n"}const ir=[un],or=[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))}}},...Qn.filter((e=>!ir.includes(e)))];class GraphQLSchemaValidationError extends Error{constructor(e){super(e.map((e=>e.message)).join("\n\n")),this.validationErrors=e,this.name="GraphQLSchemaValidationError"}}function sr(e){const t=jt(e);if(0!==t.length)throw new GraphQLSchemaValidationError(t)}function ar(e){return e.startsWith("__")}function cr(e){return null!=e}function ur(e){switch(e.kind){case m.VARIABLE:return{kind:e.kind,value:e.name.value};case m.LIST:return{kind:e.kind,value:e.values.map(ur)};case m.OBJECT:return{kind:e.kind,value:e.fields.reduce(((e,t)=>(e[t.name.value]=ur(t.value),e)),{})};default:return e}}function lr(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 pr(e,t){const n=new Map;for(const e of t.definitions)e.kind===m.FRAGMENT_DEFINITION&&n.set(e.name.value,e);const r=[],i=new Map,o=new Set;for(const e of t.definitions)e.kind===m.OPERATION_DEFINITION&&r.push(a(e));for(const[e,t]of n.entries())i.set(e,c(t));return{operations:r,fragments:Array.from(i.values()),referencedTypes:Array.from(o.values())};function s(t){if(o.add(t),Le(t)){const e=t.getTypes();for(t of e)o.add(Ve(t))}De(t)&&function(t){var n;const r=null===(n=t.astNode)||void 0===n?void 0:n.fields;if(r)for(const t of r){s(Ve(Wt(e,t.type)))}}(t)}function a(t){if(!t.name)throw new GraphQLError("Operations should be named",t);const n=lr(t),r=t.name.value,i=t.operation,a=(t.variableDefinitions||[]).map((t=>{const n=t.variable.name.value,r=t.defaultValue?ur(t.defaultValue):void 0,i=Wt(e,t.type);if(!i)throw new GraphQLError(`Couldn't get type from type node "${t.type}"`,{nodes:t});return s(Ve(i)),{name:n,type:i,defaultValue:r}})),c=fe(t),l=e.getRootType(i);return o.add(Ve(l)),{filePath:n,name:r,operationType:i,rootType:l,variables:a,source:c,selectionSet:u(t.selectionSet,l)}}function c(t){const n=t.name.value,r=lr(t),i=fe(t),o=Wt(e,t.typeCondition);return s(Ve(o)),{name:n,filePath:r,source:i,typeCondition:o,selectionSet:u(t.selectionSet,o)}}function u(t,r,o=new Set){return{parentType:r,selections:t.selections.map((t=>function(t,r,o){var a;switch(t.kind){case m.FIELD:{const n=t.name.value,i=null===(a=t.alias)||void 0===a?void 0:a.value,o=function(e,t,n){return n===kt.name&&e.getQueryType()===t?kt:n===Ft.name&&e.getQueryType()===t?Ft:n===Rt.name&&(Oe(t)||Se(t)||Le(t))?Rt:Oe(t)||Se(t)?t.getFields()[n]:void 0}(e,r,n);if(!o)throw new GraphQLError(`Cannot query field "${n}" on type "${String(r)}"`,{nodes:t});const c=o.type,l=Ve(c);s(Ve(l));const{description:p,deprecationReason:d}=o,f=t.arguments&&t.arguments.length>0?t.arguments.map((e=>{const n=e.name.value,r=o.args.find((t=>t.name===e.name.value)),i=null==r?void 0:r.type;if(!i)throw new GraphQLError(`Cannot find argument type for argument "${n}" on field "${t.name.value}"`,{nodes:[t,e]});return{name:n,value:ur(e.value),type:i}})):void 0;let h={kind:"Field",name:n,alias:i,arguments:f,type:c,description:!ar(n)&&p?p:void 0,deprecationReason:d||void 0};if(Ce(l)){const e=t.selectionSet;if(!e)throw new GraphQLError(`Composite field "${n}" on type "${String(r)}" requires selection set`,t);h.selectionSet=u(e,l)}return h}case m.INLINE_FRAGMENT:{const n=t.typeCondition,i=n?Wt(e,n):r;return s(i),{kind:"InlineFragment",selectionSet:u(t.selectionSet,i)}}case m.FRAGMENT_SPREAD:{const e=t.name.value;if(o.has(e))return;o.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=c(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,o))).filter(cr)}}}return m.FIELD,m.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 pr(e,t)},e.loadSchemaFromIntrospectionResult=function(e){let t=JSON.parse(e);t.data&&(t=t.data);const n=Mn(t);return sr(n),n},e.loadSchemaFromSDL=function(e){const t=J(e);!function(e){const t=Vn(e);if(0!==t.length)throw new GraphQLSchemaValidationError(t)}(t);const n=qn(t,{assumeValidSDL:!0});return sr(n),n},e.mergeDocuments=function(e){return function(e){const t=[];for(const n of e)t.push(...n.definitions);return{kind:m.DOCUMENT,definitions:t}}(e)},e.parseDocument=function(e){return J(e)},e.printSchemaToSDL=function(e){return Xn(e)},e.validateDocument=function(e,t){return Un(e,t,or)},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); diff --git a/Sources/ApolloCodegenLib/IR/IR+Field.swift b/Sources/ApolloCodegenLib/IR/IR+Field.swift index 595b6a8290..ac1e6638eb 100644 --- a/Sources/ApolloCodegenLib/IR/IR+Field.swift +++ b/Sources/ApolloCodegenLib/IR/IR+Field.swift @@ -9,6 +9,7 @@ extension IR { var alias: String? { underlyingField.alias } var responseKey: String { underlyingField.responseKey } var type: GraphQLType { underlyingField.type } + var arguments: [CompilationResult.Argument]? { underlyingField.arguments } fileprivate init(_ field: CompilationResult.Field) { self.underlyingField = field diff --git a/Sources/ApolloCodegenLib/TemplateString.swift b/Sources/ApolloCodegenLib/TemplateString.swift index 006e89b8e8..f70751d256 100644 --- a/Sources/ApolloCodegenLib/TemplateString.swift +++ b/Sources/ApolloCodegenLib/TemplateString.swift @@ -5,11 +5,15 @@ struct TemplateString: ExpressibleByStringInterpolation, CustomStringConvertible private let value: String private let lastLineWasRemoved: Bool - init(stringLiteral: String) { - self.value = stringLiteral + init(_ string: String) { + self.value = string lastLineWasRemoved = false } + init(stringLiteral: String) { + self.init(stringLiteral) + } + init(stringInterpolation: StringInterpolation) { self.value = stringInterpolation.output self.lastLineWasRemoved = stringInterpolation.lastLineWasRemoved @@ -106,6 +110,14 @@ struct TemplateString: ExpressibleByStringInterpolation, CustomStringConvertible appendInterpolation(elementsString) } + mutating func appendInterpolation(list: T) + where T: Collection, T.Element: CustomStringConvertible { + let shouldWrapInNewlines = list.count > 1 + if shouldWrapInNewlines { appendLiteral("\n ") } + appendInterpolation(list) + if shouldWrapInNewlines { appendInterpolation("\n") } + } + mutating func appendInterpolation( if bool: Bool, _ template: @autoclosure () -> TemplateString, @@ -120,18 +132,6 @@ struct TemplateString: ExpressibleByStringInterpolation, CustomStringConvertible } } - private mutating func removeLineIfEmpty() { - let slice = substringToStartOfLine() - if slice.allSatisfy(\.isWhitespace) { - buffer.removeLast(slice.count) - lastLineWasRemoved = true - } - } - - private func substringToStartOfLine() -> Slice> { - return buffer.reversed().prefix { !$0.isNewline } - } - mutating func appendInterpolation( ifLet optional: Optional, where whereBlock: ((T) -> Bool)? = nil, @@ -141,13 +141,32 @@ struct TemplateString: ExpressibleByStringInterpolation, CustomStringConvertible if let element = optional, whereBlock?(element) ?? true { appendInterpolation(includeBlock(element)) } else if let elseTemplate = `else` { - appendInterpolation(elseTemplate.value) + appendInterpolation(elseTemplate.description) } else { removeLineIfEmpty() } } + private mutating func removeLineIfEmpty() { + let slice = substringToStartOfLine() + if slice.allSatisfy(\.isWhitespace) { + buffer.removeLast(slice.count) + lastLineWasRemoved = true + } + } + + private func substringToStartOfLine() -> Slice> { + return buffer.reversed().prefix { !$0.isNewline } + } + } + +} + +/// Can be used to concatenate a `TemplateString` and `String` directly. +/// This bypasses `TemplateString` interpolation logic such as indentation calculation. +func +(lhs: String, rhs: TemplateString) -> TemplateString { + TemplateString(lhs + rhs.description) } fileprivate extension Array where Element == Substring { diff --git a/Sources/ApolloCodegenLib/Templates/InputObjectTemplate.swift b/Sources/ApolloCodegenLib/Templates/InputObjectTemplate.swift index 55a8fcfa02..4bd82b37b1 100644 --- a/Sources/ApolloCodegenLib/Templates/InputObjectTemplate.swift +++ b/Sources/ApolloCodegenLib/Templates/InputObjectTemplate.swift @@ -11,13 +11,17 @@ struct InputObjectTemplate { \(ImportStatementTemplate.SchemaType.render()) - struct \(graphqlInputObject.name.firstUppercased): InputObject { - private(set) public var dict: InputDict + public struct \(graphqlInputObject.name.firstUppercased): InputObject { + public private(set) var data: InputDict + + public init(_ data: InputDict) { + self.data = data + } - init( + public init( \(InitializerParametersTemplate()) ) { - dict = InputDict([ + data = InputDict([ \(InputDictInitializerTemplate()) ]) } @@ -31,7 +35,7 @@ struct InputObjectTemplate { private func InitializerParametersTemplate() -> TemplateString { TemplateString(""" \(graphqlInputObject.fields.map({ - "\($1.name): \($1.renderType(includeDefault: true))" + "\($1.name): \($1.renderInputValueType(includeDefault: true))" }), separator: ",\n") """) } @@ -44,76 +48,10 @@ struct InputObjectTemplate { private func FieldPropertyTemplate(_ field: GraphQLInputField) -> String { """ - var \(field.name): \(field.renderType()) { - get { dict[\"\(field.name)\"] } - set { dict[\"\(field.name)\"] = newValue } + public var \(field.name): \(field.renderInputValueType()) { + get { data.\(field.name) } + set { data.\(field.name) = newValue } } """ } } - -fileprivate extension GraphQLInputField { - func renderType(includeDefault: Bool = false) -> String { - "\(type.render())\(isSwiftOptional ? "?" : "")\(includeDefault && hasSwiftNilDefault ? " = nil" : "")" - } - - var isSwiftOptional: Bool { - !isNullable && hasSchemaDefault - } - - var hasSwiftNilDefault: Bool { - isNullable && !hasSchemaDefault - } - - var isNullable: Bool { - switch type { - case .nonNull(_): return false - default: return true - } - } - - var hasSchemaDefault: Bool { - switch defaultValue { - case .none, .some(nil): - return false - case let .some(value): - guard let value = value as? JSValue else { - fatalError("Cannot determine default value for Input field: \(self)") - } - - return !value.isUndefined - } - } -} - -fileprivate extension GraphQLType { - enum NullabilityContainer { - case none - case graphqlNullable - case swiftOptional - } - - func render(nullability: NullabilityContainer = .graphqlNullable) -> String { - switch self { - case let .entity(type as GraphQLNamedType), - let .enum(type as GraphQLNamedType), - let .scalar(type as GraphQLNamedType), - let .inputObject(type as GraphQLNamedType): - - switch nullability { - case .none: return type.swiftName - case .graphqlNullable: return "GraphQLNullable<\(type.swiftName)>" - case .swiftOptional: return "\(type.swiftName)?" - } - - case let .nonNull(ofType): - return ofType.render(nullability: .none) - - case let .list(ofType): - let inner = "[\(ofType.render(nullability: .swiftOptional))]" - - if nullability == .graphqlNullable { return "GraphQLNullable<\(inner)>" } - else { return inner } - } - } -} diff --git a/Sources/ApolloCodegenLib/Templates/OperationDefinitionTemplate.swift b/Sources/ApolloCodegenLib/Templates/OperationDefinitionTemplate.swift index c578fe729b..4cff725cb5 100644 --- a/Sources/ApolloCodegenLib/Templates/OperationDefinitionTemplate.swift +++ b/Sources/ApolloCodegenLib/Templates/OperationDefinitionTemplate.swift @@ -16,7 +16,11 @@ struct OperationDefinitionTemplate { \(OperationDeclaration(operation.definition)) \(DocumentType.render(operation.definition, fragments: operation.referencedFragments, apq: config.apqs)) - public init() {} + \(section: Variables.Properties(operation.definition.variables)) + + \(Initializer(operation.definition.variables)) + + \(section: Variables.Accessors(operation.definition.variables)) \(SelectionSetTemplate(schema: schema).render(for: operation)) } @@ -60,6 +64,53 @@ struct OperationDefinitionTemplate { ) } } + + private func Initializer( + _ variables: [CompilationResult.VariableDefinition] + ) -> TemplateString { + let `init` = "public init" + if variables.isEmpty { + return "\(`init`)() {}" + } + + return """ + \(`init`)(\(list: variables.map(Variables.Parameter))) { + \(variables.map { "self.\($0.name) = \($0.name)" }, separator: "\n") + } + """ + } + + enum Variables { + static func Properties( + _ variables: [CompilationResult.VariableDefinition] + ) -> TemplateString { + """ + \(variables.map { "public var \($0.name): \($0.type.renderAsInputValue())"}, separator: "\n") + """ + } + + static func Parameter(_ variable: CompilationResult.VariableDefinition) -> TemplateString { + """ + \(variable.name): \(variable.type.renderAsInputValue())\ + \(if: variable.defaultValue != nil, " = " + variable.renderVariableDefaultValue()) + """ + } + + static func Accessors( + _ variables: [CompilationResult.VariableDefinition] + ) -> TemplateString { + guard !variables.isEmpty else { + return "" + } + + return """ + public var variables: Variables? { + [\(variables.map { "\"\($0.name)\": \($0.name)"}, separator: ",\n ")] + } + """ + } + } + } fileprivate extension ApolloCodegenConfiguration.APQConfig { diff --git a/Sources/ApolloCodegenLib/Templates/RenderingHelpers/FieldArgumentRendering.swift b/Sources/ApolloCodegenLib/Templates/RenderingHelpers/FieldArgumentRendering.swift new file mode 100644 index 0000000000..4db259409a --- /dev/null +++ b/Sources/ApolloCodegenLib/Templates/RenderingHelpers/FieldArgumentRendering.swift @@ -0,0 +1,22 @@ +import OrderedCollections + +extension GraphQLValue { + func renderInputValueLiteral() -> TemplateString { + switch self { + case let .string(string): return "\"\(string)\"" + case let .boolean(boolean): return boolean ? "true" : "false" + case let .int(int): return TemplateString(int.description) + case let .float(float): return TemplateString(float.description) + case let .enum(enumValue): return "\"\(enumValue)\"" + case .null: return ".null" + case let .list(list): + return "[\(list.map{ $0.renderInputValueLiteral() }, separator: ", ")]" + + case let .object(object): + return "[\(list: object.map{ "\"\($0.0)\": " + $0.1.renderInputValueLiteral() })]" + + case let .variable(variableName): + return ".variable(\"\(variableName)\")" + } + } +} diff --git a/Sources/ApolloCodegenLib/Templates/RenderingHelpers/GraphQLInputField+Rendered.swift b/Sources/ApolloCodegenLib/Templates/RenderingHelpers/GraphQLInputField+Rendered.swift new file mode 100644 index 0000000000..12b4ba1319 --- /dev/null +++ b/Sources/ApolloCodegenLib/Templates/RenderingHelpers/GraphQLInputField+Rendered.swift @@ -0,0 +1,31 @@ +import JavaScriptCore + +extension GraphQLInputField { + func renderInputValueType(includeDefault: Bool = false) -> String { + "\(type.renderAsInputValue())\(isSwiftOptional ? "?" : "")\(includeDefault && hasSwiftNilDefault ? " = nil" : "")" + } + + private var isSwiftOptional: Bool { + !isNullable && hasDefaultValue + } + + private var hasSwiftNilDefault: Bool { + isNullable && !hasDefaultValue + } + + var isNullable: Bool { + switch type { + case .nonNull: return false + default: return true + } + } + + var hasDefaultValue: Bool { + switch defaultValue { + case .none, .some(nil): + return false + case .some: + return true + } + } +} diff --git a/Sources/ApolloCodegenLib/GraphQLNamedType+Swift.swift b/Sources/ApolloCodegenLib/Templates/RenderingHelpers/GraphQLNamedType+SwiftName.swift similarity index 100% rename from Sources/ApolloCodegenLib/GraphQLNamedType+Swift.swift rename to Sources/ApolloCodegenLib/Templates/RenderingHelpers/GraphQLNamedType+SwiftName.swift diff --git a/Sources/ApolloCodegenLib/Templates/RenderingHelpers/GraphQLType+Rendered.swift b/Sources/ApolloCodegenLib/Templates/RenderingHelpers/GraphQLType+Rendered.swift new file mode 100644 index 0000000000..a1402ee4dc --- /dev/null +++ b/Sources/ApolloCodegenLib/Templates/RenderingHelpers/GraphQLType+Rendered.swift @@ -0,0 +1,63 @@ +extension GraphQLType { + var rendered: String { + rendered(containedInNonNull: false) + } + + func rendered(replacingNamedTypeWith newTypeName: String) -> String { + rendered(containedInNonNull: false, replacingNamedTypeWith: newTypeName) + } + + private func rendered( + containedInNonNull: Bool, + replacingNamedTypeWith newTypeName: String? = nil + ) -> String { + switch self { + case let .entity(type as GraphQLNamedType), + let .scalar(type as GraphQLNamedType), + let .inputObject(type as GraphQLNamedType): + + let typeName = newTypeName ?? type.swiftName + + return containedInNonNull ? typeName : "\(typeName)?" + + case let .enum(type as GraphQLNamedType): + let typeName = newTypeName ?? type.name + let enumType = "GraphQLEnum<\(typeName)>" + + return containedInNonNull ? enumType : "\(enumType)?" + + case let .nonNull(ofType): + return ofType.rendered(containedInNonNull: true, replacingNamedTypeWith: newTypeName) + + case let .list(ofType): + let inner = "[\(ofType.rendered(containedInNonNull: false, replacingNamedTypeWith: newTypeName))]" + + return containedInNonNull ? inner : "\(inner)?" + } + } + + // MARK: Input Value + + /// Renders the type for use as an input value. + /// + /// If the outermost type is nullable, it will be wrapped in a `GraphQLNullable` instead of + /// an `Optional`. + func renderAsInputValue() -> String { + return renderAsInputValue(inNullable: true) + } + + private func renderAsInputValue(inNullable: Bool) -> String { + switch self { + case .entity, .enum, .scalar, .inputObject: + let typeName = self.rendered(containedInNonNull: true) + return inNullable ? "GraphQLNullable<\(typeName)>" : typeName + + case let .nonNull(ofType): + return ofType.renderAsInputValue(inNullable: false) + + case let .list(ofType): + let typeName = "[\(ofType.rendered)]" + return inNullable ? "GraphQLNullable<\(typeName)>" : typeName + } + } +} diff --git a/Sources/ApolloCodegenLib/Templates/RenderingHelpers/InputVariableRenderable.swift b/Sources/ApolloCodegenLib/Templates/RenderingHelpers/InputVariableRenderable.swift new file mode 100644 index 0000000000..b04c98c394 --- /dev/null +++ b/Sources/ApolloCodegenLib/Templates/RenderingHelpers/InputVariableRenderable.swift @@ -0,0 +1,81 @@ +import OrderedCollections + +protocol InputVariableRenderable { + var type: GraphQLType { get } + var defaultValue: GraphQLValue? { get } +} + +extension CompilationResult.VariableDefinition: InputVariableRenderable {} + +struct InputVariable: InputVariableRenderable { + let type: GraphQLType + let defaultValue: GraphQLValue? +} + +extension InputVariableRenderable { + func renderVariableDefaultValue() -> TemplateString { + renderVariableDefaultValue(inList: false) + } + + private func renderVariableDefaultValue(inList: Bool) -> TemplateString { + switch defaultValue { + case .none: return "" + case .null: return inList ? "nil" : ".null" + case let .string(string): return "\"\(string)\"" + case let .boolean(boolean): return boolean ? "true" : "false" + case let .int(int): return TemplateString(int.description) + case let .float(float): return TemplateString(float.description) + case let .enum(enumValue): return ".init(.\(enumValue))" + case let .list(list): + switch type { + case let .nonNull(.list(listInnerType)), + let .list(listInnerType): + return """ + [\(list.compactMap { + InputVariable(type: listInnerType, defaultValue: $0).renderVariableDefaultValue(inList: true) + }, separator: ", ")] + """ + + default: + preconditionFailure("Variable type must be List with value of .list type.") + } + + case let .object(object): + switch type { + case let .nonNull(.inputObject(inputObjectType)): + return inputObjectType.renderInitializer(values: object) + + case let .inputObject(inputObjectType): + return """ + .init( + \(inputObjectType.renderInitializer(values: object)) + ) + """ + + default: + preconditionFailure("Variable type must be InputObject with value of .object type.") + } + + case .variable: + preconditionFailure("Variable cannot be used as Default Value for an Operation Variable!") + } + } +} + +fileprivate extension GraphQLInputObjectType { + func renderInitializer(values: OrderedDictionary) -> TemplateString { + let entries = values.compactMap { entry -> TemplateString in + guard let field = self.fields[entry.0] else { + preconditionFailure("Field \(entry.0) not found on input object.") + } + + let variable = InputVariable(type: field.type, defaultValue: entry.value) + + return "\(entry.0): " + variable.renderVariableDefaultValue() + } + + return """ + \(name)(\(list: entries)) + """ + } +} diff --git a/Sources/ApolloCodegenLib/Templates/SelectionSetTemplate.swift b/Sources/ApolloCodegenLib/Templates/SelectionSetTemplate.swift index a41acc4558..328abd42c5 100644 --- a/Sources/ApolloCodegenLib/Templates/SelectionSetTemplate.swift +++ b/Sources/ApolloCodegenLib/Templates/SelectionSetTemplate.swift @@ -100,7 +100,14 @@ struct SelectionSetTemplate { private func FieldSelectionTemplate(_ field: IR.Field) -> TemplateString { """ - .field("\(field.name)", \(ifLet: field.alias, {"alias: \"\($0)\", "})\(typeName(for: field)).self) + .field("\(field.name)"\ + \(ifLet: field.alias, {", alias: \"\($0)\""})\ + , \(typeName(for: field)).self\ + \(ifLet: field.arguments, + where: { !$0.isEmpty }, { args in + ", arguments: " + renderValue(for: args) + })\ + ) """ } @@ -117,6 +124,10 @@ struct SelectionSetTemplate { } } + private func renderValue(for arguments: [CompilationResult.Argument]) -> TemplateString { + "[\(list: arguments.map{ "\"\($0.name)\": " + $0.value.renderInputValueLiteral() })]" + } + private func TypeCaseSelectionTemplate(_ typeCase: IR.SelectionSet.TypeInfo) -> TemplateString { """ .typeCase(As\(typeCase.parentType.name.firstUppercased).self) @@ -261,45 +272,6 @@ fileprivate extension GraphQLCompositeType { } } -fileprivate extension GraphQLType { - var rendered: String { - rendered(containedInNonNull: false) - } - - func rendered(replacingNamedTypeWith newTypeName: String) -> String { - rendered(containedInNonNull: false, replacingNamedTypeWith: newTypeName) - } - - private func rendered( - containedInNonNull: Bool, - replacingNamedTypeWith newTypeName: String? = nil - ) -> String { - switch self { - case let .entity(type as GraphQLNamedType), - let .scalar(type as GraphQLNamedType), - let .inputObject(type as GraphQLNamedType): - - let typeName = newTypeName ?? type.swiftName - - return containedInNonNull ? typeName : "\(typeName)?" - - case let .enum(type as GraphQLNamedType): - let typeName = newTypeName ?? type.name - let enumType = "GraphQLEnum<\(typeName)>" - - return containedInNonNull ? enumType : "\(enumType)?" - - case let .nonNull(ofType): - return ofType.rendered(containedInNonNull: true, replacingNamedTypeWith: newTypeName) - - case let .list(ofType): - let inner = "[\(ofType.rendered(containedInNonNull: false, replacingNamedTypeWith: newTypeName))]" - - return containedInNonNull ? inner : "\(inner)?" - } - } -} - fileprivate extension IR.SelectionSet { /// Indicates if the SelectionSet should be rendered by the template engine. diff --git a/Sources/ApolloCodegenTestSupport/MockCompilationResult.swift b/Sources/ApolloCodegenTestSupport/MockCompilationResult.swift index f23e723dc6..07b958f27a 100644 --- a/Sources/ApolloCodegenTestSupport/MockCompilationResult.swift +++ b/Sources/ApolloCodegenTestSupport/MockCompilationResult.swift @@ -95,3 +95,17 @@ public extension CompilationResult.FragmentDefinition { return mock } } + +public extension CompilationResult.VariableDefinition { + class func mock( + _ name: String, + type: GraphQLType, + defaultValue: GraphQLValue? + ) -> Self { + let mock = Self.emptyMockObject() + mock.name = name + mock.type = type + mock.defaultValue = defaultValue + return mock + } +} diff --git a/Sources/ApolloCodegenTestSupport/MockGraphQLType.swift b/Sources/ApolloCodegenTestSupport/MockGraphQLType.swift index 9668718e48..05243c1d16 100644 --- a/Sources/ApolloCodegenTestSupport/MockGraphQLType.swift +++ b/Sources/ApolloCodegenTestSupport/MockGraphQLType.swift @@ -98,7 +98,7 @@ public extension GraphQLInputField { class func mock( _ name: String, type: GraphQLType, - defaultValue: Any? + defaultValue: GraphQLValue? ) -> Self { let mock = Self.emptyMockObject() mock.name = name diff --git a/Tests/ApolloCodegenTests/AnimalKingdomAPI/AnimalKingdomIRCreationTests.swift b/Tests/ApolloCodegenTests/AnimalKingdomAPI/AnimalKingdomIRCreationTests.swift index ddbf8126f0..963825e9b8 100644 --- a/Tests/ApolloCodegenTests/AnimalKingdomAPI/AnimalKingdomIRCreationTests.swift +++ b/Tests/ApolloCodegenTests/AnimalKingdomAPI/AnimalKingdomIRCreationTests.swift @@ -863,7 +863,7 @@ final class AnimalKingdomIRCreationTests: XCTestCase { expected = ( fields: [ .mock("wingspan", - type: .nonNull(.scalar(GraphQLScalarType.integer()))) + type: .nonNull(.scalar(GraphQLScalarType.float()))) ], typeCases: [], fragments: [] diff --git a/Tests/ApolloCodegenTests/CodeGeneration/Templates/InputObjectTemplateTests.swift b/Tests/ApolloCodegenTests/CodeGeneration/Templates/InputObjectTemplateTests.swift index 1921fa33c6..1d7430c872 100644 --- a/Tests/ApolloCodegenTests/CodeGeneration/Templates/InputObjectTemplateTests.swift +++ b/Tests/ApolloCodegenTests/CodeGeneration/Templates/InputObjectTemplateTests.swift @@ -1,25 +1,16 @@ import XCTest import Nimble @testable import ApolloCodegenLib -import JavaScriptCore class InputObjectTemplateTests: XCTestCase { - var jsVM: JSVirtualMachine! - var jsContext: JSContext! var subject: InputObjectTemplate! override func setUp() { super.setUp() - - jsVM = JSVirtualMachine() - jsContext = JSContext(virtualMachine: jsVM) } override func tearDown() { subject = nil - jsContext = nil - jsVM = nil - super.tearDown() } @@ -68,6 +59,29 @@ class InputObjectTemplateTests: XCTestCase { expect(actual).to(equalLineByLine(expected, atLine: 4, ignoringExtraLines: true)) } + func test__render__generatesDefinitionWithInputDictVariableAndInitializer() throws { + // given + buildSubject( + name: "mockInput", + fields: [GraphQLInputField.mock("field", type: .scalar(.integer()), defaultValue: nil)] + ) + + let expected = """ + public struct MockInput: InputObject { + public private(set) var data: InputDict + + public init(_ data: InputDict) { + self.data = data + } + """ + + // when + let actual = subject.render() + + // then + expect(actual).to(equalLineByLine(expected, atLine: 6, ignoringExtraLines: true)) + } + // MARK: Casing Tests func test__render__givenLowercasedInputObjectField__generatesCorrectlyCasedSwiftDefinition() throws { @@ -77,7 +91,7 @@ class InputObjectTemplateTests: XCTestCase { fields: [GraphQLInputField.mock("field", type: .scalar(.integer()), defaultValue: nil)] ) - let expected = "struct MockInput: InputObject {" + let expected = "public struct MockInput: InputObject {" // when let actual = subject.render() @@ -93,7 +107,7 @@ class InputObjectTemplateTests: XCTestCase { fields: [GraphQLInputField.mock("field", type: .scalar(.integer()), defaultValue: nil)] ) - let expected = "struct MOCKInput: InputObject {" + let expected = "public struct MOCKInput: InputObject {" // when let actual = subject.render() @@ -109,7 +123,7 @@ class InputObjectTemplateTests: XCTestCase { fields: [GraphQLInputField.mock("field", type: .scalar(.integer()), defaultValue: nil)] ) - let expected = "struct MOcK_Input: InputObject {" + let expected = "public struct MOcK_Input: InputObject {" // when let actual = subject.render() @@ -127,17 +141,17 @@ class InputObjectTemplateTests: XCTestCase { ]) let expected = """ - init( + public init( field: GraphQLNullable = nil ) { - dict = InputDict([ + data = InputDict([ "field": field ]) } - var field: GraphQLNullable { - get { dict["field"] } - set { dict["field"] = newValue } + public var field: GraphQLNullable { + get { data.field } + set { data.field = newValue } } } """ @@ -146,7 +160,7 @@ class InputObjectTemplateTests: XCTestCase { let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: false)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: false)) } func test__render__givenAllPossibleSchemaInputFieldTypes__generatesCorrectParametersAndInitializer() throws { @@ -195,16 +209,16 @@ class InputObjectTemplateTests: XCTestCase { ]) let expected = """ - init( + public init( stringField: GraphQLNullable = nil, intField: GraphQLNullable = nil, boolField: GraphQLNullable = nil, floatField: GraphQLNullable = nil, - enumField: GraphQLNullable = nil, + enumField: GraphQLNullable> = nil, inputField: GraphQLNullable = nil, listField: GraphQLNullable<[String?]> = nil ) { - dict = InputDict([ + data = InputDict([ "stringField": stringField, "intField": intField, "boolField": boolField, @@ -215,39 +229,39 @@ class InputObjectTemplateTests: XCTestCase { ]) } - var stringField: GraphQLNullable { - get { dict["stringField"] } - set { dict["stringField"] = newValue } + public var stringField: GraphQLNullable { + get { data.stringField } + set { data.stringField = newValue } } - var intField: GraphQLNullable { - get { dict["intField"] } - set { dict["intField"] = newValue } + public var intField: GraphQLNullable { + get { data.intField } + set { data.intField = newValue } } - var boolField: GraphQLNullable { - get { dict["boolField"] } - set { dict["boolField"] = newValue } + public var boolField: GraphQLNullable { + get { data.boolField } + set { data.boolField = newValue } } - var floatField: GraphQLNullable { - get { dict["floatField"] } - set { dict["floatField"] = newValue } + public var floatField: GraphQLNullable { + get { data.floatField } + set { data.floatField = newValue } } - var enumField: GraphQLNullable { - get { dict["enumField"] } - set { dict["enumField"] = newValue } + public var enumField: GraphQLNullable> { + get { data.enumField } + set { data.enumField = newValue } } - var inputField: GraphQLNullable { - get { dict["inputField"] } - set { dict["inputField"] = newValue } + public var inputField: GraphQLNullable { + get { data.inputField } + set { data.inputField = newValue } } - var listField: GraphQLNullable<[String?]> { - get { dict["listField"] } - set { dict["listField"] = newValue } + public var listField: GraphQLNullable<[String?]> { + get { data.listField } + set { data.listField = newValue } } """ @@ -255,7 +269,7 @@ class InputObjectTemplateTests: XCTestCase { let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } // MARK: Nullable Field Tests @@ -267,47 +281,47 @@ class InputObjectTemplateTests: XCTestCase { ]) let expected = """ - init( + public init( nullable: GraphQLNullable = nil ) { - dict = InputDict([ + data = InputDict([ "nullable": nullable ]) } - var nullable: GraphQLNullable { + public var nullable: GraphQLNullable { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NullableField_WithDefault__generates_NullableParameter_NoInitializerDefault() throws { // given buildSubject(fields: [ - GraphQLInputField.mock("nullableWithDefault", type: .scalar(.integer()), defaultValue: JSValue(int32: 3, in: jsContext)) + GraphQLInputField.mock("nullableWithDefault", type: .scalar(.integer()), defaultValue: .int(3)) ]) let expected = """ - init( + public init( nullableWithDefault: GraphQLNullable ) { - dict = InputDict([ + data = InputDict([ "nullableWithDefault": nullableWithDefault ]) } - var nullableWithDefault: GraphQLNullable { + public var nullableWithDefault: GraphQLNullable { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NonNullableField_NoDefault__generates_NonNullableNonOptionalParameter_NoInitializerDefault() throws { @@ -317,47 +331,47 @@ class InputObjectTemplateTests: XCTestCase { ]) let expected = """ - init( + public init( nonNullable: Int ) { - dict = InputDict([ + data = InputDict([ "nonNullable": nonNullable ]) } - var nonNullable: Int { + public var nonNullable: Int { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NonNullableField_WithDefault__generates_OptionalParameter_NoInitializerDefault() throws { // given buildSubject(fields: [ - GraphQLInputField.mock("nonNullableWithDefault", type: .nonNull(.scalar(.integer())), defaultValue: JSValue(int32: 3, in: jsContext)) + GraphQLInputField.mock("nonNullableWithDefault", type: .nonNull(.scalar(.integer())), defaultValue: .int(3)) ]) let expected = """ - init( + public init( nonNullableWithDefault: Int? ) { - dict = InputDict([ + data = InputDict([ "nonNullableWithDefault": nonNullableWithDefault ]) } - var nonNullableWithDefault: Int? { + public var nonNullableWithDefault: Int? { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NullableList_NullableItem_NoDefault__generates_NullableParameter_OptionalItem_InitializerNilDefault() throws { @@ -367,47 +381,49 @@ class InputObjectTemplateTests: XCTestCase { ]) let expected = """ - init( + public init( nullableListNullableItem: GraphQLNullable<[String?]> = nil ) { - dict = InputDict([ + data = InputDict([ "nullableListNullableItem": nullableListNullableItem ]) } - var nullableListNullableItem: GraphQLNullable<[String?]> { + public var nullableListNullableItem: GraphQLNullable<[String?]> { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NullableList_NullableItem_WithDefault__generates_NullableParameter_OptionalItem_NoInitializerDefault() throws { // given buildSubject(fields: [ - GraphQLInputField.mock("nullableListNullableItemWithDefault", type: .list(.scalar(.string())), defaultValue: JSValue(object: ["val"], in: jsContext)) + GraphQLInputField.mock("nullableListNullableItemWithDefault", + type: .list(.scalar(.string())), + defaultValue: .list([.string("val")])) ]) let expected = """ - init( + public init( nullableListNullableItemWithDefault: GraphQLNullable<[String?]> ) { - dict = InputDict([ + data = InputDict([ "nullableListNullableItemWithDefault": nullableListNullableItemWithDefault ]) } - var nullableListNullableItemWithDefault: GraphQLNullable<[String?]> { + public var nullableListNullableItemWithDefault: GraphQLNullable<[String?]> { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NullableList_NonNullableItem_NoDefault__generates_NullableParameter_NonOptionalItem_InitializerNilDefault() throws { @@ -417,47 +433,49 @@ class InputObjectTemplateTests: XCTestCase { ]) let expected = """ - init( + public init( nullableListNonNullableItem: GraphQLNullable<[String]> = nil ) { - dict = InputDict([ + data = InputDict([ "nullableListNonNullableItem": nullableListNonNullableItem ]) } - var nullableListNonNullableItem: GraphQLNullable<[String]> { + public var nullableListNonNullableItem: GraphQLNullable<[String]> { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NullableList_NonNullableItem_WithDefault__generates_NullableParameter_NonOptionalItem_NoInitializerDefault() throws { // given buildSubject(fields: [ - GraphQLInputField.mock("nullableListNonNullableItemWithDefault", type: .list(.nonNull(.scalar(.string()))), defaultValue: JSValue(object: ["val"], in: jsContext)) + GraphQLInputField.mock("nullableListNonNullableItemWithDefault", + type: .list(.nonNull(.scalar(.string()))), + defaultValue: .list([.string("val")])) ]) let expected = """ - init( + public init( nullableListNonNullableItemWithDefault: GraphQLNullable<[String]> ) { - dict = InputDict([ + data = InputDict([ "nullableListNonNullableItemWithDefault": nullableListNonNullableItemWithDefault ]) } - var nullableListNonNullableItemWithDefault: GraphQLNullable<[String]> { + public var nullableListNonNullableItemWithDefault: GraphQLNullable<[String]> { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NonNullableList_NullableItem_NoDefault__generates_NonNullableNonOptionalParameter_OptionalItem_NoInitializerDefault() throws { @@ -467,47 +485,49 @@ class InputObjectTemplateTests: XCTestCase { ]) let expected = """ - init( + public init( nonNullableListNullableItem: [String?] ) { - dict = InputDict([ + data = InputDict([ "nonNullableListNullableItem": nonNullableListNullableItem ]) } - var nonNullableListNullableItem: [String?] { + public var nonNullableListNullableItem: [String?] { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NonNullableList_NullableItem_WithDefault__generates_OptionalParameter_OptionalItem_NoInitializerDefault() throws { // given buildSubject(fields: [ - GraphQLInputField.mock("nonNullableListNullableItemWithDefault", type: .nonNull(.list(.scalar(.string()))), defaultValue: JSValue(object: ["val"], in: jsContext)) + GraphQLInputField.mock("nonNullableListNullableItemWithDefault", + type: .nonNull(.list(.scalar(.string()))), + defaultValue: .list([.string("val")])) ]) let expected = """ - init( + public init( nonNullableListNullableItemWithDefault: [String?]? ) { - dict = InputDict([ + data = InputDict([ "nonNullableListNullableItemWithDefault": nonNullableListNullableItemWithDefault ]) } - var nonNullableListNullableItemWithDefault: [String?]? { + public var nonNullableListNullableItemWithDefault: [String?]? { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NonNullableList_NonNullableItem_NoDefault__generates_NonNullableNonOptionalParameter_NonOptionalItem_NoInitializerDefault() throws { @@ -517,46 +537,75 @@ class InputObjectTemplateTests: XCTestCase { ]) let expected = """ - init( + public init( nonNullableListNonNullableItem: [String] ) { - dict = InputDict([ + data = InputDict([ "nonNullableListNonNullableItem": nonNullableListNonNullableItem ]) } - var nonNullableListNonNullableItem: [String] { + public var nonNullableListNonNullableItem: [String] { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } func test__render__given_NonNullableList_NonNullableItem_WithDefault__generates_OptionalParameter_NonOptionalItem_NoInitializerDefault() throws { // given buildSubject(fields: [ - GraphQLInputField.mock("nonNullableListNonNullableItemWithDefault", type: .nonNull(.list(.nonNull(.scalar(.string())))), defaultValue: JSValue(object: ["val"], in: jsContext)) + GraphQLInputField.mock("nonNullableListNonNullableItemWithDefault", + type: .nonNull(.list(.nonNull(.scalar(.string())))), + defaultValue: .list([.string("val")])) ]) let expected = """ - init( + public init( nonNullableListNonNullableItemWithDefault: [String]? ) { - dict = InputDict([ + data = InputDict([ "nonNullableListNonNullableItemWithDefault": nonNullableListNonNullableItemWithDefault ]) } - var nonNullableListNonNullableItemWithDefault: [String]? { + public var nonNullableListNonNullableItemWithDefault: [String]? { + """ + + // when + let actual = subject.render() + + // then + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) + } + + func test__render__given_NullableListOfNullableEnum_NoDefault__generates_NullableParameter_OptionalItem_InitializerNilDefault() throws { + // given + buildSubject(fields: [ + GraphQLInputField.mock("nullableListNullableItem", + type: .list(.enum(.mock(name: "EnumValue"))), + defaultValue: nil) + ]) + + let expected = """ + public init( + nullableListNullableItem: GraphQLNullable<[GraphQLEnum?]> = nil + ) { + data = InputDict([ + "nullableListNullableItem": nullableListNullableItem + ]) + } + + public var nullableListNullableItem: GraphQLNullable<[GraphQLEnum?]> { """ // when let actual = subject.render() // then - expect(actual).to(equalLineByLine(expected, atLine: 9, ignoringExtraLines: true)) + expect(actual).to(equalLineByLine(expected, atLine: 13, ignoringExtraLines: true)) } } diff --git a/Tests/ApolloCodegenTests/CodeGeneration/Templates/OperationDefinitionTemplateTests.swift b/Tests/ApolloCodegenTests/CodeGeneration/Templates/OperationDefinitionTemplateTests.swift index 88df8a9d00..67da7fdf31 100644 --- a/Tests/ApolloCodegenTests/CodeGeneration/Templates/OperationDefinitionTemplateTests.swift +++ b/Tests/ApolloCodegenTests/CodeGeneration/Templates/OperationDefinitionTemplateTests.swift @@ -307,4 +307,144 @@ class OperationDefinitionTemplateTests: XCTestCase { // then expect(actual).to(equalLineByLine(expected, atLine: 6, ignoringExtraLines: true)) } + + // MARK: - Variables + + func test__generate__givenQueryWithScalarVariable_generatesQueryOperationWithVariable() throws { + // given + schemaSDL = """ + type Query { + allAnimals: [Animal!] + } + + type Animal { + species: String! + } + """ + + document = """ + query TestOperation($variable: String!) { + allAnimals { + species + } + } + """ + + let expected = + """ + public var variable: String + + public init(variable: String) { + self.variable = variable + } + + public var variables: Variables? { + ["variable": variable] + } + """ + + // when + try buildSubjectAndOperation() + + let actual = subject.render() + + // then + expect(actual).to(equalLineByLine(expected, atLine: 19, ignoringExtraLines: true)) + } + + func test__generate__givenQueryWithMutlipleScalarVariables_generatesQueryOperationWithVariables() throws { + // given + schemaSDL = """ + type Query { + allAnimals: [Animal!] + } + + type Animal { + species: String! + intField: Int! + } + """ + + document = """ + query TestOperation($variable1: String!, $variable2: Boolean!, $variable3: Int!) { + allAnimals { + species + } + } + """ + + let expected = + """ + public var variable1: String + public var variable2: Bool + public var variable3: Int + + public init( + variable1: String, + variable2: Bool, + variable3: Int + ) { + self.variable1 = variable1 + self.variable2 = variable2 + self.variable3 = variable3 + } + + public var variables: Variables? { + ["variable1": variable1, + "variable2": variable2, + "variable3": variable3] + } + """ + + // when + try buildSubjectAndOperation() + + let actual = subject.render() + + // then + expect(actual).to(equalLineByLine(expected, atLine: 19, ignoringExtraLines: true)) + } + + func test__generate__givenQueryWithNullableScalarVariable_generatesQueryOperationWithVariable() throws { + // given + schemaSDL = """ + type Query { + allAnimals: [Animal!] + } + + type Animal { + species: String! + } + """ + + document = """ + query TestOperation($variable: String = "TestVar") { + allAnimals { + species + } + } + """ + + let expected = + """ + public var variable: GraphQLNullable + + public init(variable: GraphQLNullable = "TestVar") { + self.variable = variable + } + + public var variables: Variables? { + ["variable": variable] + } + """ + + // when + try buildSubjectAndOperation() + + let actual = subject.render() + + // then + expect(actual).to(equalLineByLine(expected, atLine: 19, ignoringExtraLines: true)) + } + } diff --git a/Tests/ApolloCodegenTests/CodeGeneration/Templates/OperationDefinition_VariableDefinition_Tests.swift b/Tests/ApolloCodegenTests/CodeGeneration/Templates/OperationDefinition_VariableDefinition_Tests.swift new file mode 100644 index 0000000000..8c1234df5c --- /dev/null +++ b/Tests/ApolloCodegenTests/CodeGeneration/Templates/OperationDefinition_VariableDefinition_Tests.swift @@ -0,0 +1,540 @@ +import XCTest +import Nimble +@testable import ApolloCodegenLib + +class OperationDefinition_VariableDefinition_Tests: XCTestCase { + + var subject: CompilationResult.VariableDefinition! + + override func setUp() { + super.setUp() + } + + override func tearDown() { + subject = nil + + super.tearDown() + } + + func test__renderOperationVariableProperty_givenDefaultValue_generatesCorrectParameterNoInitializerDefault() throws { + // given + subject = .mock("variable", type: .scalar(.string()), defaultValue: .string("Value")) + + let expected = "public var variable: GraphQLNullable" + + // when + let actual = OperationDefinitionTemplate.Variables.Properties([subject]).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter_includeDefaultTrue__givenAllInputFieldTypes_nilDefaultValues__generatesCorrectParametersWithoutInitializer() throws { + // given + let tests: [(variable: CompilationResult.VariableDefinition, expected: String)] = [ + ( + .mock( + "stringField", + type: .scalar(.string()), + defaultValue: nil + ), + "stringField: GraphQLNullable" + ), + ( + .mock( + "intField", + type: .scalar(.integer()), + defaultValue: nil + ), + "intField: GraphQLNullable" + ), + ( + .mock( + "boolField", + type: .scalar(.boolean()), + defaultValue: nil + ), + "boolField: GraphQLNullable" + ), + ( + .mock( + "floatField", + type: .scalar(.float()), + defaultValue: nil + ), + "floatField: GraphQLNullable" + ), + ( + .mock( + "enumField", + type: .enum(.mock(name: "EnumValue")), + defaultValue: nil + ), + "enumField: GraphQLNullable>" + ), + ( + .mock( + "inputField", + type: .inputObject(.mock( + "InnerInputObject", + fields: [ + GraphQLInputField.mock("innerStringField", type: .scalar(.string()), defaultValue: nil) + ] + )), + defaultValue: nil + ), + "inputField: GraphQLNullable" + ), + ( + .mock( + "listField", + type: .list(.scalar(.string())), + defaultValue: nil + ), + "listField: GraphQLNullable<[String?]>" + ) + ] + + for test in tests { + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(test.variable).description + + // then + expect(actual).to(equal(test.expected)) + } + } + + func test__renderOperationVariableParameter__givenAllInputFieldTypes_withDefaultValues__generatesCorrectParametersWithInitializer() throws { + // given + let tests: [(variable: CompilationResult.VariableDefinition, expected: String)] = [ + ( + .mock( + "stringField", + type: .scalar(.string()), + defaultValue: .string("Value") + ), + "stringField: GraphQLNullable = \"Value\"" + ), + ( + .mock( + "stringFieldNullDefaultValue", + type: .scalar(.string()), + defaultValue: .null + ), + "stringFieldNullDefaultValue: GraphQLNullable = .null" + ), + ( + .mock( + "intField", + type: .scalar(.integer()), + defaultValue: .int(300) + ), + "intField: GraphQLNullable = 300" + ), + ( + .mock( + "boolField", + type: .scalar(.boolean()), + defaultValue: .boolean(true) + ), + "boolField: GraphQLNullable = true" + ), + ( + .mock( + "boolField", + type: .scalar(.boolean()), + defaultValue: .boolean(false) + ), + "boolField: GraphQLNullable = false" + ), + ( + .mock( + "floatField", + type: .scalar(.float()), + defaultValue: .float(12.3943) + ), + "floatField: GraphQLNullable = 12.3943" + ), + ( + .mock( + "enumField", + type: .enum(.mock(name: "EnumValue")), + defaultValue: .enum("CaseONE") + ), + "enumField: GraphQLNullable> = .init(.CaseONE)" + ), + ( + .mock( + "enumField", + type: .nonNull(.enum(.mock(name: "EnumValue"))), + defaultValue: .enum("CaseONE") + ), + "enumField: GraphQLEnum = .init(.CaseONE)" + ), + ( + .mock( + "listField", + type: .list(.scalar(.string())), + defaultValue: .list([.string("1"), .string("2")]) + ), + """ + listField: GraphQLNullable<[String?]> = ["1", "2"] + """ + ), + ( + .mock( + "inputField", + type: .inputObject(.mock( + "InnerInputObject", + fields: [ + .mock("innerStringField", type: .scalar(.string()), defaultValue: nil) + ] + )), + defaultValue: .object(["innerStringField": .string("Value")]) + ), + """ + inputField: GraphQLNullable = .init( + InnerInputObject(innerStringField: "Value") + ) + """ + ), + ] + + for test in tests { + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(test.variable).description + + // then + expect(actual).to(equal(test.expected)) + } + } + + func test__renderOperationVariableParameter_includeDefaultTrue__givenNullable_nestedInputObject_withDefaultValues__generatesCorrectParametersWithInitializer() throws { + // given + subject = .mock( + "inputField", + type: .inputObject(.mock( + "InputObject", + fields: [ + .mock("innerStringField", type: .scalar(.string()), defaultValue: nil), + .mock("innerIntField", type: .scalar(.integer()), defaultValue: nil), + .mock("innerFloatField", type: .scalar(.float()), defaultValue: nil), + .mock("innerBoolField", type: .scalar(.boolean()), defaultValue: nil), + .mock("innerListField", type: .list(.scalar(.string())), defaultValue: nil), + .mock("innerEnumField", type: .enum(.mock(name: "EnumValue")), defaultValue: nil), + .mock("innerInputObject", + type: .inputObject(.mock( + "InnerInputObject", + fields: [ + .mock("innerStringField", type: .scalar(.string()), defaultValue: nil), + .mock("innerListField", type: .list(.enum(.mock(name: "EnumList"))), defaultValue: nil), + .mock("innerIntField", type: .scalar(.integer()), defaultValue: nil), + .mock("innerEnumField", type: .enum(.mock(name: "EnumValue")), defaultValue: nil), + ] + )), + defaultValue: nil + ) + ] + )), + defaultValue: .object([ + "innerStringField": .string("ABCD"), + "innerIntField": .int(123), + "innerFloatField": .float(12.3456), + "innerBoolField": .boolean(true), + "innerListField": .list([.string("A"), .string("B")]), + "innerEnumField": .enum("CaseONE"), + "innerInputObject": .object([ + "innerStringField": .string("EFGH"), + "innerListField": .list([.enum("CaseTwo"), .enum("CaseThree")]), + ]) + ]) + ) + + let expected = """ + inputField: GraphQLNullable = .init( + InputObject( + innerStringField: "ABCD", + innerIntField: 123, + innerFloatField: 12.3456, + innerBoolField: true, + innerListField: ["A", "B"], + innerEnumField: .init(.CaseONE), + innerInputObject: .init( + InnerInputObject( + innerStringField: "EFGH", + innerListField: [.init(.CaseTwo), .init(.CaseThree)] + ) + ) + ) + ) + """ + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equalLineByLine(expected)) + } + + func test__renderOperationVariableParameter_includeDefaultTrue__givenNotNullable_nestedInputObject_withDefaultValues__generatesCorrectParametersWithInitializer() throws { + // given + subject = .mock( + "inputField", + type: .nonNull(.inputObject(.mock( + "InputObject", + fields: [ + .mock("innerStringField", type: .scalar(.string()), defaultValue: nil), + .mock("innerIntField", type: .scalar(.integer()), defaultValue: nil), + .mock("innerFloatField", type: .scalar(.float()), defaultValue: nil), + .mock("innerBoolField", type: .scalar(.boolean()), defaultValue: nil), + .mock("innerListField", type: .list(.scalar(.string())), defaultValue: nil), + .mock("innerEnumField", type: .enum(.mock(name: "EnumValue")), defaultValue: nil), + .mock("innerInputObject", + type: .nonNull(.inputObject(.mock( + "InnerInputObject", + fields: [ + .mock("innerStringField", type: .scalar(.string()), defaultValue: nil), + .mock("innerListField", type: .list(.enum(.mock(name: "EnumList"))), defaultValue: nil), + .mock("innerIntField", type: .scalar(.integer()), defaultValue: nil), + .mock("innerEnumField", type: .enum(.mock(name: "EnumValue")), defaultValue: nil), + ] + ))), + defaultValue: nil + ) + ] + ))), + defaultValue: .object([ + "innerStringField": .string("ABCD"), + "innerIntField": .int(123), + "innerFloatField": .float(12.3456), + "innerBoolField": .boolean(true), + "innerListField": .list([.string("A"), .string("B")]), + "innerEnumField": .enum("CaseONE"), + "innerInputObject": .object([ + "innerStringField": .string("EFGH"), + "innerListField": .list([.enum("CaseTwo"), .enum("CaseThree")]), + ]) + ]) + ) + + let expected = """ + inputField: InputObject = InputObject( + innerStringField: "ABCD", + innerIntField: 123, + innerFloatField: 12.3456, + innerBoolField: true, + innerListField: ["A", "B"], + innerEnumField: .init(.CaseONE), + innerInputObject: InnerInputObject( + innerStringField: "EFGH", + innerListField: [.init(.CaseTwo), .init(.CaseThree)] + ) + ) + """ + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equalLineByLine(expected)) + } + + // MARK: Nullable Field Tests + + func test__renderOperationVariableParameter__given_NullableField_NoDefault__generates_NullableParameter_Initializer() throws { + // given + subject = .mock("nullable", type: .scalar(.integer()), defaultValue: nil) + + let expected = "nullable: GraphQLNullable" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NullableField_WithDefault__generates_NullableParameter_NoInitializerDefault() throws { + // given + subject = .mock("nullableWithDefault", type: .scalar(.integer()), defaultValue: .int(3)) + + let expected = "nullableWithDefault: GraphQLNullable = 3" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NonNullableField_NoDefault__generates_NonNullableNonOptionalParameter_NoInitializerDefault() throws { + // given + subject = .mock("nonNullable", type: .nonNull(.scalar(.integer())), defaultValue: nil) + + let expected = "nonNullable: Int" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NonNullableField_WithDefault__generates_NonNullableNonOptionalParameter_WithInitializerDefault() throws { + // given + subject = .mock("nonNullableWithDefault", type: .nonNull(.scalar(.integer())), defaultValue: .int(3)) + + let expected = "nonNullableWithDefault: Int = 3" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NullableList_NullableItem_NoDefault__generates_NullableParameter_OptionalItem_NoInitializerDefault() throws { + // given + subject = .mock("nullableListNullableItem", type: .list(.scalar(.string())), defaultValue: nil) + + let expected = "nullableListNullableItem: GraphQLNullable<[String?]>" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NullableList_NullableItem_WithDefault__generates_NullableParameter_OptionalItem_WithInitializerDefault() throws { + // given + subject = .mock("nullableListNullableItemWithDefault", + type: .list(.scalar(.string())), + defaultValue: .list([.string("val")])) + + let expected = "nullableListNullableItemWithDefault: GraphQLNullable<[String?]> = [\"val\"]" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NullableList_NullableItem_WithDefault_includingNullElement_generates_NullableParameter_OptionalItem_WithInitializerDefault() throws { + // given + subject = .mock("nullableListNullableItemWithDefault", + type: .list(.scalar(.string())), + defaultValue: .list([.string("val"), .null])) + + let expected = "nullableListNullableItemWithDefault: GraphQLNullable<[String?]> = [\"val\", nil]" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NullableList_NonNullableItem_NoDefault__generates_NullableParameter_NonOptionalItem_NoInitializerDefault() throws { + // given + subject = .mock("nullableListNonNullableItem", + type: .list(.nonNull(.scalar(.string()))), + defaultValue: nil) + + let expected = "nullableListNonNullableItem: GraphQLNullable<[String]>" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NullableList_NonNullableItem_WithDefault__generates_NullableParameter_NonOptionalItem_WithInitializerDefault() throws { + // given + subject = .mock("nullableListNonNullableItemWithDefault", type: .list(.nonNull(.scalar(.string()))), defaultValue: .list([.string("val")])) + + let expected = "nullableListNonNullableItemWithDefault: GraphQLNullable<[String]> = [\"val\"]" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NonNullableList_NullableItem_NoDefault__generates_NonNullableNonOptionalParameter_OptionalItem_NoInitializerDefault() throws { + // given + subject = .mock("nonNullableListNullableItem", type: .nonNull(.list(.scalar(.string()))), defaultValue: nil) + + let expected = "nonNullableListNullableItem: [String?]" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NonNullableList_NullableItem_WithDefault__generates_OptionalParameter_OptionalItem_WithInitializerDefault() throws { + // given + subject = .mock("nonNullableListNullableItemWithDefault", + type: .nonNull(.list(.scalar(.string()))), + defaultValue: .list([.string("val")])) + + let expected = "nonNullableListNullableItemWithDefault: [String?] = [\"val\"]" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NonNullableList_NonNullableItem_NoDefault__generates_NonNullableNonOptionalParameter_NonOptionalItem_NoInitializerDefault() throws { + // given + subject = .mock("nonNullableListNonNullableItem", + type: .nonNull(.list(.nonNull(.scalar(.string())))), + defaultValue: nil) + + let expected = "nonNullableListNonNullableItem: [String]" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NonNullableList_NonNullableItem_WithDefault__generates_OptionalParameter_NonOptionalItem_WithInitializerDefault() throws { + // given + subject = .mock("nonNullableListNonNullableItemWithDefault", + type: .nonNull(.list(.nonNull(.scalar(.string())))), + defaultValue: .list([.string("val")])) + + let expected = "nonNullableListNonNullableItemWithDefault: [String] = [\"val\"]" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + + func test__renderOperationVariableParameter__given_NullableListOfNullableEnum_NoDefault__generates_NullableParameter_OptionalItem_NoInitializerNilDefault() throws { + // given + subject = .mock("nullableListNullableItem", + type: .list(.enum(.mock(name: "EnumValue"))), + defaultValue: nil) + + let expected = "nullableListNullableItem: GraphQLNullable<[GraphQLEnum?]>" + + // when + let actual = OperationDefinitionTemplate.Variables.Parameter(subject).description + + // then + expect(actual).to(equal(expected)) + } + +} diff --git a/Tests/ApolloCodegenTests/CodeGeneration/Templates/SelectionSet/SelectionSetTemplateTests.swift b/Tests/ApolloCodegenTests/CodeGeneration/Templates/SelectionSet/SelectionSetTemplateTests.swift index 64d3c262b8..7ba4810f3e 100644 --- a/Tests/ApolloCodegenTests/CodeGeneration/Templates/SelectionSet/SelectionSetTemplateTests.swift +++ b/Tests/ApolloCodegenTests/CodeGeneration/Templates/SelectionSet/SelectionSetTemplateTests.swift @@ -464,6 +464,202 @@ class SelectionSetTemplateTests: XCTestCase { expect(actual).to(equalLineByLine(expected, atLine: 7, ignoringExtraLines: true)) } + // MARK: Selections - Fields - Arguments + + func test__render_selections__givenFieldWithArgumentWithConstantValue_rendersFieldSelections() throws { + // given + schemaSDL = """ + type Query { + allAnimals: [Animal!] + } + + type Animal { + string(variable: Int): String! + } + """ + + document = """ + query TestOperation { + allAnimals { + aliased: string(variable: 3) + } + } + """ + + let expected = """ + public static var selections: [Selection] { [ + .field("string", alias: "aliased", String.self, arguments: ["variable": 3]), + ] } + """ + + // when + try buildSubjectAndOperation() + let allAnimals = try XCTUnwrap( + operation[field: "query"]?[field: "allAnimals"] as? IR.EntityField + ) + + let actual = subject.render(field: allAnimals) + + // then + expect(actual).to(equalLineByLine(expected, atLine: 7, ignoringExtraLines: true)) + } + + func test__render_selections__givenFieldWithArgumentWithNullConstantValue_rendersFieldSelections() throws { + // given + schemaSDL = """ + type Query { + allAnimals: [Animal!] + } + + type Animal { + string(variable: Int): String! + } + """ + + document = """ + query TestOperation { + allAnimals { + aliased: string(variable: null) + } + } + """ + + let expected = """ + public static var selections: [Selection] { [ + .field("string", alias: "aliased", String.self, arguments: ["variable": .null]), + ] } + """ + + // when + try buildSubjectAndOperation() + let allAnimals = try XCTUnwrap( + operation[field: "query"]?[field: "allAnimals"] as? IR.EntityField + ) + + let actual = subject.render(field: allAnimals) + + // then + expect(actual).to(equalLineByLine(expected, atLine: 7, ignoringExtraLines: true)) + } + + func test__render_selections__givenFieldWithArgumentWithVariableValue_rendersFieldSelections() throws { + // given + schemaSDL = """ + type Query { + allAnimals: [Animal!] + } + + type Animal { + string(variable: Int): String! + } + """ + + document = """ + query TestOperation($var: Int) { + allAnimals { + aliased: string(variable: $var) + } + } + """ + + let expected = """ + public static var selections: [Selection] { [ + .field("string", alias: "aliased", String.self, arguments: ["variable": .variable("var")]), + ] } + """ + + // when + try buildSubjectAndOperation() + let allAnimals = try XCTUnwrap( + operation[field: "query"]?[field: "allAnimals"] as? IR.EntityField + ) + + let actual = subject.render(field: allAnimals) + + // then + expect(actual).to(equalLineByLine(expected, atLine: 7, ignoringExtraLines: true)) + } + + func test__render_selections__givenFieldWithArgumentOfInputObjectTypeWithNullableFields_withConstantValues_rendersFieldSelections() throws { + // given + schemaSDL = """ + type Query { + allAnimals: [Animal!] + } + + type Animal { + string(input: TestInput): String! + } + + input TestInput { + string: String + int: Int + float: Float + bool: Boolean + list: [String] + enum: TestEnum + innerInput: InnerInput + } + + input InnerInput { + string: String + enumList: [TestEnum] + } + + enum TestEnum { + CaseOne + CaseTwo + } + """ + + document = """ + query TestOperation { + allAnimals { + aliased: string(input: { + string: "ABCD", + int: 3, + float: 123.456, + bool: true, + list: ["A", "B"], + enum: CaseOne, + innerInput: { + string: "EFGH", + enumList: [CaseOne, CaseTwo] + } + }) + } + } + """ + + let expected = """ + public static var selections: [Selection] { [ + .field("string", alias: "aliased", String.self, arguments: ["input": [ + "string": "ABCD", + "int": 3, + "float": 123.456, + "bool": true, + "list": ["A", "B"], + "enum": "CaseOne", + "innerInput": [ + "string": "EFGH", + "enumList": ["CaseOne", "CaseTwo"] + ] + ]]), + ] } + """ + + // when + try buildSubjectAndOperation() + let allAnimals = try XCTUnwrap( + operation[field: "query"]?[field: "allAnimals"] as? IR.EntityField + ) + + let actual = subject.render(field: allAnimals) + + // then + expect(actual).to(equalLineByLine(expected, atLine: 7, ignoringExtraLines: true)) + } + // MARK: Selections - Type Cases func test__render_selections__givenTypeCases_rendersTypeCaseSelections() throws {