springboot集成graphql(一)

背景:基于上篇springboot集成jooq继续

GraphQL Playgroundhttps://github.com/prisma-labs/graphql-playground/releases

一、pom.xml文件引入相关依赖


    com.graphql-java-kickstart
    graphql-spring-boot-starter
    5.10.0


    com.graphql-java
    graphql-java
    2019-10-31T04-37-48-0919e71



    com.graphql-java-kickstart
    graphiql-spring-boot-starter
    5.10.0


    com.graphql-java
    graphql-java-spring-boot-starter-webmvc
    2019-06-24T11-47-27-31ab4f9


二、配置文件修改

1. application.yml增加服务配置

server:
  port: 8088
  #指定项目服务路径
  servlet:
    context-path: /api/v1

2. 在资源文件夹src/main/resources目录下添加文件company.graphqls

schema {
    query: CompanyQuery
}
type CompanyQuery {
    companyById(id: ID): Company
}
type Company {
    id: ID
    name: String
    age: Int
    address: String
    salary: Float
    joinDate: String
}

三配置GraphQLProvider,注册GraphQL

package com.zsx.graphql;

import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import graphql.GraphQL;
import graphql.schema.GraphQLSchema;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.idl.SchemaGenerator;
import graphql.schema.idl.SchemaParser;
import graphql.schema.idl.TypeDefinitionRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.net.URL;

import static graphql.schema.idl.TypeRuntimeWiring.newTypeWiring;

@Component
public class CompanyGraphQLProvider {

    private GraphQL graphQL;

    @Autowired
    private CompanyGraphQLDataFetchers graphQLDataFetchers;

    @Bean
    public GraphQL graphQL() {
        return graphQL;
    }

    @PostConstruct
    public void init() throws IOException {
        URL url = Resources.getResource("company.graphqls");
        String sdl = Resources.toString(url, Charsets.UTF_8);
        GraphQLSchema graphQLSchema = buildSchema(sdl);
        this.graphQL = GraphQL.newGraphQL(graphQLSchema).build();
    }

    private GraphQLSchema buildSchema(String sdl) {
        // TODO: we will create the schema here later
        TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(sdl);
        RuntimeWiring runtimeWiring = buildWiring();
        SchemaGenerator schemaGenerator = new SchemaGenerator();
        return schemaGenerator.makeExecutableSchema(typeRegistry, runtimeWiring);
    }


    private RuntimeWiring buildWiring() {
        return RuntimeWiring.newRuntimeWiring()
                .type(newTypeWiring("CompanyQuery")
                        .dataFetcher("companyById", graphQLDataFetchers.getCompanyByIdDataFetcher()))
                .build();
    }

}

 

四、配置GraphQLDataFetchers

package com.zsx.graphql;

import com.zsx.entity.Company;
import com.zsx.service.CompanyService;
import graphql.schema.DataFetcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CompanyGraphQLDataFetchers {

    @Autowired
    private CompanyService companyService;

    public DataFetcher getCompanyByIdDataFetcher() {
        List companies = companyService.getCompanies();
        return dataFetchingEnvironment -> {
            Long companyId  = Long.valueOf(dataFetchingEnvironment.getArgument("id"));
            return companies
                    .stream()
                    .filter(company -> company.getId().equals(companyId))
                    .findFirst()
                    .orElse(null);
        };
    }

}

五、编写业务接口

package com.zsx.service;

import com.zsx.entity.Company;

import java.util.List;

public interface CompanyService {

    List getCompanies();

}

六、编写业务实现

package com.zsx.service.impl;

import com.zsx.entity.Company;
import com.zsx.service.CompanyService;
import org.jooq.DSLContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private DSLContext dslContext;

    private com.zsx.generator.jooq.tables.Company company = com.zsx.generator.jooq.tables.Company.COMPANY.as("company");
    

    @Override
    public List getCompanies() {
        return dslContext.selectFrom(company).fetch().into(Company.class);
    }

}

七、启动主程序

