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 ofGraphQLFactory
that creates aGraphQLSchema
from the content-type definitions found in the site repository- Since:
- 3.1
- Author:
- joseross
-
-
Field Summary
Fields Modifier and Type Field Description protected String
contentTypeDefinitionName
The name of the file containing the content-type definitionprotected graphql.schema.DataFetcher<?>
dataFetcher
TheDataFetcher
to use for queriesprotected boolean
disableVariableRestrictions
protected Executor
jobThreadPoolExecutor
TheExecutor
to use for new threadsprotected String
repoConfigFolder
The path to look for content-type definitionsprotected String
rootQueryTypeName
The name for the root Query typeprotected String
schemaScriptPath
The path of the init script for custom fields & fetchersprotected javax.servlet.ServletContext
servletContext
The servlet contextprotected GraphQLTypeFactory
typeFactory
TheGraphQLTypeFactory
to use for all content-typesstatic String
VARIABLE_SCHEMA
-
Constructor Summary
Constructors Constructor Description GraphQLFactoryImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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 Detail
-
VARIABLE_SCHEMA
public static final String VARIABLE_SCHEMA
- See Also:
- Constant Field Values
-
schemaScriptPath
protected String schemaScriptPath
The path of the init script for custom fields & fetchers
-
repoConfigFolder
protected String repoConfigFolder
The path to look for content-type definitions
-
contentTypeDefinitionName
protected String contentTypeDefinitionName
The name of the file containing the content-type definition
-
rootQueryTypeName
protected String rootQueryTypeName
The name for the root Query type
-
typeFactory
protected GraphQLTypeFactory typeFactory
TheGraphQLTypeFactory
to use for all content-types
-
dataFetcher
protected graphql.schema.DataFetcher<?> dataFetcher
TheDataFetcher
to use for queries
-
servletContext
protected javax.servlet.ServletContext servletContext
The servlet context
-
disableVariableRestrictions
protected boolean disableVariableRestrictions
-
-
Method Detail
-
setSchemaScriptPath
public void setSchemaScriptPath(String schemaScriptPath)
-
setRepoConfigFolder
public void setRepoConfigFolder(String repoConfigFolder)
-
setContentTypeDefinitionName
public void setContentTypeDefinitionName(String contentTypeDefinitionName)
-
setRootQueryTypeName
public void setRootQueryTypeName(String rootQueryTypeName)
-
setTypeFactory
public void setTypeFactory(GraphQLTypeFactory typeFactory)
-
setDataFetcher
public void setDataFetcher(graphql.schema.DataFetcher<?> dataFetcher)
-
setJobThreadPoolExecutor
public void setJobThreadPoolExecutor(Executor jobThreadPoolExecutor)
-
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
protected graphql.schema.GraphQLSchema buildSchema(SiteContext siteContext)
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
public graphql.GraphQL getInstance(SiteContext siteContext)
Returns the instance for the givenSiteContext
- Specified by:
getInstance
in interfaceGraphQLFactory
- Parameters:
siteContext
- the site context used to build theGraphQLSchema
- Returns:
- a
GraphQL
instance
-
-