private Schema TypeSchemaFactory(Type type, ISchemaRepository schemaRepository)
        {
            var schema = GetSchemaIfPrimitive(type);

            if (schema != null)
            {
                return(schema);
            }

            schema = GetSchemaIfEnumerable(type, schemaRepository);
            if (schema != null)
            {
                return(schema);
            }

            var filter = _options.PropertyFilter ?? ((_) => true);

            var propertyAndFieldMembers = type.GetProperties()
                                          .Where(filter)
                                          .Cast <MemberInfo>()
                                          .Concat(type.GetFields()).ToArray();

            return(CreateSchemaFromPropertyAndFieldMembers(schemaRepository, propertyAndFieldMembers));
        }
Example #2
0
        protected override GraphQLValue GetAst(object value, ISchemaRepository schemaRepository)
        {
            if (value is bool)
            {
                value = value.ToString().ToLower();
            }

            var stringValue = value.ToString();

            if (stringValue.ParseIntOrGiveNull() != null)
            {
                return new GraphQLScalarValue(ASTNodeKind.IntValue)
                       {
                           Value = stringValue
                       }
            }
            ;

            return(new GraphQLScalarValue(ASTNodeKind.StringValue)
            {
                Value = Regex.Escape(stringValue)
            });
        }
    }
Example #3
0
 public IQueryable <SchemaVersion> GetSchemaVersions(
     [Service] ISchemaRepository repository) =>
 repository.GetSchemaVersions();
Example #4
0
 public IQueryable <SchemaPublishReport> GetPublishReports(
     [Parent] SchemaVersion schemaVersion,
     [Service] ISchemaRepository repository) =>
 repository.GetPublishReports().Where(t => t.SchemaVersionId == schemaVersion.Id);
Example #5
0
 protected abstract GraphQLBaseType GetSchemaType(Type type, ISchemaRepository schemaRepository);
Example #6
0
 public OperationFilterContext(MethodInfo method, ISchemaRepository schemaRepository, OperationAttribute operation)
 {
     Method           = method;
     SchemaRepository = schemaRepository;
     Operation        = operation;
 }
Example #7
0
 public ChannelItemFilterContext(MethodInfo method, ISchemaRepository schemaRepository, ChannelAttribute channel)
 {
     Method           = method;
     SchemaRepository = schemaRepository;
     Channel          = channel;
 }
 public KnownArgumentNamesVisitor(IGraphQLSchema schema) : base(schema)
 {
     this.schemaRepository = schema.SchemaRepository;
     this.Errors           = new List <GraphQLException>();
 }
Example #9
0
        /// <summary>
        /// Generate the Channels section of the AsyncApi schema from the <see cref="ChannelAttribute"/> on classes.
        /// </summary>
        private Channels GenerateChannelsFromClasses(IEnumerable <TypeInfo> asyncApiTypes, ISchemaRepository schemaRepository)
        {
            var channels = new Channels();

            var classesWithChannelAttribute = asyncApiTypes
                                              .Select(type => new
            {
                Channel = type.GetCustomAttribute <ChannelAttribute>(),
                Type    = type,
            })
                                              .Where(cc => cc.Channel != null);

            foreach (var cc in classesWithChannelAttribute)
            {
                var channelItem = new ChannelItem
                {
                    Description = cc.Channel.Description,
                    Parameters  = cc.Channel.Parameters,
                    Publish     = GenerateOperationFromClass(cc.Type, schemaRepository, OperationType.Publish),
                    Subscribe   = GenerateOperationFromClass(cc.Type, schemaRepository, OperationType.Subscribe),
                };

                channels.Add(cc.Channel.Name, channelItem);

                var context = new ChannelItemFilterContext(cc.Type, schemaRepository, cc.Channel);
                foreach (var filter in _options.ChannelItemFilters)
                {
                    filter.Apply(channelItem, context);
                }
            }

            return(channels);
        }
Example #10
0
        /// <summary>
        /// Generate the Channels section of the AsyncApi schema from the <see cref="ChannelAttribute"/> on methods.
        /// </summary>
        private Channels GenerateChannelsFromMethods(IEnumerable <TypeInfo> asyncApiTypes, ISchemaRepository schemaRepository)
        {
            var channels = new Channels();

            var methodsWithChannelAttribute = asyncApiTypes
                                              .SelectMany(type => type.DeclaredMethods)
                                              .Select(method => new
            {
                Channel = method.GetCustomAttribute <ChannelAttribute>(),
                Method  = method,
            })
                                              .Where(mc => mc.Channel != null);

            foreach (var mc in methodsWithChannelAttribute)
            {
                var channelItem = new ChannelItem
                {
                    Description = mc.Channel.Description,
                    Parameters  = mc.Channel.Parameters,
                    Publish     = GenerateOperationFromMethod(mc.Method, schemaRepository, OperationType.Publish),
                    Subscribe   = GenerateOperationFromMethod(mc.Method, schemaRepository, OperationType.Subscribe),
                };
                channels.Add(mc.Channel.Name, channelItem);

                var context = new ChannelItemFilterContext(mc.Method, schemaRepository, mc.Channel);
                foreach (var filter in _options.ChannelItemFilters)
                {
                    filter.Apply(channelItem, context);
                }
            }

            return(channels);
        }