E:\jdk\jdk-13.0.1\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:E:\JetBrains\IntelliJ IDEA 2019.2.3\lib\idea_rt.jar=65186:E:\JetBrains\IntelliJ IDEA 2019.2.3\bin" -Dfile.encoding=UTF-8 -classpath F:\IdeaProjects\postgres\target\classes;E:\maven\repository\org\springframework\boot\spring-boot-starter-web\2.2.0.RELEASE\spring-boot-starter-web-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter\2.2.0.RELEASE\spring-boot-starter-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-logging\2.2.0.RELEASE\spring-boot-starter-logging-2.2.0.RELEASE.jar;E:\maven\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;E:\maven\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;E:\maven\repository\org\apache\logging\log4j\log4j-to-slf4j\2.12.1\log4j-to-slf4j-2.12.1.jar;E:\maven\repository\org\apache\logging\log4j\log4j-api\2.12.1\log4j-api-2.12.1.jar;E:\maven\repository\org\slf4j\jul-to-slf4j\1.7.28\jul-to-slf4j-1.7.28.jar;E:\maven\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;E:\maven\repository\org\yaml\snakeyaml\1.25\snakeyaml-1.25.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-json\2.2.0.RELEASE\spring-boot-starter-json-2.2.0.RELEASE.jar;E:\maven\repository\com\fasterxml\jackson\core\jackson-databind\2.10.0\jackson-databind-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\core\jackson-annotations\2.10.0\jackson-annotations-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\core\jackson-core\2.10.0\jackson-core-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.10.0\jackson-datatype-jdk8-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.10.0\jackson-datatype-jsr310-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.10.0\jackson-module-parameter-names-2.10.0.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-tomcat\2.2.0.RELEASE\spring-boot-starter-tomcat-2.2.0.RELEASE.jar;E:\maven\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.27\tomcat-embed-core-9.0.27.jar;E:\maven\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.27\tomcat-embed-el-9.0.27.jar;E:\maven\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.27\tomcat-embed-websocket-9.0.27.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-validation\2.2.0.RELEASE\spring-boot-starter-validation-2.2.0.RELEASE.jar;E:\maven\repository\jakarta\validation\jakarta.validation-api\2.0.1\jakarta.validation-api-2.0.1.jar;E:\maven\repository\org\hibernate\validator\hibernate-validator\6.0.17.Final\hibernate-validator-6.0.17.Final.jar;E:\maven\repository\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;E:\maven\repository\com\fasterxml\classmate\1.5.0\classmate-1.5.0.jar;E:\maven\repository\org\springframework\spring-web\5.2.0.RELEASE\spring-web-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-beans\5.2.0.RELEASE\spring-beans-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-webmvc\5.2.0.RELEASE\spring-webmvc-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-context\5.2.0.RELEASE\spring-context-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-expression\5.2.0.RELEASE\spring-expression-5.2.0.RELEASE.jar;E:\maven\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.2\jakarta.xml.bind-api-2.3.2.jar;E:\maven\repository\org\springframework\spring-core\5.2.0.RELEASE\spring-core-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-jcl\5.2.0.RELEASE\spring-jcl-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-aop\2.2.0.RELEASE\spring-boot-starter-aop-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-aop\5.2.0.RELEASE\spring-aop-5.2.0.RELEASE.jar;E:\maven\repository\org\aspectj\aspectjweaver\1.9.4\aspectjweaver-1.9.4.jar;E:\maven\repository\com\graphql-java-kickstart\graphiql-spring-boot-starter\5.10.0\graphiql-spring-boot-starter-5.10.0.jar;E:\maven\repository\com\graphql-java-kickstart\graphiql-spring-boot-autoconfigure\5.10.0\graphiql-spring-boot-autoconfigure-5.10.0.jar;E:\maven\repository\org\apache\commons\commons-text\1.1\commons-text-1.1.jar;E:\maven\repository\org\apache\commons\commons-lang3\3.9\commons-lang3-3.9.jar;E:\maven\repository\com\graphql-java-kickstart\graphql-spring-boot-starter\5.10.0\graphql-spring-boot-starter-5.10.0.jar;E:\maven\repository\com\graphql-java-kickstart\graphql-spring-boot-autoconfigure\5.10.0\graphql-spring-boot-autoconfigure-5.10.0.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-websocket\2.2.0.RELEASE\spring-boot-starter-websocket-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-messaging\5.2.0.RELEASE\spring-messaging-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-websocket\5.2.0.RELEASE\spring-websocket-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-actuator\2.2.0.RELEASE\spring-boot-starter-actuator-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-actuator-autoconfigure\2.2.0.RELEASE\spring-boot-actuator-autoconfigure-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-actuator\2.2.0.RELEASE\spring-boot-actuator-2.2.0.RELEASE.jar;E:\maven\repository\io\micrometer\micrometer-core\1.3.0\micrometer-core-1.3.0.jar;E:\maven\repository\org\hdrhistogram\HdrHistogram\2.1.11\HdrHistogram-2.1.11.jar;E:\maven\repository\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar;E:\maven\repository\com\graphql-java-kickstart\graphql-java-servlet\8.0.0\graphql-java-servlet-8.0.0.jar;E:\maven\repository\javax\servlet\javax.servlet-api\4.0.1\javax.servlet-api-4.0.1.jar;E:\maven\repository\javax\websocket\javax.websocket-api\1.1\javax.websocket-api-1.1.jar;E:\maven\repository\commons-io\commons-io\2.6\commons-io-2.6.jar;E:\maven\repository\com\graphql-java-kickstart\graphql-java-tools\5.6.1\graphql-java-tools-5.6.1.jar;E:\maven\repository\org\jetbrains\kotlin\kotlin-stdlib\1.3.50\kotlin-stdlib-1.3.50.jar;E:\maven\repository\org\jetbrains\kotlin\kotlin-stdlib-common\1.3.50\kotlin-stdlib-common-1.3.50.jar;E:\maven\repository\org\jetbrains\annotations\13.0\annotations-13.0.jar;E:\maven\repository\org\jetbrains\kotlin\kotlin-reflect\1.3.50\kotlin-reflect-1.3.50.jar;E:\maven\repository\org\jetbrains\kotlinx\kotlinx-coroutines-jdk8\1.3.2\kotlinx-coroutines-jdk8-1.3.2.jar;E:\maven\repository\org\jetbrains\kotlinx\kotlinx-coroutines-core\1.3.2\kotlinx-coroutines-core-1.3.2.jar;E:\maven\repository\org\jetbrains\kotlinx\kotlinx-coroutines-reactive\1.3.2\kotlinx-coroutines-reactive-1.3.2.jar;E:\maven\repository\com\fasterxml\jackson\module\jackson-module-kotlin\2.10.0\jackson-module-kotlin-2.10.0.jar;E:\maven\repository\com\esotericsoftware\reflectasm\1.11.9\reflectasm-1.11.9.jar;E:\maven\repository\com\graphql-java\graphql-java-spring-boot-starter-webmvc\2019-06-24T11-47-27-31ab4f9\graphql-java-spring-boot-starter-webmvc-2019-06-24T11-47-27-31ab4f9.jar;E:\maven\repository\org\springframework\boot\spring-boot-autoconfigure\2.2.0.RELEASE\spring-boot-autoconfigure-2.2.0.RELEASE.jar;E:\maven\repository\com\graphql-java\graphql-java-spring-webmvc\2019-06-24T11-47-27-31ab4f9\graphql-java-spring-webmvc-2019-06-24T11-47-27-31ab4f9.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-jooq\2.2.0.RELEASE\spring-boot-starter-jooq-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-jdbc\2.2.0.RELEASE\spring-boot-starter-jdbc-2.2.0.RELEASE.jar;E:\maven\repository\com\zaxxer\HikariCP\3.4.1\HikariCP-3.4.1.jar;E:\maven\repository\org\springframework\spring-jdbc\5.2.0.RELEASE\spring-jdbc-5.2.0.RELEASE.jar;E:\maven\repository\jakarta\activation\jakarta.activation-api\1.2.1\jakarta.activation-api-1.2.1.jar;E:\maven\repository\org\springframework\spring-tx\5.2.0.RELEASE\spring-tx-5.2.0.RELEASE.jar;E:\maven\repository\org\jooq\jooq\3.12.2\jooq-3.12.2.jar;E:\maven\repository\org\jooq\jooq-meta\3.12.2\jooq-meta-3.12.2.jar;E:\maven\repository\org\jooq\jooq-codegen\3.12.2\jooq-codegen-3.12.2.jar;E:\maven\repository\org\flywaydb\flyway-core\6.0.7\flyway-core-6.0.7.jar;E:\maven\repository\org\glassfish\jaxb\jaxb-core\2.3.0.1\jaxb-core-2.3.0.1.jar;E:\maven\repository\javax\xml\bind\jaxb-api\2.3.1\jaxb-api-2.3.1.jar;E:\maven\repository\javax\activation\javax.activation-api\1.2.0\javax.activation-api-1.2.0.jar;E:\maven\repository\org\glassfish\jaxb\txw2\2.3.2\txw2-2.3.2.jar;E:\maven\repository\com\sun\istack\istack-commons-runtime\3.0.5\istack-commons-runtime-3.0.5.jar;E:\maven\repository\com\sun\xml\bind\jaxb-impl\2.3.2\jaxb-impl-2.3.2.jar;E:\maven\repository\org\postgresql\postgresql\42.2.8\postgresql-42.2.8.jar;E:\maven\repository\com\alibaba\fastjson\1.2.62\fastjson-1.2.62.jar;E:\maven\repository\org\projectlombok\lombok\1.18.10\lombok-1.18.10.jar;E:\maven\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.1.1\mybatis-spring-boot-starter-2.1.1.jar;E:\maven\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.1.1\mybatis-spring-boot-autoconfigure-2.1.1.jar;E:\maven\repository\org\mybatis\mybatis\3.5.3\mybatis-3.5.3.jar;E:\maven\repository\org\mybatis\mybatis-spring\2.0.3\mybatis-spring-2.0.3.jar;E:\maven\repository\com\graphql-java\graphql-java\2019-10-31T04-37-48-0919e71\graphql-java-2019-10-31T04-37-48-0919e71.jar;E:\maven\repository\org\antlr\antlr4-runtime\4.7.2\antlr4-runtime-4.7.2.jar;E:\maven\repository\org\slf4j\slf4j-api\1.7.28\slf4j-api-1.7.28.jar;E:\maven\repository\com\graphql-java\java-dataloader\2.2.3\java-dataloader-2.2.3.jar;E:\maven\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;E:\maven\repository\com\google\guava\guava\28.1-jre\guava-28.1-jre.jar;E:\maven\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;E:\maven\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;E:\maven\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;E:\maven\repository\org\checkerframework\checker-qual\2.8.1\checker-qual-2.8.1.jar;E:\maven\repository\com\google\errorprone\error_prone_annotations\2.3.2\error_prone_annotations-2.3.2.jar;E:\maven\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;E:\maven\repository\org\codehaus\mojo\animal-sniffer-annotations\1.18\animal-sniffer-annotations-1.18.jar;E:\maven\repository\org\springframework\boot\spring-boot-devtools\2.2.0.RELEASE\spring-boot-devtools-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot\2.2.0.RELEASE\spring-boot-2.2.0.RELEASE.jar com.zsx.PostgresApplication
Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.0.RELEASE)

