public GraphQLModel(IAppEntity app,
                            IEnumerable <ISchemaEntity> schemas,
                            int pageSizeContents,
                            int pageSizeAssets,
                            IUrlGenerator urlGenerator, ISemanticLog log)
        {
            this.log = log;

            partitionResolver = app.PartitionResolver();

            CanGenerateAssetSourceUrl = urlGenerator.CanGenerateAssetSourceUrl;

            assetType     = new AssetGraphType(this);
            assetListType = new ListGraphType(new NonNullGraphType(assetType));

            graphQLTypeVisitor = new GraphQLTypeVisitor(contentTypes, this, assetListType);

            var allSchemas = schemas.Where(x => x.SchemaDef.IsPublished).ToList();

            BuildSchemas(allSchemas);

            graphQLSchema = BuildSchema(this, pageSizeContents, pageSizeAssets, allSchemas);
            graphQLSchema.RegisterValueConverter(JsonConverter.Instance);
            graphQLSchema.RegisterValueConverter(InstantConverter.Instance);

            InitializeContentTypes(allSchemas, pageSizeContents);
        }
Beispiel #2
0
        public GraphQLSchema BuildSchema(IEnumerable <ISchemaEntity> schemas)
        {
            var schemaInfos = SchemaInfo.Build(schemas).ToList();

            foreach (var schemaInfo in schemaInfos)
            {
                var contentType = new ContentGraphType(this, schemaInfo);

                contentTypes[schemaInfo]       = contentType;
                contentResultTypes[schemaInfo] = new ContentResultGraphType(contentType, schemaInfo);
            }

            var newSchema = new GraphQLSchema
            {
                Query = new AppQueriesGraphType(this, schemaInfos)
            };

            newSchema.RegisterValueConverter(JsonConverter.Instance);
            newSchema.RegisterValueConverter(InstantConverter.Instance);

            newSchema.RegisterType(sharedTypes.ContentInterface);

            if (schemas.Any())
            {
                newSchema.Mutation = new AppMutationsGraphType(this, schemaInfos);
            }

            foreach (var(schemaInfo, contentType) in contentTypes)
            {
                contentType.Initialize(this, schemaInfo, schemaInfos);
            }

            foreach (var contentType in contentTypes.Values)
            {
                newSchema.RegisterType(contentType);
            }

            newSchema.Initialize();
            newSchema.CleanupMetadata();

            return(newSchema);
        }
Beispiel #3
0
        public GraphQLModel(IAppEntity app, IEnumerable <ISchemaEntity> schemas, GraphQLTypeFactory typeFactory, ISemanticLog log)
        {
            graphQLTypeFactory = typeFactory;

            this.log = log;

            partitionResolver = app.PartitionResolver();

            typeVisitor = new GraphQLTypeVisitor(contentTypes, this);

            var allSchemas = schemas.Where(x => x.SchemaDef.IsPublished).ToList();

            BuildSchemas(allSchemas);

            graphQLSchema = BuildSchema(this, allSchemas);
            graphQLSchema.RegisterValueConverter(JsonConverter.Instance);
            graphQLSchema.RegisterValueConverter(InstantConverter.Instance);

            InitializeContentTypes(allSchemas);

            partitionResolver = null !;

            typeVisitor = null !;
        }
Beispiel #4
0
        public GraphQLModel(IAppEntity app, IEnumerable <ISchemaEntity> schemas, IGraphQLUrlGenerator urlGenerator)
        {
            this.app = app;

            partitionResolver = app.PartitionResolver();

            CanGenerateAssetSourceUrl = urlGenerator.CanGenerateAssetSourceUrl;

            assetType     = new AssetGraphType(this);
            assetListType = new ListGraphType(new NonNullGraphType(assetType));

            schemasById = schemas.ToDictionary(x => x.Id);

            graphQLSchema = BuildSchema(this);
            graphQLSchema.RegisterValueConverter(JsonConverter.Instance);

            InitializeContentTypes();
        }