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 Details

    • VARIABLE_SCHEMA

      public static final String VARIABLE_SCHEMA
      See Also:
    • 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
      The GraphQLTypeFactory to use for all content-types
    • dataFetcher

      protected graphql.schema.DataFetcher<?> dataFetcher
      The DataFetcher to use for queries
    • jobThreadPoolExecutor

      protected Executor jobThreadPoolExecutor
      The Executor to use for new threads
    • servletContext

      protected jakarta.servlet.ServletContext servletContext
      The servlet context
    • disableVariableRestrictions

      protected boolean disableVariableRestrictions
  • Constructor Details

    • GraphQLFactoryImpl

      public GraphQLFactoryImpl(String schemaScriptPath, String repoConfigFolder, String contentTypeDefinitionName, String rootQueryTypeName, GraphQLTypeFactory typeFactory, graphql.schema.DataFetcher<?> dataFetcher, Executor jobThreadPoolExecutor)
  • Method Details

    • setServletContext

      public void setServletContext(jakarta.servlet.ServletContext servletContext)
      Specified by:
      setServletContext in interface org.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 given SiteContext
      Specified by:
      getInstance in interface GraphQLFactory
      Parameters:
      siteContext - the site context used to build the GraphQLSchema
      Returns:
      a GraphQL instance