2019-11-05 16:05:15.846  INFO 12960 --- [  restartedMain] com.zsx.PostgresApplication              : Starting PostgresApplication on DESKTOP-I29QKRP with PID 12960 (F:\IdeaProjects\postgres\target\classes started by 18273 in F:\IdeaProjects\postgres)
2019-11-05 16:05:15.848  INFO 12960 --- [  restartedMain] com.zsx.PostgresApplication              : No active profile set, falling back to default profiles: default
2019-11-05 16:05:15.883  INFO 12960 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in E:\maven\repository\org\glassfish\jaxb\jaxb-core\2.3.0.1\jaxb-core-2.3.0.1.jar referenced one or more files that do not exist: file:/E:/maven/repository/org/glassfish/jaxb/jaxb-core/2.3.0.1/jaxb-api-2.3.0.jar,file:/E:/maven/repository/org/glassfish/jaxb/jaxb-core/2.3.0.1/txw2-2.3.0.1.jar,file:/E:/maven/repository/org/glassfish/jaxb/jaxb-core/2.3.0.1/istack-commons-runtime-3.0.5.jar
2019-11-05 16:05:15.883  INFO 12960 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in E:\maven\repository\com\sun\xml\bind\jaxb-impl\2.3.2\jaxb-impl-2.3.2.jar referenced one or more files that do not exist: file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/jaxb-runtime-2.3.2.jar,file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/txw2-2.3.2.jar,file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/istack-commons-runtime-3.0.8.jar,file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/stax-ex-1.8.1.jar,file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/FastInfoset-1.2.16.jar,file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/jakarta.activation-api-1.2.1.jar
2019-11-05 16:05:15.883  INFO 12960 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-11-05 16:05:15.883  INFO 12960 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-11-05 16:05:16.565  INFO 12960 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-11-05 16:05:16.762  INFO 12960 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8088 (http)
2019-11-05 16:05:16.767  INFO 12960 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-11-05 16:05:16.767  INFO 12960 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.27]
2019-11-05 16:05:16.811  INFO 12960 --- [  restartedMain] o.a.c.c.C.[.[localhost].[/api/v1]        : Initializing Spring embedded WebApplicationContext
2019-11-05 16:05:16.811  INFO 12960 --- [  restartedMain] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 928 ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jooq.tools.reflect.Reflect (file:/E:/maven/repository/org/jooq/jooq/3.12.2/jooq-3.12.2.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class)
WARNING: Please consider reporting this to the maintainers of org.jooq.tools.reflect.Reflect
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-11-05 16:05:17.197  WARN 12960 --- [  restartedMain] com.zaxxer.hikari.HikariConfig           : HikariPool-1 - idleTimeout has been set but has no effect because the pool is operating as a fixed size pool.
2019-11-05 16:05:17.197  INFO 12960 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2019-11-05 16:05:17.246  INFO 12960 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2019-11-05 16:05:17.859  INFO 12960 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-11-05 16:05:18.050  INFO 12960 --- [  restartedMain] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 6.0.7 by Redgate
2019-11-05 16:05:18.055  INFO 12960 --- [  restartedMain] o.f.c.internal.database.DatabaseFactory  : Database: jdbc:postgresql://127.0.0.1:5432/mydb10 (PostgreSQL 12.0)
2019-11-05 16:05:18.068  INFO 12960 --- [  restartedMain] o.f.core.internal.command.DbValidate     : Successfully validated 2 migrations (execution time 00:00.008s)
2019-11-05 16:05:18.071  INFO 12960 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Current version of schema "myschema": 3
2019-11-05 16:05:18.071  INFO 12960 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Schema "myschema" is up to date. No migration necessary.
2019-11-05 16:05:18.129  INFO 12960 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2019-11-05 16:05:18.132  INFO 12960 --- [  restartedMain] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-11-05 16:05:18.293  INFO 12960 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8088 (http) with context path '/api/v1'
2019-11-05 16:05:18.294  INFO 12960 --- [  restartedMain] com.zsx.PostgresApplication              : Started PostgresApplication in 2.649 seconds (JVM running for 3.131)
2019-11-05 16:05:18.585  INFO 12960 --- [3)-192.168.56.1] o.a.c.c.C.[.[localhost].[/api/v1]        : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-11-05 16:05:18.585  INFO 12960 --- [3)-192.168.56.1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-11-05 16:05:18.594  INFO 12960 --- [3)-192.168.56.1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 9 ms

八、打开浏览器,查看请求:http://localhost:8088/api/v1/graphiql

springboot集成graphql(一)_第1张图片

九、输入查询条件,查看查询结果

springboot集成graphql(一)_第2张图片

从以上结果可以看出集成graphql成功

你可能感兴趣的:(graphql,springboot,database)