|
| 1 | +/* |
| 2 | + * The MIT License (MIT) |
| 3 | + * |
| 4 | + * Copyright (c) 2016 oEmbedler Inc. and Contributors |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
| 7 | + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the |
| 8 | + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit |
| 9 | + * persons to whom the Software is furnished to do so, subject to the following conditions: |
| 10 | + * |
| 11 | + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
| 12 | + * |
| 13 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
| 14 | + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 15 | + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 16 | + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 17 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 18 | + */ |
| 19 | + |
| 20 | +package graphql.kickstart.sample; |
| 21 | + |
| 22 | +import graphql.Scalars; |
| 23 | +import graphql.schema.DataFetcher; |
| 24 | +import graphql.schema.FieldCoordinates; |
| 25 | +import graphql.schema.GraphQLCodeRegistry; |
| 26 | +import graphql.schema.GraphQLObjectType; |
| 27 | +import graphql.schema.GraphQLSchema; |
| 28 | +import java.util.concurrent.CompletableFuture; |
| 29 | +import lombok.extern.slf4j.Slf4j; |
| 30 | +import org.springframework.boot.SpringApplication; |
| 31 | +import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 32 | +import org.springframework.context.annotation.Bean; |
| 33 | + |
| 34 | +@Slf4j |
| 35 | +@SpringBootApplication |
| 36 | +public class ApplicationBootConfiguration { |
| 37 | + |
| 38 | + public static void main(String[] args) { |
| 39 | + SpringApplication.run(ApplicationBootConfiguration.class, args); |
| 40 | + } |
| 41 | + |
| 42 | + @Bean |
| 43 | + GraphQLSchema schema() { |
| 44 | + DataFetcher<CompletableFuture<String>> test = |
| 45 | + env -> CompletableFuture.supplyAsync(() -> "response"); |
| 46 | + return GraphQLSchema.newSchema() |
| 47 | + .query( |
| 48 | + GraphQLObjectType.newObject() |
| 49 | + .name("query") |
| 50 | + .field(field -> field.name("test").type(Scalars.GraphQLString)) |
| 51 | + .build()) |
| 52 | + .codeRegistry( |
| 53 | + GraphQLCodeRegistry.newCodeRegistry() |
| 54 | + .dataFetcher(FieldCoordinates.coordinates("query", "test"), test) |
| 55 | + .build()) |
| 56 | + .build(); |
| 57 | + } |
| 58 | +} |
0 commit comments