Example #11
0
        private Message GenerateMessageFromAttribute(MessageAttribute messageAttribute, ISchemaRepository schemaRepository)
        {
            if (messageAttribute?.PayloadType == null)
            {
                return(null);
            }

            var message = new Message
            {
                Payload     = _schemaGenerator.GenerateSchema(messageAttribute.PayloadType, schemaRepository),
                Name        = messageAttribute.Name ?? _options.SchemaIdSelector(messageAttribute.PayloadType),
                Title       = messageAttribute.Title,
                Summary     = messageAttribute.Summary,
                Description = messageAttribute.Description,
            };

            return(message);
        }
Example #12
0
 public IQueryable <SchemaVersion> GetVersions(
     [Parent] Schema schema,
     [Service] ISchemaRepository repository) =>
 repository.GetSchemaVersions().Where(t => t.SchemaId == schema.Id);
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateAssetCommandHandler" /> class.
 /// </summary>
 /// <param name="schemaRepository">The schema repository.</param>
 /// <param name="eventBus">The event bus.</param>
 public CreateAssetCommandHandler(ISchemaRepository schemaRepository, IEventBus eventBus)
 {
     _schemaRepository = schemaRepository;
     _eventBus         = eventBus;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateSchemaTaskEventCommandHandler"/> class.
 /// </summary>
 /// <param name="repository">The repository.</param>
 public CreateSchemaTaskEventCommandHandler(ISchemaRepository repository, IEventBus eventBus)
 {
     this._repository = repository;
     this._eventBus   = eventBus;
 }
Example #15
0
 public Migrator(IDatabaseConnection dbConnection, MigratorOptions options)
 {
     DbConnection     = dbConnection;
     SchemaRepository = new SchemaRepository(dbConnection);
     Options          = options;
 }
Example #16
0
 public KnownTypeNamesVisitor(IGraphQLSchema schema)
 {
     this.schemaRepository = schema.SchemaRepository;
     this.Errors           = new List <GraphQLException>();
 }
 internal ComplexIntrospectedType(ISchemaRepository schemaRepository, GraphQLComplexType type)
 {
     this.schemaRepository = schemaRepository;
     this.type             = type;
 }
Example #18
0
 public SchemasCacheGrain(ISchemaRepository schemaRepository)
 {
     this.schemaRepository = schemaRepository;
 }
Example #19
0
 public DbScriptsService(ISchemaRepository schemaRepository)
 {
     _schemaRepository = schemaRepository ?? throw new ArgumentNullException(nameof(schemaRepository));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateTaskTransitionCommandHandler" /> class.
 /// </summary>
 /// <param name="repository">The repository.</param>
 /// <param name="eventBus">The event bus.</param>
 public CreateTaskTransitionCommandHandler(ISchemaRepository repository, IEventBus eventBus)
 {
     _repository = repository;
     _eventBus   = eventBus;
 }
Example #21
0
 public SchemasController(ISchemaRepository schemaRepository)
 {
     _schemaRepository = schemaRepository;
 }
Example #22
0
 public SchemaHandler(ISchemaRepository schemaRepository)
 {
     _schemaRepository = schemaRepository ?? throw new ArgumentNullException(nameof(schemaRepository));
 }
Example #23
0
 public GraphQLBaseType GetGraphQLType(ISchemaRepository schemaRepository)
 {
     return(this.GetSchemaType(this.SystemType, schemaRepository));
 }
        private Message GenerateMessage(MethodInfo method, OperationAttribute operationAttribute, ISchemaRepository schemaRepository)
        {
            var message = new Message
            {
                Payload = _schemaGenerator.GenerateSchema(operationAttribute.MessagePayloadType, schemaRepository),
                // todo: all the other properties... message has a lot!
            };

            return(message);
        }
Example #25
0
 public SchemasController(ICommandBus commandBus, ISchemaRepository schemaRepository)
     : base(commandBus)
 {
     this.schemaRepository = schemaRepository;
 }
Example #26
0
 public CreateSchemaEventCommandHandler(ISchemaRepository repository, IEventBus eventBus)
 {
     _repository = repository;
     _eventBus   = eventBus;
 }
Example #27
0
 public Task <SchemaVersion?> GetSchemaVersionByExternalIdAsync(
     string externalId,
     [Service] ISchemaRepository repository,
     CancellationToken cancellationToken) =>
 repository.GetSchemaVersionByExternalIdAsync(externalId, cancellationToken);
Example #28
0
 public abstract Result GetValueFromAst(GraphQLValue astValue, ISchemaRepository schemaRepository);
 protected override GraphQLBaseType GetSchemaType(Type type, ISchemaRepository schemaRepository)
 {
     return(schemaRepository.GetSchemaTypeFor(type));
 }
Example #30
0
 protected abstract GraphQLValue GetAst(object value, ISchemaRepository schemaRepository);