Class 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 Detail

      • 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
      • 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 javax.servlet.ServletContext servletContext
        The servlet context
      • disableVariableRestrictions

        protected boolean disableVariableRestrictions
    • Constructor Detail

      • GraphQLFactoryImpl

        public GraphQLFactoryImpl()
    • 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)
      • 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 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