Class GraphQLFactoryImpl
java.lang.Object
org.craftercms.engine.graphql.impl.GraphQLFactoryImpl
- All Implemented Interfaces:
GraphQLFactory
,org.springframework.beans.factory.Aware
,org.springframework.web.context.ServletContextAware
public class GraphQLFactoryImpl
extends Object
implements GraphQLFactory, org.springframework.web.context.ServletContextAware
Default implementation of
GraphQLFactory
that creates a GraphQLSchema
from the content-type
definitions found in the site repository- Since:
- 3.1
- Author:
- joseross
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The name of the file containing the content-type definitionprotected graphql.schema.DataFetcher<?>
TheDataFetcher
to use for queriesprotected boolean
protected Executor
TheExecutor
to use for new threadsprotected String
The path to look for content-type definitionsprotected String
The name for the root Query typeprotected String
The path of the init script for custom fields & fetchersprotected javax.servlet.ServletContext
The servlet contextprotected GraphQLTypeFactory
TheGraphQLTypeFactory
to use for all content-typesstatic final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected graphql.schema.GraphQLSchema
buildSchema
(SiteContext siteContext) Creates the root Query type and looks for all existing content-type definitionsprotected void
findContentTypes
(org.craftercms.core.service.Tree item, graphql.schema.GraphQLObjectType.Builder rootType, graphql.schema.GraphQLCodeRegistry.Builder codeRegistry, graphql.schema.DataFetcher<?> dataFetcher, Map<String, graphql.schema.GraphQLObjectType.Builder> siteTypes) Recursively looks for content-type definitionsgraphql.GraphQL
getInstance
(SiteContext siteContext) Returns the instance for the givenSiteContext
protected void
runInitScript
(SiteContext siteContext, graphql.schema.GraphQLObjectType.Builder rootType, graphql.schema.GraphQLCodeRegistry.Builder codeRegistry, SchemaCustomizer customizer, Map<String, graphql.schema.GraphQLObjectType.Builder> siteTypes) void
setContentTypeDefinitionName
(String contentTypeDefinitionName) void
setDataFetcher
(graphql.schema.DataFetcher<?> dataFetcher) void
setDisableVariableRestrictions
(boolean disableVariableRestrictions) void
setJobThreadPoolExecutor
(Executor jobThreadPoolExecutor) void
setRepoConfigFolder
(String repoConfigFolder) void
setRootQueryTypeName
(String rootQueryTypeName) void
setSchemaScriptPath
(String schemaScriptPath) void
setServletContext
(javax.servlet.ServletContext servletContext) void
setTypeFactory
(GraphQLTypeFactory typeFactory)
-
Field Details
-
VARIABLE_SCHEMA
- See Also:
-
schemaScriptPath
The path of the init script for custom fields & fetchers -
repoConfigFolder
The path to look for content-type definitions -
contentTypeDefinitionName
The name of the file containing the content-type definition -
rootQueryTypeName
The name for the root Query type -
typeFactory
TheGraphQLTypeFactory
to use for all content-types -
dataFetcher
protected graphql.schema.DataFetcher<?> dataFetcherTheDataFetcher
to use for queries -
jobThreadPoolExecutor
TheExecutor
to use for new threads -
servletContext
protected javax.servlet.ServletContext servletContextThe servlet context -
disableVariableRestrictions
protected boolean disableVariableRestrictions
-
-
Constructor Details
-
GraphQLFactoryImpl
public GraphQLFactoryImpl()
-
-
Method Details
-
setSchemaScriptPath
-
setRepoConfigFolder
-
setContentTypeDefinitionName
-
setRootQueryTypeName
-
setTypeFactory
-
setDataFetcher
public void setDataFetcher(graphql.schema.DataFetcher<?> dataFetcher) -
setJobThreadPoolExecutor
-
setServletContext
public void setServletContext(javax.servlet.ServletContext servletContext) - Specified by:
setServletContext
in interfaceorg.springframework.web.context.ServletContextAware
-
setDisableVariableRestrictions
public void setDisableVariableRestrictions(boolean disableVariableRestrictions) -
findContentTypes
protected void findContentTypes(org.craftercms.core.service.Tree item, graphql.schema.GraphQLObjectType.Builder rootType, graphql.schema.GraphQLCodeRegistry.Builder codeRegistry, graphql.schema.DataFetcher<?> dataFetcher, Map<String, graphql.schema.GraphQLObjectType.Builder> siteTypes) Recursively looks for content-type definitions -
buildSchema
Creates the root Query type and looks for all existing content-type definitions- Parameters:
siteContext
- the site context- Returns:
- the
GraphQLSchema
instance
-
runInitScript
protected void runInitScript(SiteContext siteContext, graphql.schema.GraphQLObjectType.Builder rootType, graphql.schema.GraphQLCodeRegistry.Builder codeRegistry, SchemaCustomizer customizer, Map<String, graphql.schema.GraphQLObjectType.Builder> siteTypes) -
getInstance
Returns the instance for the givenSiteContext
- Specified by:
getInstance
in interfaceGraphQLFactory
- Parameters:
siteContext
- the site context used to build theGraphQLSchema
- Returns:
- a
GraphQL
instance
-