com.networknt.graphql.router.GraphqlEndpointSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphql-router Show documentation
Show all versions of graphql-router Show documentation
A route handler for GraphQL endpoint
The newest version!
package com.networknt.graphql.router;
import com.networknt.graphql.common.GraphqlUtil;
import com.networknt.handler.config.EndpointSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
/**
* Lists standard GraphQl endpoints at /graphql (or as reconfigured in Graphql.config)
*/
public class GraphqlEndpointSource implements EndpointSource {
private static final Logger log = LoggerFactory.getLogger(GraphqlEndpointSource.class);
@Override
public Iterable listEndpoints() {
String graphqlPath = GraphqlUtil.config.getPath();
if(log.isInfoEnabled()) log.info("Generating " + graphqlPath + " from graphql.yml");
return Arrays.asList(
new Endpoint(graphqlPath, "GET"),
new Endpoint(graphqlPath, "POST"),
new Endpoint(graphqlPath, "OPTIONS")
// The subscriptions websocket endpoint does not need to be listed
);
}
}