Repository: Netflix/dgs-examples-java Branch: main Commit: ad5547b99a7a Files: 50 Total size: 416.3 KB Directory structure: gitextract_wtbsn2rz/ ├── .github/ │ ├── dependabot.yml │ └── workflows/ │ └── gradle.yml ├── .gitignore ├── .sdkmanrc ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── build.gradle.kts ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts ├── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── example/ │ │ │ └── demo/ │ │ │ ├── DemoApplication.java │ │ │ ├── config/ │ │ │ │ ├── MetricsConfig.java │ │ │ │ └── SecurityConfig.java │ │ │ ├── datafetchers/ │ │ │ │ ├── ArtworkUploadDataFetcher.java │ │ │ │ ├── ReviewsDataFetcher.java │ │ │ │ ├── SecurityExampleFetchers.java │ │ │ │ └── ShowsDataFetcher.java │ │ │ ├── dataloaders/ │ │ │ │ ├── ReviewsDataLoader.java │ │ │ │ └── ReviewsDataLoaderWithContext.java │ │ │ ├── directives/ │ │ │ │ └── UppercaseDirective.java │ │ │ ├── instrumentation/ │ │ │ │ └── ExampleTracingInstrumentation.java │ │ │ ├── scalars/ │ │ │ │ └── DateTimeScalar.java │ │ │ └── services/ │ │ │ ├── DefaultReviewsService.java │ │ │ ├── ReviewsService.java │ │ │ ├── ShowsService.java │ │ │ └── ShowsServiceImpl.java │ │ └── resources/ │ │ ├── application.yml │ │ ├── schema/ │ │ │ └── schema.graphqls │ │ └── static/ │ │ ├── asset-manifest.json │ │ ├── index.html │ │ ├── precache-manifest.2241ce5fa2602c9cdc3eb026c3eb8589.js │ │ ├── service-worker.js │ │ └── static/ │ │ └── js/ │ │ ├── 2.ae627b82.chunk.js │ │ ├── 2.ae627b82.chunk.js.LICENSE.txt │ │ ├── main.05accb10.chunk.js │ │ └── runtime-main.09b85ec0.js │ └── test/ │ └── java/ │ └── com/ │ └── example/ │ └── demo/ │ ├── ArtworkUploadDataFetcherTest.java │ ├── ReviewSubscriptionIntegrationTest.java │ ├── ReviewSubscriptionTest.java │ ├── SecurityExampleFetchersTest.java │ └── ShowsDataFetcherTest.java └── ui-example/ ├── package.json ├── public/ │ └── index.html ├── src/ │ ├── index.tsx │ └── react-app-env.d.ts └── tsconfig.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/dependabot.yml ================================================ version: 2 updates: - package-ecosystem: "gradle" directory: "/" schedule: interval: "daily" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "daily" ================================================ FILE: .github/workflows/gradle.yml ================================================ # This workflow will build a Java project with Gradle # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle name: Java CI with Gradle on: push: branches: [ main ] pull_request: branches: [ main ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.1 - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 17 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle run: ./gradlew build ================================================ FILE: .gitignore ================================================ HELP.md .gradle build/ !gradle/wrapper/gradle-wrapper.jar !**/src/main/**/build/ !**/src/test/**/build/ ### STS ### .apt_generated .classpath .factorypath .project .settings .springBeans .sts4-cache bin/ !**/src/main/**/bin/ !**/src/test/**/bin/ ### IntelliJ IDEA ### .idea *.iws *.iml *.ipr out/ !**/src/main/**/out/ !**/src/test/**/out/ ### NetBeans ### /nbproject/private/ /nbbuild/ /dist/ /nbdist/ /.nb-gradle/ ### VS Code ### .vscode/ uploaded-images .DS_Store ================================================ FILE: .sdkmanrc ================================================ # Enable auto-env through the sdkman_auto_env config # Add key=value pairs of SDKs to use below java=17.0.3-zulu ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: Makefile ================================================ .PHONY: help run check .DEFAULT_GOAL := help SHELL = /bin/sh ## Gradle GW = ./gradlew GFLAGS ?= GW_CMD = $(GW) $(GFLAGS) run: ## Runs the service, with the local profile enabled $(GW_CMD) $(GW_OPT) bootRun --args='--spring.profiles.active=local' check: ## Runs gradlew check $(GW_CMD) $(GW_OPT) check help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' ================================================ FILE: NOTICE ================================================ ================================================ FILE: README.md ================================================ Java DGS Framework example ===== This repository is an example application for the [DGS Framework](https://netflix.github.io/dgs). The example is a standalone GraphQL server in Java. It shows the following features: * [Datafetchers](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/datafetchers/ShowsDatafetcher.java#L26) * [Mutations](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/datafetchers/ReviewsDataFetcher.java#L50) * [DataLoader to prevent the N+1 problem](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/datafetchers/ReviewsDataFetcher.java#L40) * [Query testing](https://github.com/Netflix/dgs-examples-java/blob/main/src/test/java/com/example/demo/ShowsDatafetcherTest.java#L61) * [Using a generated Query API](https://github.com/Netflix/dgs-examples-java/blob/main/src/test/java/com/example/demo/ShowsDatafetcherTest.java#L89) * [File Upload](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/datafetchers/ArtworkUploadDataFetcher.java#L22) * [Using the Gradle codegen plugin](https://github.com/Netflix/dgs-examples-java/blob/main/build.gradle.kts#L45) * [A custom instrumentation implementation](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/instrumentation/ExampleTracingInstrumentation.java#L20) * [Subscriptions](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/datafetchers/ReviewsDataFetcher.java#L60) * [Testing a subscription](https://github.com/Netflix/dgs-examples-java/blob/main/src/test/java/com/example/demo/ReviewSubscriptionTest.java#L46) * [Registering an optional scalar from graphql-java](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/scalars/DateTimeScalar.java#L16) Other examples --- There are other examples of using the DGS framework as well: * [Kotlin implementation of this example](https://github.com/Netflix/dgs-examples-kotlin) * [Federation examples (with Apollo Gateway)](https://github.com/Netflix/dgs-federation-example) Shows and Reviews ---- This example is built around two main types: [Show](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/resources/schema/schema.graphqls#L14) and [Review](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/resources/schema/schema.graphqls#L22). A `Show` represents a series or movie you would find on Netflix. For ease of running the demo, the list of shows is hardcoded in [ShowsServiceImpl](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/services/ShowsServiceImpl.java). A show can have `Reviews`. Again, for ease of running the demo, a list of reviews is generated during startup for each show in [DefaultReviewsService](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/services/DefaultReviewsService.java). Reviews can also be added by users of the API using a [mutation](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/resources/schema/schema.graphqls#L6), and a [GraphQL Subscription](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/resources/schema/schema.graphqls#L11) is available to watch for added reviews. There's also a mutation available to add [Artwork](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/resources/schema/schema.graphqls#L7) for a show, demonstrating file uploads. Uploaded files are stored in a folder `uploaded-images` in the work directory where ethe application is started. Starting the example ---- The example requires Java 11. Run the application in an IDE using its [main class](https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/DemoApplication.java) or using Gradle: ``` ./gradlew bootRun ``` Interact with the application using GraphiQL on http://localhost:8080/graphiql. ================================================ FILE: build.gradle.kts ================================================ /* * Copyright 2021 Netflix, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.gradle.api.tasks.testing.logging.TestExceptionFormat.* import org.gradle.api.tasks.testing.logging.TestLogEvent.* plugins { id("java") id("org.springframework.boot") version "3.3.0" id("io.spring.dependency-management") version "1.1.4" id("com.netflix.dgs.codegen") version "6.1.4" } apply(plugin = "com.netflix.dgs.codegen") group = "com.example" version = "0.0.1-SNAPSHOT" repositories { mavenCentral() // ---- // Before we release the DGS Framework our CI Pipeline tests this project against the current snapshot. // To support that we need to have `mavenLocal` support. mavenLocal() // ---- maven {url = uri("https://repo.spring.io/milestone/")} } dependencyManagement { imports { mavenBom("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.5.6") } } java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } } repositories { mavenLocal() } // Set Kotlin version to 1.9.20 to avoid the issue described here: // https://youtrack.jetbrains.com/issue/KT-58021 // TODO: after updating to Spring Boot 3.2.x, this workaround can be removed extra["kotlin.version"] = "1.9.20" dependencies { implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:8.5.6")) implementation("com.netflix.graphql.dgs:graphql-dgs-spring-graphql-starter") implementation("com.netflix.graphql.dgs:graphql-dgs-extended-scalars") implementation("org.springframework.boot:spring-boot-starter-websocket") implementation("name.nkonev.multipart-spring-graphql:multipart-spring-graphql:1.+") implementation("org.springframework.boot:spring-boot-starter-web") implementation("net.datafaker:datafaker:2.+") implementation("com.github.ben-manes.caffeine:caffeine") implementation("org.springframework.boot:spring-boot-starter-security") implementation("com.netflix.graphql.dgs:graphql-dgs-spring-boot-micrometer") implementation("org.springframework.boot:spring-boot-starter-actuator") testImplementation("org.springframework.boot:spring-boot-starter-test") implementation("com.netflix.graphql.dgs:graphql-dgs-spring-graphql-starter-test") testImplementation("com.netflix.graphql.dgs:graphql-dgs-client") testImplementation("org.springframework.boot:spring-boot-starter-webflux") testImplementation("io.projectreactor:reactor-test") testImplementation("org.springframework.security:spring-security-test") } tasks.withType { generateClientv2 = true packageName = "com.example.demo.generated" } tasks.withType { useJUnitPlatform() testLogging { events(FAILED, STANDARD_ERROR, SKIPPED) exceptionFormat = FULL showExceptions = true showCauses = true showStackTraces = true } } ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists ================================================ FILE: gradlew ================================================ #!/usr/bin/env sh # # Copyright 2015 the original author or authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn () { echo "$*" } die () { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin or MSYS, switch paths to Windows format before running java if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=`expr $i + 1` done case $i in 0) set -- ;; 1) set -- "$args0" ;; 2) set -- "$args0" "$args1" ;; 3) set -- "$args0" "$args1" "$args2" ;; 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" exec "$JAVACMD" "$@" ================================================ FILE: gradlew.bat ================================================ @rem @rem Copyright 2015 the original author or authors. @rem @rem Licensed under the Apache License, Version 2.0 (the "License"); @rem you may not use this file except in compliance with the License. @rem You may obtain a copy of the License at @rem @rem https://www.apache.org/licenses/LICENSE-2.0 @rem @rem Unless required by applicable law or agreed to in writing, software @rem distributed under the License is distributed on an "AS IS" BASIS, @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Resolve any "." and ".." in APP_HOME to make it shorter. for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: settings.gradle.kts ================================================ /* * Copyright 2021 Netflix, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ rootProject.name = "dgs-examples-java" ================================================ FILE: src/main/java/com/example/demo/DemoApplication.java ================================================ package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } /** * Below is an example of using a PreparsedDocumentProvider. * Uncomment to enable */ // @Configuration // static class PreparsedDocumentProviderConfig { // // private final Cache cache = Caffeine.newBuilder().maximumSize(250) // .expireAfterAccess(5, TimeUnit.MINUTES).recordStats().build(); // // // @Bean // public PreparsedDocumentProvider preparsedDocumentProvider() { // return (executionInput, parseAndValidateFunction) -> { // Function mapCompute = key -> parseAndValidateFunction.apply(executionInput); // return cache.get(executionInput.getQuery(), mapCompute); // }; // } // } } ================================================ FILE: src/main/java/com/example/demo/config/MetricsConfig.java ================================================ package com.example.demo.config; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import io.micrometer.core.instrument.logging.LoggingMeterRegistry; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; @Configuration public class MetricsConfig { @Bean public MeterRegistry loggingMeterRegistry() { return new LoggingMeterRegistry(); } } ================================================ FILE: src/main/java/com/example/demo/config/SecurityConfig.java ================================================ package com.example.demo.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.web.DefaultSecurityFilterChain; import static org.springframework.security.config.Customizer.withDefaults; @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) public class SecurityConfig { @Bean DefaultSecurityFilterChain springWebFilterChain(HttpSecurity http) throws Exception { return http .csrf(AbstractHttpConfigurer::disable) .authorizeRequests(requests -> requests .anyRequest().permitAll() ) .httpBasic(withDefaults()) .build(); } @Bean public static InMemoryUserDetailsManager userDetailsService() { User.UserBuilder userBuilder = User.withDefaultPasswordEncoder(); UserDetails user = userBuilder.username("user").password("user").roles("USER").build(); UserDetails admin = userBuilder.username("admin").password("admin").roles("USER", "ADMIN").build(); return new InMemoryUserDetailsManager(user, admin); } } ================================================ FILE: src/main/java/com/example/demo/datafetchers/ArtworkUploadDataFetcher.java ================================================ package com.example.demo.datafetchers; import com.example.demo.generated.types.Image; import com.netflix.graphql.dgs.DgsComponent; import com.netflix.graphql.dgs.DgsMutation; import com.netflix.graphql.dgs.InputArgument; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; @DgsComponent public class ArtworkUploadDataFetcher { @DgsMutation public List addArtwork(@InputArgument Integer showId, @InputArgument MultipartFile upload) throws IOException { Path uploadDir = Paths.get("uploaded-images"); if (!Files.exists(uploadDir)) { Files.createDirectories(uploadDir); } Path newFile = uploadDir.resolve("show-" + showId + "-" + UUID.randomUUID() + upload.getOriginalFilename().substring(upload.getOriginalFilename().lastIndexOf("."))); try (OutputStream outputStream = Files.newOutputStream(newFile)) { outputStream.write(upload.getBytes()); } return Files.list(uploadDir) .filter(f -> f.getFileName().toString().startsWith("show-" + showId)) .map(f -> f.getFileName().toString()) .map(fileName -> Image.newBuilder().url(fileName).build()).collect(Collectors.toList()); } } ================================================ FILE: src/main/java/com/example/demo/datafetchers/ReviewsDataFetcher.java ================================================ package com.example.demo.datafetchers; import com.example.demo.dataloaders.ReviewsDataLoader; import com.example.demo.dataloaders.ReviewsDataLoaderWithContext; import com.example.demo.generated.DgsConstants; import com.example.demo.generated.types.Review; import com.example.demo.generated.types.Show; import com.example.demo.generated.types.SubmittedReview; import com.example.demo.services.DefaultReviewsService; import com.netflix.graphql.dgs.*; import org.dataloader.BatchLoaderEnvironment; import org.dataloader.DataLoader; import org.reactivestreams.Publisher; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @DgsComponent public class ReviewsDataFetcher { private final DefaultReviewsService reviewsService; public ReviewsDataFetcher(DefaultReviewsService reviewsService) { this.reviewsService = reviewsService; } /** * This datafetcher will be called to resolve the "reviews" field on a Show. * It's invoked for each individual Show, so if we would load 10 shows, this method gets called 10 times. * To avoid the N+1 problem this datafetcher uses a DataLoader. * Although the DataLoader is called for each individual show ID, it will batch up the actual loading to a single method call to the "load" method in the ReviewsDataLoader. * For this to work correctly, the datafetcher needs to return a CompletableFuture. */ @DgsData(parentType = DgsConstants.SHOW.TYPE_NAME, field = DgsConstants.SHOW.Reviews) public CompletableFuture> reviews(DgsDataFetchingEnvironment dfe) { //Instead of loading a DataLoader by name, we can use the DgsDataFetchingEnvironment and pass in the DataLoader classname. DataLoader> reviewsDataLoader = dfe.getDataLoader(ReviewsDataLoaderWithContext.class); //Because the reviews field is on Show, the getSource() method will return the Show instance. Show show = dfe.getSource(); //Load the reviews from the DataLoader. This call is async and will be batched by the DataLoader mechanism. return reviewsDataLoader.load(show.getId()); } @DgsMutation public List addReview(@InputArgument SubmittedReview review) { reviewsService.saveReview(review); List reviews = reviewsService.reviewsForShow(review.getShowId()); return Optional.ofNullable(reviews).orElse(Collections.emptyList()); } @DgsMutation public List addReviews(@InputArgument(value = "reviews", collectionType = SubmittedReview.class) List reviewsInput) { reviewsService.saveReviews(reviewsInput); List showIds = reviewsInput.stream().map(SubmittedReview::getShowId).collect(Collectors.toList()); Map> reviews = reviewsService.reviewsForShows(showIds); return reviews.values().stream().flatMap(List::stream).collect(Collectors.toList()); } @DgsSubscription public Publisher reviewAdded(@InputArgument Integer showId) { return reviewsService.getReviewsPublisher(); } } ================================================ FILE: src/main/java/com/example/demo/datafetchers/SecurityExampleFetchers.java ================================================ package com.example.demo.datafetchers; import com.netflix.graphql.dgs.DgsComponent; import com.netflix.graphql.dgs.DgsQuery; import org.springframework.security.access.annotation.Secured; @DgsComponent public class SecurityExampleFetchers { @DgsQuery public String secureNone() { return "Hello to everyone"; } @DgsQuery @Secured({"ROLE_USER", "ROLE_ADMIN"}) public String secureUser() { return "Hello to users or admins"; } @DgsQuery @Secured({"ROLE_ADMIN"}) public String secureAdmin() { return "Hello to admins only"; } } ================================================ FILE: src/main/java/com/example/demo/datafetchers/ShowsDataFetcher.java ================================================ package com.example.demo.datafetchers; import com.example.demo.generated.types.Show; import com.example.demo.services.ShowsService; import com.netflix.graphql.dgs.DgsComponent; import com.netflix.graphql.dgs.DgsQuery; import com.netflix.graphql.dgs.InputArgument; import java.util.List; import java.util.stream.Collectors; @DgsComponent public class ShowsDataFetcher { private final ShowsService showsService; public ShowsDataFetcher(ShowsService showsService) { this.showsService = showsService; } /** * This dataFetcher resolves the shows field on Query. * It uses an @InputArgument to get the titleFilter from the Query if one is defined. */ @DgsQuery public List shows(@InputArgument("titleFilter") String titleFilter) { if (titleFilter == null) { return showsService.shows(); } return showsService.shows().stream().filter(s -> s.getTitle().contains(titleFilter)).collect(Collectors.toList()); } } ================================================ FILE: src/main/java/com/example/demo/dataloaders/ReviewsDataLoader.java ================================================ package com.example.demo.dataloaders; import com.example.demo.generated.types.Review; import com.example.demo.services.DefaultReviewsService; import com.netflix.graphql.dgs.DgsDataLoader; import org.dataloader.MappedBatchLoader; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; @DgsDataLoader(name = "reviews") public class ReviewsDataLoader implements MappedBatchLoader> { private final DefaultReviewsService reviewsService; public ReviewsDataLoader(DefaultReviewsService reviewsService) { this.reviewsService = reviewsService; } /** * This method will be called once, even if multiple datafetchers use the load() method on the DataLoader. * This way reviews can be loaded for all the Shows in a single call instead of per individual Show. */ @Override public CompletionStage>> load(Set keys) { return CompletableFuture.supplyAsync(() -> reviewsService.reviewsForShows(new ArrayList<>(keys))); } } ================================================ FILE: src/main/java/com/example/demo/dataloaders/ReviewsDataLoaderWithContext.java ================================================ package com.example.demo.dataloaders; import com.example.demo.generated.types.Review; import com.example.demo.services.DefaultReviewsService; import com.netflix.graphql.dgs.DgsDataLoader; import org.dataloader.BatchLoaderEnvironment; import org.dataloader.MappedBatchLoader; import org.dataloader.MappedBatchLoaderWithContext; import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; @DgsDataLoader(name = "reviewsWithContext") public class ReviewsDataLoaderWithContext implements MappedBatchLoaderWithContext> { private final DefaultReviewsService reviewsService; @Autowired public ReviewsDataLoaderWithContext(DefaultReviewsService reviewsService) { this.reviewsService = reviewsService; } @Override public CompletionStage>> load(Set keys, BatchLoaderEnvironment environment) { return CompletableFuture.supplyAsync(() -> reviewsService.reviewsForShows(new ArrayList<>(keys))); } } ================================================ FILE: src/main/java/com/example/demo/directives/UppercaseDirective.java ================================================ package com.example.demo.directives; import com.netflix.graphql.dgs.DgsDirective; import graphql.schema.DataFetcher; import graphql.schema.DataFetcherFactories; import graphql.schema.GraphQLFieldDefinition; import graphql.schema.GraphQLFieldsContainer; import graphql.schema.idl.SchemaDirectiveWiring; import graphql.schema.idl.SchemaDirectiveWiringEnvironment; @DgsDirective(name = "uppercase") public class UppercaseDirective implements SchemaDirectiveWiring { @Override public GraphQLFieldDefinition onField(SchemaDirectiveWiringEnvironment env) { DataFetcher originalDataFetcher = env.getFieldDataFetcher(); DataFetcher dataFetcher = DataFetcherFactories.wrapDataFetcher( originalDataFetcher, (dataFetchingEnvironment, value) -> { if (value instanceof String) { return ((String) value).toUpperCase(); } return value; } ); env.setFieldDataFetcher(dataFetcher); return env.getElement(); } } ================================================ FILE: src/main/java/com/example/demo/instrumentation/ExampleTracingInstrumentation.java ================================================ package com.example.demo.instrumentation; import graphql.ExecutionResult; import graphql.execution.instrumentation.InstrumentationContext; import graphql.execution.instrumentation.InstrumentationState; import graphql.execution.instrumentation.SimpleInstrumentation; import graphql.execution.instrumentation.SimplePerformantInstrumentation; import graphql.execution.instrumentation.parameters.InstrumentationCreateStateParameters; import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters; import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters; import graphql.schema.DataFetcher; import graphql.schema.GraphQLNonNull; import graphql.schema.GraphQLObjectType; import graphql.schema.GraphQLOutputType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; @Component public class ExampleTracingInstrumentation extends SimplePerformantInstrumentation { private final static Logger LOGGER = LoggerFactory.getLogger(ExampleTracingInstrumentation.class); @Override public @Nullable InstrumentationState createState(InstrumentationCreateStateParameters parameters) { return new TracingState(); } @Override public @Nullable InstrumentationContext beginExecution(InstrumentationExecutionParameters parameters, InstrumentationState state) { TracingState tracingState = (TracingState) state; tracingState.startTime = System.currentTimeMillis(); return super.beginExecution(parameters, state); } @Override public @NotNull DataFetcher instrumentDataFetcher(DataFetcher dataFetcher, InstrumentationFieldFetchParameters parameters, InstrumentationState state) { // We only care about user code if(parameters.isTrivialDataFetcher()) { return dataFetcher; } return environment -> { long startTime = System.currentTimeMillis(); Object result = dataFetcher.get(environment); if(result instanceof CompletableFuture) { ((CompletableFuture) result).whenComplete((r, ex) -> { long totalTime = System.currentTimeMillis() - startTime; LOGGER.info("Async datafetcher {} took {}ms", findDatafetcherTag(parameters), totalTime); }); } else { long totalTime = System.currentTimeMillis() - startTime; LOGGER.info("Datafetcher {} took {}ms", findDatafetcherTag(parameters), totalTime); } return result; }; } @Override public @NotNull CompletableFuture instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters, InstrumentationState state) { TracingState tracingState = (TracingState) state; long totalTime = System.currentTimeMillis() - tracingState.startTime; LOGGER.info("Total execution time: {}ms", totalTime); return super.instrumentExecutionResult(executionResult, parameters, state); } private String findDatafetcherTag(InstrumentationFieldFetchParameters parameters) { GraphQLOutputType type = parameters.getExecutionStepInfo().getParent().getType(); GraphQLObjectType parent; if (type instanceof GraphQLNonNull) { parent = (GraphQLObjectType) ((GraphQLNonNull) type).getWrappedType(); } else { parent = (GraphQLObjectType) type; } return parent.getName() + "." + parameters.getExecutionStepInfo().getPath().getSegmentName(); } static class TracingState implements InstrumentationState { long startTime; } } ================================================ FILE: src/main/java/com/example/demo/scalars/DateTimeScalar.java ================================================ package com.example.demo.scalars; import com.netflix.graphql.dgs.DgsComponent; import com.netflix.graphql.dgs.DgsRuntimeWiring; import graphql.scalars.ExtendedScalars; import graphql.schema.idl.RuntimeWiring; /** * graphql-java provides optional scalars in the graphql-java-extended-scalars library. * We can wire a scalar from this library by adding the scalar to the RuntimeWiring. */ @DgsComponent public class DateTimeScalar { @DgsRuntimeWiring public RuntimeWiring.Builder addScalar(RuntimeWiring.Builder builder) { return builder.scalar(ExtendedScalars.DateTime); } } ================================================ FILE: src/main/java/com/example/demo/services/DefaultReviewsService.java ================================================ package com.example.demo.services; import com.example.demo.generated.types.Review; import com.example.demo.generated.types.SubmittedReview; import net.datafaker.Faker; import org.reactivestreams.Publisher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import reactor.core.publisher.ConnectableFlux; import reactor.core.publisher.Flux; import reactor.core.publisher.FluxSink; import jakarta.annotation.PostConstruct; import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.IntStream; /** * This service emulates a data store. * For convenience in the demo we just generate Reviews in memory, but imagine this would be backed by for example a database. * If this was indeed backed by a database, it would be very important to avoid the N+1 problem, which means we need to use a DataLoader to call this class. */ @Service public class DefaultReviewsService implements ReviewsService { private final static Logger logger = LoggerFactory.getLogger(DefaultReviewsService.class); private final ShowsService showsService; private final Map> reviews = new ConcurrentHashMap<>(); private FluxSink reviewsStream; private ConnectableFlux reviewsPublisher; public DefaultReviewsService(ShowsService showsService) { this.showsService = showsService; } @PostConstruct private void createReviews() { Faker faker = new Faker(); //For each show we generate a random set of reviews. showsService.shows().forEach(show -> { List generatedReviews = IntStream.range(0, faker.number().numberBetween(1, 20)).mapToObj(number -> { LocalDateTime date = faker.date().past(300, TimeUnit.DAYS).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); return Review.newBuilder().submittedDate(OffsetDateTime.of(date, ZoneOffset.UTC)).username(faker.name().username()).starScore(faker.number().numberBetween(0, 6)).build(); }).collect(Collectors.toList()); reviews.put(show.getId(), generatedReviews); }); Flux publisher = Flux.create(emitter -> { reviewsStream = emitter; }); reviewsPublisher = publisher.publish(); reviewsPublisher.connect(); } /** * Hopefully nobody calls this for multiple shows within a single query, that would indicate the N+1 problem! */ public List reviewsForShow(Integer showId) { return reviews.get(showId); } /** * This is the method we want to call when loading reviews for multiple shows. * If this code was backed by a relational database, it would select reviews for all requested shows in a single SQL query. */ public Map> reviewsForShows(List showIds) { logger.info("Loading reviews for shows {}", showIds.stream().map(String::valueOf).collect(Collectors.joining(", "))); return reviews .entrySet() .stream() .filter(entry -> showIds.contains(entry.getKey())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } public void saveReview(SubmittedReview reviewInput) { List reviewsForShow = reviews.computeIfAbsent(reviewInput.getShowId(), (key) -> new ArrayList<>()); Review review = Review.newBuilder() .username(reviewInput.getUsername()) .starScore(reviewInput.getStarScore()) .submittedDate(OffsetDateTime.now()).build(); reviewsForShow.add(review); reviewsStream.next(review); logger.info("Review added {}", review); } public void saveReviews(List reviewsInput) { reviewsInput.forEach(reviewInput -> { List reviewsForShow = reviews.computeIfAbsent(reviewInput.getShowId(), (key) -> new ArrayList<>()); Review review = Review.newBuilder() .username(reviewInput.getUsername()) .starScore(reviewInput.getStarScore()) .submittedDate(OffsetDateTime.now()).build(); reviewsForShow.add(review); reviewsStream.next(review); logger.info("Review added {}", review); }); } public Publisher getReviewsPublisher() { return reviewsPublisher; } } ================================================ FILE: src/main/java/com/example/demo/services/ReviewsService.java ================================================ package com.example.demo.services; public interface ReviewsService { } ================================================ FILE: src/main/java/com/example/demo/services/ShowsService.java ================================================ package com.example.demo.services; import com.example.demo.generated.types.Show; import java.util.List; public interface ShowsService { List shows(); } ================================================ FILE: src/main/java/com/example/demo/services/ShowsServiceImpl.java ================================================ package com.example.demo.services; import com.example.demo.generated.types.Show; import org.springframework.stereotype.Service; import java.util.Arrays; import java.util.List; @Service public class ShowsServiceImpl implements ShowsService { @Override public List shows() { return Arrays.asList( Show.newBuilder().id(1).title("Stranger Things").releaseYear(2016).build(), Show.newBuilder().id(2).title("Ozark").releaseYear(2017).build(), Show.newBuilder().id(3).title("The Crown").releaseYear(2016).build(), Show.newBuilder().id(4).title("Dead to Me").releaseYear(2019).build(), Show.newBuilder().id(5).title("Orange is the New Black").releaseYear(2013).build() ); } } ================================================ FILE: src/main/resources/application.yml ================================================ spring: application: name: dgs-example-java graphql: graphiql: enabled: true websocket: path: /graphql --- spring: config: activate: on-profile: local output: ansi: enabled: always logging: level: io.micrometer.core.instrument.logging.*: true ================================================ FILE: src/main/resources/schema/schema.graphqls ================================================ type Query { shows(titleFilter: String): [Show] secureNone: String secureUser: String secureAdmin: String } type Mutation { addReview(review: SubmittedReview): [Review] addReviews(reviews: [SubmittedReview]): [Review] addArtwork(showId: Int!, upload: Upload!): [Image]! @skipcodegen } type Subscription { reviewAdded(showId: Int!): Review } type Show { id: Int title: String @uppercase releaseYear: Int reviews(minScore:Int): [Review] artwork: [Image] } type Review { username: String starScore: Int submittedDate: DateTime } input SubmittedReview { showId: Int! username: String! starScore: Int! } type Image { url: String } scalar DateTime scalar Upload directive @skipcodegen on FIELD_DEFINITION directive @uppercase on FIELD_DEFINITION ================================================ FILE: src/main/resources/static/asset-manifest.json ================================================ { "files": { "main.js": "/static/js/main.05accb10.chunk.js", "main.js.map": "/static/js/main.05accb10.chunk.js.map", "runtime-main.js": "/static/js/runtime-main.09b85ec0.js", "runtime-main.js.map": "/static/js/runtime-main.09b85ec0.js.map", "static/js/2.ae627b82.chunk.js": "/static/js/2.ae627b82.chunk.js", "static/js/2.ae627b82.chunk.js.map": "/static/js/2.ae627b82.chunk.js.map", "index.html": "/index.html", "precache-manifest.2241ce5fa2602c9cdc3eb026c3eb8589.js": "/precache-manifest.2241ce5fa2602c9cdc3eb026c3eb8589.js", "service-worker.js": "/service-worker.js", "static/js/2.ae627b82.chunk.js.LICENSE.txt": "/static/js/2.ae627b82.chunk.js.LICENSE.txt" }, "entrypoints": [ "static/js/runtime-main.09b85ec0.js", "static/js/2.ae627b82.chunk.js", "static/js/main.05accb10.chunk.js" ] } ================================================ FILE: src/main/resources/static/index.html ================================================ Launches
================================================ FILE: src/main/resources/static/precache-manifest.2241ce5fa2602c9cdc3eb026c3eb8589.js ================================================ self.__precacheManifest = (self.__precacheManifest || []).concat([ { "revision": "e16b7b688dacd0dc3ffa733050e8aa20", "url": "/index.html" }, { "revision": "43e513520a1bd98e6c88", "url": "/static/js/2.ae627b82.chunk.js" }, { "revision": "570d362d673dab785e62d2b8563e1118", "url": "/static/js/2.ae627b82.chunk.js.LICENSE.txt" }, { "revision": "a9b28ac0f6d2a2881254", "url": "/static/js/main.05accb10.chunk.js" }, { "revision": "9b4e396c183e42c1fa5c", "url": "/static/js/runtime-main.09b85ec0.js" } ]); ================================================ FILE: src/main/resources/static/service-worker.js ================================================ /** * Welcome to your Workbox-powered service worker! * * You'll need to register this file in your web app and you should * disable HTTP caching for this file too. * See https://goo.gl/nhQhGp * * The rest of the code is auto-generated. Please don't update this file * directly; instead, make changes to your Workbox build configuration * and re-run your build process. * See https://goo.gl/2aRDsh */ importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js"); importScripts( "/precache-manifest.2241ce5fa2602c9cdc3eb026c3eb8589.js" ); self.addEventListener('message', (event) => { if (event.data && event.data.type === 'SKIP_WAITING') { self.skipWaiting(); } }); workbox.core.clientsClaim(); /** * The workboxSW.precacheAndRoute() method efficiently caches and responds to * requests for URLs in the manifest. * See https://goo.gl/S9QRab */ self.__precacheManifest = [].concat(self.__precacheManifest || []); workbox.precaching.precacheAndRoute(self.__precacheManifest, {}); workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("/index.html"), { blacklist: [/^\/_/,/\/[^/?]+\.[^/]+$/], }); ================================================ FILE: src/main/resources/static/static/js/2.ae627b82.chunk.js ================================================ /*! For license information please see 2.ae627b82.chunk.js.LICENSE.txt */ (this.webpackJsonpclient=this.webpackJsonpclient||[]).push([[2],[function(e,t,n){"use strict";n.d(t,"c",(function(){return i})),n.d(t,"a",(function(){return o})),n.d(t,"e",(function(){return a})),n.d(t,"b",(function(){return u})),n.d(t,"d",(function(){return c})),n.d(t,"f",(function(){return s}));var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function i(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var o=function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=s){var t=console[e]||console.log;return t.apply(console,arguments)}}}!function(e){e.debug=l("debug"),e.log=l("log"),e.warn=l("warn"),e.error=l("error")}(u||(u={}));var f=n(20),p=n(13),d="__",h=[d,d].join("DEV");var v=function(){try{return Boolean(__DEV__)}catch(e){return Object.defineProperty(f.a,h,{value:"production"!==Object(p.a)((function(){return"production"})),enumerable:!1,configurable:!0,writable:!0}),f.a[h]}}(),y=n(32);n(36).a,Object(y.a)(),__DEV__?u("boolean"===typeof v,v):u("boolean"===typeof v,36)},function(e,t,n){"use strict";n.d(t,"e",(function(){return c})),n.d(t,"b",(function(){return s})),n.d(t,"h",(function(){return f})),n.d(t,"j",(function(){return p})),n.d(t,"d",(function(){return d})),n.d(t,"a",(function(){return h})),n.d(t,"c",(function(){return v})),n.d(t,"i",(function(){return y})),n.d(t,"k",(function(){return b})),n.d(t,"g",(function(){return m})),n.d(t,"f",(function(){return g}));var r=n(33),i=n(8),o=n(7),a=n(72),u=n(71),c=Object.prototype.hasOwnProperty;function s(e,t){var n=e.__typename,r=e.id,i=e._id;if("string"===typeof n&&(t&&(t.keyObject=void 0!==r?{id:r}:void 0!==i?{_id:i}:void 0),void 0===r&&(r=i),void 0!==r))return"".concat(n,":").concat("number"===typeof r||"string"===typeof r?r:JSON.stringify(r))}var l={dataIdFromObject:s,addTypename:!0,resultCaching:!0,canonizeResults:!1};function f(e){return Object(r.a)(l,e)}function p(e){var t=e.canonizeResults;return void 0===t?l.canonizeResults:t}function d(e,t){return Object(i.g)(t)?e.get(t.__ref,"__typename"):t&&t.__typename}var h=/^[_a-z][_0-9a-z]*/i;function v(e){var t=e.match(h);return t?t[0]:e}function y(e,t,n){return!!Object(o.a)(t)&&(g(t)?t.every((function(t){return y(e,t,n)})):e.selections.every((function(e){if(Object(i.e)(e)&&Object(a.c)(e,n)){var r=Object(i.i)(e);return c.call(t,r)&&(!e.selectionSet||y(e.selectionSet,t[r],n))}return!0})))}function b(e){return Object(o.a)(e)&&!Object(i.g)(e)&&!g(e)}function m(){return new u.a}var g=function(e){return Array.isArray(e)}},function(e,t,n){"use strict";e.exports=n(53)},function(e,t,n){"use strict";var r;function i(e){return!!e&&e<7}n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i})),function(e){e[e.loading=1]="loading",e[e.setVariables=2]="setVariables",e[e.fetchMore=3]="fetchMore",e[e.refetch=4]="refetch",e[e.poll=6]="poll",e[e.ready=7]="ready",e[e.error=8]="error"}(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=Object.prototype,i=r.toString,o=r.hasOwnProperty,a=Function.prototype.toString,u=new Map;function c(e,t){try{return function e(t,n){if(t===n)return!0;var r=i.call(t),u=i.call(n);if(r!==u)return!1;switch(r){case"[object Array]":if(t.length!==n.length)return!1;case"[object Object]":if(p(t,n))return!0;var c=s(t),l=s(n),d=c.length;if(d!==l.length)return!1;for(var h=0;h=0&&e.indexOf(t,n)===n}(k,f)}return!1}(e,t)}finally{u.clear()}}function s(e){return Object.keys(e).filter(l,e)}function l(e){return void 0!==this[e]}var f="{ [native code] }";function p(e,t){var n=u.get(e);if(n){if(n.has(t))return!0}else u.set(e,n=new Set);return n.add(t),!1}},,function(e,t,n){"use strict";function r(e){return null!==e&&"object"===typeof e}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"h",(function(){return a})),n.d(t,"g",(function(){return u})),n.d(t,"d",(function(){return c})),n.d(t,"k",(function(){return s})),n.d(t,"j",(function(){return l})),n.d(t,"b",(function(){return p})),n.d(t,"a",(function(){return v})),n.d(t,"i",(function(){return y})),n.d(t,"c",(function(){return b})),n.d(t,"e",(function(){return m})),n.d(t,"f",(function(){return g}));var r=n(1),i=n(7),o=n(27);function a(e){return{__ref:String(e)}}function u(e){return Boolean(e&&"object"===typeof e&&"string"===typeof e.__ref)}function c(e){return Object(i.a)(e)&&"Document"===e.kind&&Array.isArray(e.definitions)}function s(e,t,n,i){if(function(e){return"IntValue"===e.kind}(n)||function(e){return"FloatValue"===e.kind}(n))e[t.value]=Number(n.value);else if(function(e){return"BooleanValue"===e.kind}(n)||function(e){return"StringValue"===e.kind}(n))e[t.value]=n.value;else if(function(e){return"ObjectValue"===e.kind}(n)){var o={};n.fields.map((function(e){return s(o,e.name,e.value,i)})),e[t.value]=o}else if(function(e){return"Variable"===e.kind}(n)){var a=(i||{})[n.name.value];e[t.value]=a}else if(function(e){return"ListValue"===e.kind}(n))e[t.value]=n.values.map((function(e){var n={};return s(n,t,e,i),n[t.value]}));else if(function(e){return"EnumValue"===e.kind}(n))e[t.value]=n.value;else{if(!function(e){return"NullValue"===e.kind}(n))throw __DEV__?new r.a('The inline argument "'.concat(t.value,'" of kind "').concat(n.kind,'"')+"is not supported. Use variables instead of inline arguments to overcome this limitation."):new r.a(52);e[t.value]=null}}function l(e,t){var n=null;e.directives&&(n={},e.directives.forEach((function(e){n[e.name.value]={},e.arguments&&e.arguments.forEach((function(r){var i=r.name,o=r.value;return s(n[e.name.value],i,o,t)}))})));var r=null;return e.arguments&&e.arguments.length&&(r={},e.arguments.forEach((function(e){var n=e.name,i=e.value;return s(r,n,i,t)}))),p(e.name.value,r,n)}var f=["connection","include","skip","client","rest","export"],p=Object.assign((function(e,t,n){if(t&&n&&n.connection&&n.connection.key){if(n.connection.filter&&n.connection.filter.length>0){var r=n.connection.filter?n.connection.filter:[];r.sort();var i={};return r.forEach((function(e){i[e]=t[e]})),"".concat(n.connection.key,"(").concat(d(i),")")}return n.connection.key}var o=e;if(t){var a=d(t);o+="(".concat(a,")")}return n&&Object.keys(n).forEach((function(e){-1===f.indexOf(e)&&(n[e]&&Object.keys(n[e]).length?o+="@".concat(e,"(").concat(d(n[e]),")"):o+="@".concat(e))})),o}),{setStringify:function(e){var t=d;return d=e,t}}),d=function(e){return JSON.stringify(e,h)};function h(e,t){return Object(i.a)(t)&&!Array.isArray(t)&&(t=Object.keys(t).sort().reduce((function(e,n){return e[n]=t[n],e}),{})),t}function v(e,t){if(e.arguments&&e.arguments.length){var n={};return e.arguments.forEach((function(e){var r=e.name,i=e.value;return s(n,r,i,t)})),n}return null}function y(e){return e.alias?e.alias.value:e.name.value}function b(e,t,n){if("string"===typeof e.__typename)return e.__typename;for(var r=0,i=t.selections;rthis.max;)this.delete(this.oldest.key)},e.prototype.delete=function(e){var t=this.map.get(e);return!!t&&(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0)},e}(),c=new i.a,s=Object.prototype.hasOwnProperty,l=void 0===(a=Array.from)?function(e){var t=[];return e.forEach((function(e){return t.push(e)})),t}:a;function f(e){var t=e.unsubscribe;"function"===typeof t&&(e.unsubscribe=void 0,t())}var p=[];function d(e,t){if(!e)throw new Error(t||"assertion failure")}function h(e){switch(e.length){case 0:throw new Error("unknown value");case 1:return e[0];case 2:throw e[1]}}var v=function(){function e(t){this.fn=t,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],this.deps=null,++e.count}return e.prototype.peek=function(){if(1===this.value.length&&!m(this))return y(this),this.value[0]},e.prototype.recompute=function(e){return d(!this.recomputing,"already recomputing"),y(this),m(this)?function(e,t){x(e),c.withValue(e,b,[e,t]),function(e,t){if("function"===typeof e.subscribe)try{f(e),e.unsubscribe=e.subscribe.apply(null,t)}catch(n){return e.setDirty(),!1}return!0}(e,t)&&function(e){if(e.dirty=!1,m(e))return;w(e)}(e);return h(e.value)}(this,e):h(this.value)},e.prototype.setDirty=function(){this.dirty||(this.dirty=!0,this.value.length=0,g(this),f(this))},e.prototype.dispose=function(){var e=this;this.setDirty(),x(this),O(this,(function(t,n){t.setDirty(),T(t,e)}))},e.prototype.forget=function(){this.dispose()},e.prototype.dependOn=function(e){e.add(this),this.deps||(this.deps=p.pop()||new Set),this.deps.add(e)},e.prototype.forgetDeps=function(){var e=this;this.deps&&(l(this.deps).forEach((function(t){return t.delete(e)})),this.deps.clear(),p.push(this.deps),this.deps=null)},e.count=0,e}();function y(e){var t=c.getValue();if(t)return e.parents.add(t),t.childValues.has(e)||t.childValues.set(e,[]),m(e)?E(t,e):k(t,e),t}function b(e,t){e.recomputing=!0,e.value.length=0;try{e.value[0]=e.fn.apply(null,t)}catch(n){e.value[1]=n}e.recomputing=!1}function m(e){return e.dirty||!(!e.dirtyChildren||!e.dirtyChildren.size)}function g(e){O(e,E)}function w(e){O(e,k)}function O(e,t){var n=e.parents.size;if(n)for(var r=l(e.parents),i=0;i0&&n===t.length&&e[n-1]===t[n-1]}(n,t.value)||e.setDirty(),_(e,t),m(e)||w(e)}function _(e,t){var n=e.dirtyChildren;n&&(n.delete(t),0===n.size&&(p.length<100&&p.push(n),e.dirtyChildren=null))}function x(e){e.childValues.size>0&&e.childValues.forEach((function(t,n){T(e,n)})),e.forgetDeps(),d(null===e.dirtyChildren)}function T(e,t){t.parents.delete(e),e.childValues.delete(t),_(e,t)}var S={setDirty:!0,dispose:!0,forget:!0};function j(e){var t=new Map,n=e&&e.subscribe;function r(e){var r=c.getValue();if(r){var i=t.get(e);i||t.set(e,i=new Set),r.dependOn(i),"function"===typeof n&&(f(i),i.unsubscribe=n(e))}}return r.dirty=function(e,n){var r=t.get(e);if(r){var i=n&&s.call(S,n)?n:"setDirty";l(r).forEach((function(e){return e[i]()})),t.delete(e),f(r)}},r}function C(){var e=new r.a("function"===typeof WeakMap);return function(){return e.lookupArray(arguments)}}C();var N=new Set;function D(e,t){void 0===t&&(t=Object.create(null));var n=new u(t.max||Math.pow(2,16),(function(e){return e.dispose()})),r=t.keyArgs,i=t.makeCacheKey||C(),o=function(){var o=i.apply(null,r?r.apply(null,arguments):arguments);if(void 0===o)return e.apply(null,arguments);var a=n.get(o);a||(n.set(o,a=new v(e)),a.subscribe=t.subscribe,a.forget=function(){return n.delete(o)});var u=a.recompute(Array.prototype.slice.call(arguments));return n.set(o,a),N.add(n),c.hasValue()||(N.forEach((function(e){return e.clean()})),N.clear()),u};function a(e){var t=n.get(e);t&&t.setDirty()}function s(e){var t=n.get(e);if(t)return t.peek()}function l(e){return n.delete(e)}return Object.defineProperty(o,"size",{get:function(){return n.map.size},configurable:!1,enumerable:!1}),o.dirtyKey=a,o.dirty=function(){a(i.apply(null,arguments))},o.peekKey=s,o.peek=function(){return s(i.apply(null,arguments))},o.forgetKey=l,o.forget=function(){return l(i.apply(null,arguments))},o.makeCacheKey=i,o.getKey=r?function(){return i.apply(null,r.apply(null,arguments))}:i,Object.freeze(o)}},function(e,t,n){"use strict";function r(e){try{return e()}catch(t){}}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=null,i={},o=1,a=Array,u=a["@wry/context:Slot"]||function(){var e=function(){function e(){this.id=["slot",o++,Date.now(),Math.random().toString(36).slice(2)].join(":")}return e.prototype.hasValue=function(){for(var e=r;e;e=e.parent)if(this.id in e.slots){var t=e.slots[this.id];if(t===i)break;return e!==r&&(r.slots[this.id]=t),!0}return r&&(r.slots[this.id]=i),!1},e.prototype.getValue=function(){if(this.hasValue())return r.slots[this.id]},e.prototype.withValue=function(e,t,n,i){var o,a=((o={__proto__:null})[this.id]=e,o),u=r;r={parent:u,slots:a};try{return t.apply(i,n)}finally{r=u}},e.bind=function(e){var t=r;return function(){var n=r;try{return r=t,e.apply(this,arguments)}finally{r=n}}},e.noContext=function(e,t,n){if(!r)return e.apply(n,t);var i=r;try{return r=null,e.apply(n,t)}finally{r=i}},e}();try{Object.defineProperty(a,"@wry/context:Slot",{value:a["@wry/context:Slot"]=e,enumerable:!1,writable:!1,configurable:!1})}finally{return e}}();u.bind,u.noContext},,function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"d",(function(){return c})),n.d(t,"c",(function(){return s}));var r=n(12),i=new(n(14).a),o=new WeakMap;function a(e){var t=o.get(e);return t||o.set(e,t={vars:new Set,dep:Object(r.a)()}),t}function u(e){a(e).vars.forEach((function(t){return t.forgetCache(e)}))}function c(e){a(e).vars.forEach((function(t){return t.attachCache(e)}))}function s(e){var t=new Set,n=new Set,r=function r(u){if(arguments.length>0){if(e!==u){e=u,t.forEach((function(e){a(e).dep.dirty(r),l(e)}));var c=Array.from(n);n.clear(),c.forEach((function(t){return t(e)}))}}else{var s=i.getValue();s&&(o(s),a(s).dep(r))}return e};r.onNextChange=function(e){return n.add(e),function(){n.delete(e)}};var o=r.attachCache=function(e){return t.add(e),a(e).vars.add(r),r};return r.forgetCache=function(e){return t.delete(e)},r}function l(e){e.broadcastWatches&&e.broadcastWatches()}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"f",(function(){return a})),n.d(t,"g",(function(){return u})),n.d(t,"d",(function(){return c})),n.d(t,"h",(function(){return s})),n.d(t,"c",(function(){return l})),n.d(t,"e",(function(){return f})),n.d(t,"b",(function(){return p}));var r=n(1),i=n(8);function o(e){__DEV__?Object(r.b)(e&&"Document"===e.kind,'Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql'):Object(r.b)(e&&"Document"===e.kind,44);var t=e.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})).map((function(e){if("OperationDefinition"!==e.kind)throw __DEV__?new r.a('Schema type definitions not allowed in queries. Found: "'.concat(e.kind,'"')):new r.a(45);return e}));return __DEV__?Object(r.b)(t.length<=1,"Ambiguous GraphQL document: contains ".concat(t.length," operations")):Object(r.b)(t.length<=1,46),e}function a(e){return o(e),e.definitions.filter((function(e){return"OperationDefinition"===e.kind}))[0]}function u(e){return e.definitions.filter((function(e){return"OperationDefinition"===e.kind&&e.name})).map((function(e){return e.name.value}))[0]||null}function c(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function s(e){var t=a(e);return __DEV__?Object(r.b)(t&&"query"===t.operation,"Must contain a query definition."):Object(r.b)(t&&"query"===t.operation,47),t}function l(e){__DEV__?Object(r.b)("Document"===e.kind,'Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql'):Object(r.b)("Document"===e.kind,48),__DEV__?Object(r.b)(e.definitions.length<=1,"Fragment must have exactly one definition."):Object(r.b)(e.definitions.length<=1,49);var t=e.definitions[0];return __DEV__?Object(r.b)("FragmentDefinition"===t.kind,"Must be a fragment definition."):Object(r.b)("FragmentDefinition"===t.kind,50),t}function f(e){var t;o(e);for(var n=0,i=e.definitions;n=0}))||!1,s=u&&!c},function(e,t,n){"use strict";(function(e){var r=n(13);t.a=Object(r.a)((function(){return globalThis}))||Object(r.a)((function(){return window}))||Object(r.a)((function(){return self}))||Object(r.a)((function(){return e}))||Object(r.a)((function(){return r.a.constructor("return this")()}))}).call(this,n(29))},function(e,t,n){"use strict";var r="function"===typeof Symbol&&"function"===typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):void 0;t.a=r},function(e,t,n){"use strict";function r(e,t){if(!Boolean(e))throw new Error(t)}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return f}));var r=n(0),i=n(1),o=n(69);var a=n(17);function u(e,t){return t?t(e):o.a.of()}function c(e){return"function"===typeof e?new f(e):e}function s(e){return e.request.length<=1}var l=function(e){function t(t,n){var r=e.call(this,t)||this;return r.link=n,r}return Object(r.c)(t,e),t}(Error),f=function(){function e(e){e&&(this.request=e)}return e.empty=function(){return new e((function(){return o.a.of()}))},e.from=function(t){return 0===t.length?e.empty():t.map(c).reduce((function(e,t){return e.concat(t)}))},e.split=function(t,n,r){var i=c(n),a=c(r||new e(u));return s(i)&&s(a)?new e((function(e){return t(e)?i.request(e)||o.a.of():a.request(e)||o.a.of()})):new e((function(e,n){return t(e)?i.request(e,n)||o.a.of():a.request(e,n)||o.a.of()}))},e.execute=function(e,t){return e.request(function(e,t){var n=Object(r.a)({},e);return Object.defineProperty(t,"setContext",{enumerable:!1,value:function(e){n="function"===typeof e?Object(r.a)(Object(r.a)({},n),e(n)):Object(r.a)(Object(r.a)({},n),e)}}),Object.defineProperty(t,"getContext",{enumerable:!1,value:function(){return Object(r.a)({},n)}}),t}(t.context,function(e){var t={variables:e.variables||{},extensions:e.extensions||{},operationName:e.operationName,query:e.query};return t.operationName||(t.operationName="string"!==typeof t.query?Object(a.g)(t.query)||void 0:""),t}(function(e){for(var t=["query","operationName","variables","extensions","context"],n=0,r=Object.keys(e);n2)return"[Array]";for(var n=Math.min(10,e.length),r=e.length-n,i=[],o=0;o1&&i.push("... ".concat(r," more items"));return"["+i.join(", ")+"]"}(e,n);return function(e,t){var n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"===typeof e.constructor){var n=e.constructor.name;if("string"===typeof n&&""!==n)return n}return t}(e)+"]";return"{ "+n.map((function(n){return n+": "+a(e[n],t)})).join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}},function(e,t,n){"use strict";function r(e){var t=e.split(/\r\n|[\n\r]/g),n=function(e){for(var t=null,n=1;n0&&o(t[0]);)t.shift();for(;t.length>0&&o(t[t.length-1]);)t.pop();return t.join("\n")}function i(e){for(var t=0;t1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],a=!r||o||n,u="";return!a||r&&i||(u+="\n"+t),u+=t?e.replace(/\n/g,"\n"+t):e,a&&(u+="\n"),'"""'+u.replace(/"""/g,'\\"""')+'"""'}n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return a}))},function(e,t,n){"use strict";n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return u}));var r=n(0),i=n(1);function o(e,t){var n=t,o=[];return e.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw __DEV__?new i.a("Found a ".concat(e.operation," operation").concat(e.name?" named '".concat(e.name.value,"'"):"",". ")+"No operations are allowed when using a fragment as a query. Only fragments are allowed."):new i.a(41);"FragmentDefinition"===e.kind&&o.push(e)})),"undefined"===typeof n&&(__DEV__?Object(i.b)(1===o.length,"Found ".concat(o.length," fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")):Object(i.b)(1===o.length,42),n=o[0].name.value),Object(r.a)(Object(r.a)({},e),{definitions:Object(r.f)([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],e.definitions,!0)})}function a(e){void 0===e&&(e=[]);var t={};return e.forEach((function(e){t[e.name.value]=e})),t}function u(e,t){switch(e.kind){case"InlineFragment":return e;case"FragmentSpread":var n=t&&t[e.name.value];return __DEV__?Object(i.b)(n,"No fragment named ".concat(e.name.value,".")):Object(i.b)(n,43),n;default:return null}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(1),i=n(3),o=n(34);function a(e){var t=Object(i.useContext)(Object(o.a)()),n=e||t.client;return __DEV__?Object(r.b)(!!n,'Could not find "client" in the context or passed in as an option. Wrap the root component in an , or pass an ApolloClient instance in via options.'):Object(r.b)(!!n,29),n}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(r){"object"===typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return a}));var r=n(25),i={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:["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","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","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},o=Object.freeze({});function a(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i,a=void 0,s=Array.isArray(e),l=[e],f=-1,p=[],d=void 0,h=void 0,v=void 0,y=[],b=[],m=e;do{var g=++f===l.length,w=g&&0!==p.length;if(g){if(h=0===b.length?void 0:y[y.length-1],d=v,v=b.pop(),w){if(s)d=d.slice();else{for(var O={},E=0,k=Object.keys(d);E=300&&s(e,t,"Response not successful: Received status code ".concat(e.status)),Array.isArray(t)||l.call(t,"data")||l.call(t,"errors")||s(e,t,"Server response was missing for query '".concat(Array.isArray(r)?r.map((function(e){return e.operationName})):r.operationName,"'.")),t}))})).then((function(e){return n.next(e),n.complete(),e})).catch((function(e){"AbortError"!==e.name&&(e.result&&e.result.errors&&e.result.data&&n.next(e.result),n.error(e))})),function(){k&&k.abort()}}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(22);var i,o=function(e,t,n){this.body=e,this.name=t||"GraphQL request",this.locationOffset=n||{line:1,column:1},this.locationOffset.line>0||Object(r.a)(0,"line in locationOffset is 1-indexed and must be positive"),this.locationOffset.column>0||Object(r.a)(0,"column in locationOffset is 1-indexed and must be positive")};i=o,"function"===typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(i.prototype,Symbol.toStringTag,{get:function(){return this.constructor.name}})},,,function(e,t,n){"use strict";var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function a(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(i){return!1}}()?Object.assign:function(e,t){for(var n,u,c=a(e),s=1;se.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&r.every((function(e){return"message"in e}))))throw new Error('"'.concat(e.type,"\" message expects the 'payload' property to be an array of GraphQL errors, but got ").concat(JSON.stringify(e.payload)));break;case t.MessageType.Complete:if("string"!==typeof e.id)throw new Error('"'.concat(e.type,"\" message expects the 'id' property to be a string, but got ").concat(n(e.id)));if(!e.id)throw new Error('"'.concat(e.type,"\" message requires a non-empty 'id' property"));break;default:throw new Error("Invalid message 'type' property \"".concat(e.type,'"'))}var r;return e}function p(e,t){try{return f(e)}catch(n){if("string"!==typeof e)throw new Error("Only strings are parsable messages");return f(JSON.parse(e,t))}}function d(e,t){return f(e),JSON.stringify(e,t)}function h(e){return u(e)&&"code"in e&&"reason"in e}t.CloseCode=void 0,(s=t.CloseCode||(t.CloseCode={}))[s.InternalServerError=4500]="InternalServerError",s[s.InternalClientError=4005]="InternalClientError",s[s.BadRequest=4400]="BadRequest",s[s.BadResponse=4004]="BadResponse",s[s.Unauthorized=4401]="Unauthorized",s[s.Forbidden=4403]="Forbidden",s[s.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",s[s.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",s[s.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",s[s.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",s[s.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",t.MessageType=void 0,(l=t.MessageType||(t.MessageType={})).ConnectionInit="connection_init",l.ConnectionAck="connection_ack",l.Ping="ping",l.Pong="pong",l.Subscribe="subscribe",l.Next="next",l.Error="error",l.Complete="complete",t.DEPRECATED_GRAPHQL_WS_PROTOCOL="graphql-ws",t.GRAPHQL_TRANSPORT_WS_PROTOCOL="graphql-transport-ws",t.createClient=function(n){var u,s,l=n.url,f=n.connectionParams,v=n.lazy,y=void 0===v||v,b=n.onNonLazyError,m=void 0===b?console.error:b,g=n.lazyCloseTimeout,w=void 0===g?0:g,O=n.keepAlive,E=void 0===O?0:O,k=n.disablePong,_=n.connectionAckWaitTimeout,x=void 0===_?0:_,T=n.retryAttempts,S=void 0===T?5:T,j=n.retryWait,C=void 0===j?function(){var e=a(o.mark((function e(t){var n,r;return o.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=1e3,r=0;r(e[t]=n,function(){delete e[t]}),emit(t){var n;"id"in t&&(null===(n=e[t.id])||void 0===n||n.call(e,t))}}}(),t={connecting:(null===I||void 0===I?void 0:I.connecting)?[I.connecting]:[],opened:(null===I||void 0===I?void 0:I.opened)?[I.opened]:[],connected:(null===I||void 0===I?void 0:I.connected)?[I.connected]:[],ping:(null===I||void 0===I?void 0:I.ping)?[I.ping]:[],pong:(null===I||void 0===I?void 0:I.pong)?[I.pong]:[],message:(null===I||void 0===I?void 0:I.message)?[e.emit,I.message]:[e.emit],closed:(null===I||void 0===I?void 0:I.closed)?[I.closed]:[],error:(null===I||void 0===I?void 0:I.error)?[I.error]:[]};return{onMessage:e.on,on(e,n){var r=t[e];return r.push(n),function(){r.splice(r.indexOf(n),1)}},emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o0&&(clearTimeout(s),s=setTimeout((function(){i.readyState===V.OPEN&&(i.send(d({type:t.MessageType.Ping})),q.emit("ping",!1,void 0))}),E))},!B){r.next=8;break}return r.next=4,C(W);case 4:if(U){r.next=7;break}return z=void 0,r.abrupt("return",n({code:1e3,reason:"All Subscriptions Gone"}));case 7:W++;case 8:if(q.emit("connecting"),r.t0=V,"function"!==typeof l){r.next=16;break}return r.next=13,l();case 13:r.t1=r.sent,r.next=17;break;case 16:r.t1=l;case 17:r.t2=r.t1,r.t3="graphql-transport-ws",i=new r.t0(r.t2,r.t3),Q((function(e){z=void 0,clearTimeout(u),clearTimeout(s),n(e),h(e)&&4499===e.code&&(i.close(4499,"Terminated"),i.onerror=null,i.onclose=null)})),i.onerror=function(e){return q.emit("error",e)},i.onclose=function(e){return q.emit("closed",e)},i.onopen=a(o.mark((function e(){var n;return o.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,q.emit("opened",i),"function"!==typeof f){e.next=8;break}return e.next=5,f();case 5:e.t0=e.sent,e.next=9;break;case 8:e.t0=f;case 9:if(n=e.t0,i.readyState===V.OPEN){e.next=12;break}return e.abrupt("return");case 12:i.send(d(n?{type:t.MessageType.ConnectionInit,payload:n}:{type:t.MessageType.ConnectionInit},M)),isFinite(x)&&x>0&&(u=setTimeout((function(){i.close(t.CloseCode.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")}),x)),v(),e.next=21;break;case 17:e.prev=17,e.t1=e.catch(0),q.emit("error",e.t1),i.close(t.CloseCode.InternalClientError,c(e.t1 instanceof Error?e.t1.message:new Error(e.t1).message,"Internal client error"));case 21:case"end":return e.stop()}}),e,null,[[0,17]])}))),y=!1,i.onmessage=function(n){var r=n.data;try{var o=p(r,L);if(q.emit("message",o),"ping"===o.type||"pong"===o.type)return q.emit(o.type,!0,o.payload),void("pong"===o.type?v():k||(i.send(d(o.payload?{type:t.MessageType.Pong,payload:o.payload}:{type:t.MessageType.Pong})),q.emit("pong",!1,o.payload)));if(y)return;if(o.type!==t.MessageType.ConnectionAck)throw new Error("First message cannot be of type ".concat(o.type));clearTimeout(u),y=!0,q.emit("connected",i,o.payload),B=!1,W=0,e([i,new Promise((function(e,t){return Q(t)}))])}catch(a){i.onmessage=null,q.emit("error",a),i.close(t.CloseCode.BadResponse,c(a instanceof Error?a.message:new Error(a).message,"Bad response"))}};case 26:case"end":return r.stop()}}),r)})))()}));case 2:if(n=e.sent,i=r(n,2),u=i[0],s=i[1],u.readyState!==V.CLOSING){e.next=9;break}return e.next=9,s;case 9:return v=function(){},y=new Promise((function(e){return v=e})),e.abrupt("return",[u,v,Promise.race([y.then((function(){if(!U){var e=function(){return u.close(1e3,"Normal Closure")};isFinite(w)&&w>0?setTimeout((function(){U||u.readyState!==V.OPEN||e()}),w):e()}})),s])]);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Y(e){if(h(e)&&(n=e.code,![1e3,1001,1006,1005,1012,1013,1013].includes(n)&&n>=1e3&&n<=1999||[t.CloseCode.InternalServerError,t.CloseCode.InternalClientError,t.CloseCode.BadRequest,t.CloseCode.BadResponse,t.CloseCode.Unauthorized,t.CloseCode.SubprotocolNotAcceptable,t.CloseCode.SubscriberAlreadyExists,t.CloseCode.TooManyInitialisationRequests].includes(e.code)))throw e;var n;if(K)return!1;if(h(e)&&1e3===e.code)return U>0;if(!S||W>=S)throw e;if(!D(e))throw e;if(null===P||void 0===P?void 0:P(e))throw e;return B=!0}return y||a(o.mark((function e(){var t,n,i;return o.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:U++;case 1:return e.prev=1,e.next=4,H();case 4:return t=e.sent,n=r(t,3),i=n[2],e.next=9,i;case 9:e.next=21;break;case 11:if(e.prev=11,e.t0=e.catch(1),e.prev=13,Y(e.t0)){e.next=16;break}return e.abrupt("return");case 16:e.next=21;break;case 18:return e.prev=18,e.t1=e.catch(13),e.abrupt("return",null===m||void 0===m?void 0:m(e.t1));case 21:e.next=1;break;case 23:case"end":return e.stop()}}),e,null,[[1,11],[13,18]])})))(),{on:q.on,subscribe(e,n){var i=A(),u=!1,c=!1,s=function(){U--,u=!0};return a(o.mark((function a(){var l;return o.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:U++;case 1:return a.prev=1,a.delegateYield(o.mark((function a(){var l,f,p,h,v,y;return o.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,H();case 2:if(l=o.sent,f=r(l,3),p=f[0],h=f[1],v=f[2],!u){o.next=9;break}return o.abrupt("return",{v:h()});case 9:return y=q.onMessage(i,(function(e){switch(e.type){case t.MessageType.Next:return void n.next(e.payload);case t.MessageType.Error:return c=!0,u=!0,n.error(e.payload),void s();case t.MessageType.Complete:return u=!0,void s()}})),p.send(d({id:i,type:t.MessageType.Subscribe,payload:e},M)),s=function(){u||p.readyState!==V.OPEN||p.send(d({id:i,type:t.MessageType.Complete},M)),U--,u=!0,h()},o.next=14,v.finally(y);case 14:return o.abrupt("return",{v:void 0});case 15:case"end":return o.stop()}}),a)}))(),"t0",3);case 3:if("object"!==typeof(l=a.t0)){a.next=6;break}return a.abrupt("return",l.v);case 6:a.next=12;break;case 8:if(a.prev=8,a.t1=a.catch(1),Y(a.t1)){a.next=12;break}return a.abrupt("return");case 12:a.next=1;break;case 14:case"end":return a.stop()}}),a,null,[[1,8]])})))().then((function(){c||n.complete()})).catch((function(e){n.error(e)})),function(){u||s()}},dispose:()=>a(o.mark((function e(){var t;return o.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(K=!0,!z){e.next=8;break}return e.next=4,z;case 4:t=e.sent,r(t,1)[0].close(1e3,"Normal Closure");case 8:case"end":return e.stop()}}),e)})))(),terminate(){z&&q.emit("closed",{code:4499,reason:"Terminated",wasClean:!1})}}},t.isMessage=function(e){try{return f(e),!0}catch(t){return!1}},t.parseMessage=p,t.stringifyMessage=d,t.validateMessage=f,Object.defineProperty(t,"__esModule",{value:!0})})(t)}).call(this,n(29))},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(0),i=n(70),o=n(23),a=n(7),u=n(69),c=n(10);var s=function(e){function t(t){var n=e.call(this)||this;return n.client=t,n}return Object(r.c)(t,e),t.prototype.request=function(e){var t=this;return new u.a((function(n){return t.client.subscribe(Object(r.a)(Object(r.a)({},e),{query:Object(i.a)(e.query)}),{next:n.next.bind(n),complete:n.complete.bind(n),error:function(e){return e instanceof Error?n.error(e):(t=e,Object(a.a)(t)&&"code"in t&&"reason"in t?n.error(new Error("Socket closed with event ".concat(e.code," ").concat(e.reason||""))):n.error(new c.a({graphQLErrors:Array.isArray(e)?e:[e]})));var t}})}))},t}(o.a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=new Map;function i(e){var t=r.get(e)||1;return r.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}},function(e,t,n){"use strict";function r(e){return Array.isArray(e)&&e.length>0}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return L}));var r=n(0),i=n(25),o=n(22),a=n(21);function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.prototype.toString;e.prototype.toJSON=t,e.prototype.inspect=t,a.a&&(e.prototype[a.a]=t)}function c(e){return(c="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){for(var n,r=/\r\n|[\n\r]/g,i=1,o=t+1;(n=r.exec(e.body))&&n.index120){for(var h=Math.floor(c/80),v=c%80,y=[],b=0;b",EOF:"",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function w(){return this.lastToken=this.token,this.token=this.lookahead()}function O(){var e=this.token;if(e.kind!==g.EOF)do{e=e.next||(e.next=_(this,e))}while(e.kind===g.COMMENT);return e}function E(e,t,n,r,i,o,a){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=a,this.prev=o,this.next=null}function k(e){return isNaN(e)?g.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function _(e,t){var n=e.source,r=n.body,i=r.length,o=function(e,t,n){var r=e.length,i=t;for(;i=i)return new E(g.EOF,i,i,a,u,t);var c=r.charCodeAt(o);switch(c){case 33:return new E(g.BANG,o,o+1,a,u,t);case 35:return function(e,t,n,r,i){var o,a=e.body,u=t;do{o=a.charCodeAt(++u)}while(!isNaN(o)&&(o>31||9===o));return new E(g.COMMENT,t,u,n,r,i,a.slice(t+1,u))}(n,o,a,u,t);case 36:return new E(g.DOLLAR,o,o+1,a,u,t);case 38:return new E(g.AMP,o,o+1,a,u,t);case 40:return new E(g.PAREN_L,o,o+1,a,u,t);case 41:return new E(g.PAREN_R,o,o+1,a,u,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new E(g.SPREAD,o,o+3,a,u,t);break;case 58:return new E(g.COLON,o,o+1,a,u,t);case 61:return new E(g.EQUALS,o,o+1,a,u,t);case 64:return new E(g.AT,o,o+1,a,u,t);case 91:return new E(g.BRACKET_L,o,o+1,a,u,t);case 93:return new E(g.BRACKET_R,o,o+1,a,u,t);case 123:return new E(g.BRACE_L,o,o+1,a,u,t);case 124:return new E(g.PIPE,o,o+1,a,u,t);case 125:return new E(g.BRACE_R,o,o+1,a,u,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return function(e,t,n,r,i){var o=e.body,a=o.length,u=t+1,c=0;for(;u!==a&&!isNaN(c=o.charCodeAt(u))&&(95===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122);)++u;return new E(g.NAME,t,u,n,r,i,o.slice(t,u))}(n,o,a,u,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return function(e,t,n,r,i,o){var a=e.body,u=n,c=t,s=!1;45===u&&(u=a.charCodeAt(++c));if(48===u){if((u=a.charCodeAt(++c))>=48&&u<=57)throw v(e,c,"Invalid number, unexpected digit after 0: ".concat(k(u),"."))}else c=x(e,c,u),u=a.charCodeAt(c);46===u&&(s=!0,u=a.charCodeAt(++c),c=x(e,c,u),u=a.charCodeAt(c));69!==u&&101!==u||(s=!0,43!==(u=a.charCodeAt(++c))&&45!==u||(u=a.charCodeAt(++c)),c=x(e,c,u),u=a.charCodeAt(c));if(46===u||69===u||101===u)throw v(e,c,"Invalid number, expected digit but got: ".concat(k(u),"."));return new E(s?g.FLOAT:g.INT,t,c,r,i,o,a.slice(t,c))}(n,o,c,a,u,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?function(e,t,n,r,i,o){var a=e.body,u=t+3,c=u,s=0,l="";for(;u=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw v(e,i,"Invalid number, expected digit but got: ".concat(k(o),"."))}function T(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}u(E,(function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}));var S=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});var j=function(){function e(e,t){var n="string"===typeof e?new b.a(e):e;n instanceof b.a||Object(o.a)(0,"Must provide Source. Received: ".concat(Object(i.a)(n))),this._lexer=function(e,t){var n=new E(g.SOF,0,0,0,0,null);return{source:e,options:t,lastToken:n,token:n,line:1,lineStart:0,advance:w,lookahead:O}}(n),this._options=t||{}}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(g.NAME);return{kind:y.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:y.DOCUMENT,definitions:this.many(g.SOF,this.parseDefinition,g.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(g.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(g.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(g.BRACE_L))return{kind:y.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,n=this.parseOperationType();return this.peek(g.NAME)&&(t=this.parseName()),{kind:y.OPERATION_DEFINITION,operation:n,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(g.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(g.PAREN_L,this.parseVariableDefinition,g.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:y.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(g.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(g.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(g.DOLLAR),{kind:y.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:y.SELECTION_SET,selections:this.many(g.BRACE_L,this.parseSelection,g.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(g.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(g.COLON)?(e=r,t=this.parseName()):t=r,{kind:y.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(g.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(g.PAREN_L,t,g.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(g.COLON),{kind:y.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:y.ARGUMENT,name:this.parseName(),value:(this.expectToken(g.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(g.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(g.NAME)?{kind:y.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:y.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e=this._lexer.token;return this.expectKeyword("fragment"),this._options.experimentalFragmentVariables?{kind:y.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:y.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case g.BRACKET_L:return this.parseList(e);case g.BRACE_L:return this.parseObject(e);case g.INT:return this._lexer.advance(),{kind:y.INT,value:t.value,loc:this.loc(t)};case g.FLOAT:return this._lexer.advance(),{kind:y.FLOAT,value:t.value,loc:this.loc(t)};case g.STRING:case g.BLOCK_STRING:return this.parseStringLiteral();case g.NAME:return"true"===t.value||"false"===t.value?(this._lexer.advance(),{kind:y.BOOLEAN,value:"true"===t.value,loc:this.loc(t)}):"null"===t.value?(this._lexer.advance(),{kind:y.NULL,loc:this.loc(t)}):(this._lexer.advance(),{kind:y.ENUM,value:t.value,loc:this.loc(t)});case g.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:y.STRING,value:e.value,block:e.kind===g.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,n=this._lexer.token;return{kind:y.LIST,values:this.any(g.BRACKET_L,(function(){return t.parseValueLiteral(e)}),g.BRACKET_R),loc:this.loc(n)}},t.parseObject=function(e){var t=this,n=this._lexer.token;return{kind:y.OBJECT,fields:this.any(g.BRACE_L,(function(){return t.parseObjectField(e)}),g.BRACE_R),loc:this.loc(n)}},t.parseObjectField=function(e){var t=this._lexer.token,n=this.parseName();return this.expectToken(g.COLON),{kind:y.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(g.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(g.AT),{kind:y.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(g.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(g.BRACKET_R),e={kind:y.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(g.BANG)?{kind:y.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:y.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===g.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(g.STRING)||this.peek(g.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token;this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.many(g.BRACE_L,this.parseOperationTypeDefinition,g.BRACE_R);return{kind:y.SCHEMA_DEFINITION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(g.COLON);var n=this.parseNamedType();return{kind:y.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var n=this.parseName(),r=this.parseDirectives(!0);return{kind:y.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:y.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e=[];if(this.expectOptionalKeyword("implements")){this.expectOptionalToken(g.AMP);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(g.AMP)||this._options.allowLegacySDLImplementsInterfaces&&this.peek(g.NAME))}return e},t.parseFieldsDefinition=function(){return this._options.allowLegacySDLEmptyFields&&this.peek(g.BRACE_L)&&this._lexer.lookahead().kind===g.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(g.BRACE_L,this.parseFieldDefinition,g.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(g.COLON);var i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:y.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(g.PAREN_L,this.parseInputValueDef,g.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(g.COLON);var r,i=this.parseTypeReference();this.expectOptionalToken(g.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:y.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();return{kind:y.INTERFACE_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:y.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){var e=[];if(this.expectOptionalToken(g.EQUALS)){this.expectOptionalToken(g.PIPE);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(g.PIPE))}return e},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:y.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(g.BRACE_L,this.parseEnumValueDefinition,g.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:y.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:y.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(g.BRACE_L,this.parseInputValueDef,g.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===g.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)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.optionalMany(g.BRACE_L,this.parseOperationTypeDefinition,g.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:y.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:y.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:y.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:y.INTERFACE_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:y.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:y.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:y.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(g.AT);var n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:y.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){this.expectOptionalToken(g.PIPE);var e=[];do{e.push(this.parseDirectiveLocation())}while(this.expectOptionalToken(g.PIPE));return e},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==S[t.value])return t;throw this.unexpected(e)},t.loc=function(e){if(!this._options.noLocation)return new C(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw v(this._lexer.source,t.start,"Expected ".concat(e,", found ").concat(N(t)))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==g.NAME||t.value!==e)throw v(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(N(t)));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===g.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=e||this._lexer.token;return v(this._lexer.source,t.start,"Unexpected ".concat(N(t)))},t.any=function(e,t,n){this.expectToken(e);for(var r=[];!this.expectOptionalToken(n);)r.push(t.call(this));return r},t.optionalMany=function(e,t,n){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}return[]},t.many=function(e,t,n){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r},e}();function C(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}function N(e){var t=e.value;return t?"".concat(e.kind,' "').concat(t,'"'):e.kind}u(C,(function(){return{start:this.start,end:this.end}}));var D=new Map,P=new Map,I=!0,R=!1;function F(e){return e.replace(/[\s,]+/g," ").trim()}function A(e){var t=new Set,n=[];return e.definitions.forEach((function(e){if("FragmentDefinition"===e.kind){var r=e.name.value,i=F((a=e.loc).source.body.substring(a.start,a.end)),o=P.get(r);o&&!o.has(i)?I&&console.warn("Warning: fragment with name "+r+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||P.set(r,o=new Set),o.add(i),t.has(i)||(t.add(i),n.push(e))}else n.push(e);var a})),Object(r.a)(Object(r.a)({},e),{definitions:n})}function M(e){var t=F(e);if(!D.has(t)){var n=function(e,t){return new j(e,t).parseDocument()}(e,{experimentalFragmentVariables:R,allowLegacyFragmentVariables:R});if(!n||"Document"!==n.kind)throw new Error("Not a valid GraphQL document.");D.set(t,function(e){var t=new Set(e.definitions);t.forEach((function(e){e.loc&&delete e.loc,Object.keys(e).forEach((function(n){var r=e[n];r&&"object"===typeof r&&t.add(r)}))}));var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}(A(n)))}return D.get(t)}function L(e){for(var t=[],n=1;nN.length&&N.push(e)}function I(e,t,n){return null==e?0:function e(t,n,r,i){var u=typeof t;"undefined"!==u&&"boolean"!==u||(t=null);var c=!1;if(null===t)c=!0;else switch(u){case"string":case"number":c=!0;break;case"object":switch(t.$$typeof){case o:case a:c=!0}}if(c)return r(i,t,""===n?"."+R(t,0):n),1;if(c=0,n=""===n?".":n+":",Array.isArray(t))for(var s=0;s