public ComplexGraphType <TModel> BuildGraphType(GraphTypeCache cache, IServiceCollection services) { var graphType = CreateGraphTypeCore(cache, services); graphType.Name = GraphTypeName; graphType.Description = typeof(TModel).GetCustomAttribute <DescriptionAttribute>()?.Description; if (!cache.TryPrime(graphType)) { return(cache.GetOrCreate <TModel> (services)); } foreach (var prop in typeof(TModel).GetProperties().Where(x => !_config.IsPropertyIgnored(x))) { var fieldConfig = _config.GetFieldConfig(prop); fieldConfig.ConfigureField(graphType, cache, services); } if (graphType is ObjectGraphType <TModel> objectGraphType) { foreach (var iFace in _config.Interfaces) { objectGraphType.AddResolvedInterface((IInterfaceGraphType)cache.GetOrCreate(iFace, services)); } } return(graphType); }
public QueryArguments BuildQueryArguments(GraphTypeCache cache, IServiceCollection services) { var args = typeof(TModel) .GetProperties() .Except(_config.PropsToIgnore) .Select(prop => ToQueryArgument(prop, cache)); return(new QueryArguments(args)); }
public InputObjectGraphType <TModel> BuildInputGraphType(GraphTypeCache cache) { var graphType = new InputObjectGraphType <TModel> { Name = GraphTypeName + "Input" }; if (!cache.TryPrimeInput(graphType)) { return((InputObjectGraphType <TModel>)cache.GetOrCreateInputType(typeof(TModel))); } foreach (var prop in typeof(TModel).GetProperties().Except(_config.PropsToIgnore)) { var fieldConfig = _config.GetFieldConfig(prop); fieldConfig.ConfigureInputTypeField(graphType, cache); } return(graphType); }
public OttoSchemaInfo Build(IServiceCollection services) { var cache = new GraphTypeCache(_builders, _scalarTypeMap); var queryType = _schemaType.GetGenericArguments().First(); var mutationType = _schemaType.GetGenericArguments().Skip(1).First(); var queryGraphType = cache.GetOrCreate(queryType, services); var mutationGraphType = cache.GetOrCreate(mutationType, services); var otherTypes = _builders.Values .Where(x => x.NeedsRegistration) .Select(x => x.BuildGraphType(cache, services)) .ToArray(); cache.ValidateNoDuplicates(); services.AddTransient(typeof(CustomScalarGraphType <,>)); var schema = new OttoSchemaInfo((IObjectGraphType)queryGraphType, (IObjectGraphType)mutationGraphType, null, otherTypes); return(schema); }
IComplexGraphType IGraphTypeBuilder.BuildGraphType(GraphTypeCache cache, IServiceCollection services) => BuildGraphType(cache, services);