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
FieldsModifier and TypeFieldDescriptionprotected StringThe name of the file containing the content-type definitionprotected graphql.schema.DataFetcher<?> TheDataFetcherto use for queriesprotected booleanprotected ExecutorTheExecutorto use for new threadsprotected StringThe path to look for content-type definitionsprotected StringThe name for the root Query typeprotected StringThe path of the init script for custom fields & fetchersprotected jakarta.servlet.ServletContextThe servlet contextprotected GraphQLTypeFactoryTheGraphQLTypeFactoryto use for all content-typesstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionGraphQLFactoryImpl(String schemaScriptPath, String repoConfigFolder, String contentTypeDefinitionName, String rootQueryTypeName, GraphQLTypeFactory typeFactory, graphql.schema.DataFetcher<?> dataFetcher, Executor jobThreadPoolExecutor) -
Method Summary
Modifier and TypeMethodDescriptionprotected graphql.schema.GraphQLSchemabuildSchema(SiteContext siteContext) Creates the root Query type and looks for all existing content-type definitionsprotected voidfindContentTypes(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.GraphQLgetInstance(SiteContext siteContext) Returns the instance for the givenSiteContextprotected voidrunInitScript(SiteContext siteContext, graphql.schema.GraphQLObjectType.Builder rootType, graphql.schema.GraphQLCodeRegistry.Builder codeRegistry, SchemaCustomizer customizer, Map<String, graphql.schema.GraphQLObjectType.Builder> siteTypes) voidsetDisableVariableRestrictions(boolean disableVariableRestrictions) voidsetServletContext(jakarta.servlet.ServletContext servletContext)
-
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
TheGraphQLTypeFactoryto use for all content-types -
dataFetcher
protected graphql.schema.DataFetcher<?> dataFetcherTheDataFetcherto use for queries -
jobThreadPoolExecutor
TheExecutorto use for new threads -
servletContext
protected jakarta.servlet.ServletContext servletContextThe servlet context -
disableVariableRestrictions
protected boolean disableVariableRestrictions
-
-
Constructor Details
-
GraphQLFactoryImpl
-
-
Method Details
-
setServletContext
public void setServletContext(jakarta.servlet.ServletContext servletContext) - Specified by:
setServletContextin 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
GraphQLSchemainstance
-
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:
getInstancein interfaceGraphQLFactory- Parameters:
siteContext- the site context used to build theGraphQLSchema- Returns:
- a
GraphQLinstance
-