简体   繁体   中英

Persisted queries in SPQR GraphQL

GraphQL-SPQR是否支持PersistedQueries,如果不是,建议的处理SPQR中持久化查询的方式是什么。

I presume you're referring to SPQR Spring Starter here. It currently does not have this feature built-in. I believe only Apollo Engine (Link?) does. But you should be able to use it with any GraphQL server.

A post from Apollo blog says:

Automatic persisted queries — a built-in feature when using Apollo Link and Engine, works with any client or server

So you could have your SPQR-based server behind Apollo Engine, and get this and other features it offers.

I think you could also implement this specific feature yourself, relatively easily. As of v0.0.4 of SPQR Spring Starter you can replace the GraphQLServletExecutor (or GraphQLReactiveExecutor if you're using WebFlux, or GraphQLWebSocketExecutor if you're using subscriptions):

@Bean
public GraphQLServletExecutor graphQLExecutor(ServletContextFactory contextFactory) {
    return new CustomExecutorThatPersistsQueries();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM