コード例 #1
0
        private IGraphType CreateGraphType(OperationType operationType, IEnumerable <GraphOperationDescriptor> operations)
        {
            var graphType = new GraphType(operationType);

            if (operations == null)
            {
                return(graphType);
            }
            foreach (var operation in operations)
            {
                var resolver = new OperationResolver(operation, _binderProvider);
                var type     = _graphTypeProvider.GetGraphType(operation.MethodInfo.ReturnType, null, null);

                var field = new GraphField(operation.Name, type, typeof(void), resolver);
                foreach (var parameter in operation.Parameters.Values)
                {
                    if (!parameter.IsGraphArgument)
                    {
                        continue;
                    }
                    var parameterGraphType = _graphTypeProvider.GetGraphType(parameter.ParameterInfo.ParameterType, parameter.IsRequired, null);
                    field.AddArgument(new NamedGraphType(parameter.ArgumentName, parameterGraphType));
                }

                graphType.AddField(typeof(void), field);
            }
            return(graphType);
        }
コード例 #2
0
        private void AddEntityField <TEntity>(GraphType query, IEntityType entityType, FieldResolver resolver)
            where TEntity : class
        {
            CreateEntityGraphType <TEntity>(entityType);

            // TODO use a different resolver when this is a nav prop
            query.AddField <ObjectGraphType <TEntity> >(
                entityType.GraphQL().FieldName,
                entityType.GraphQL().Description,
                resolver);
        }
コード例 #3
0
        private FieldType AddEntityCollectionField <TEntity>(GraphType query, IEntityType entityType, FieldResolver resolver)
            where TEntity : class
        {
            CreateEntityGraphType <TEntity>(entityType);

            var listFieldName = entityType.GraphQL().PluralFieldName;

            return(query.AddField <ListGraphType <ObjectGraphType <TEntity> > >(
                       listFieldName,
                       entityType.GraphQL().PluralDescription,
                       resolver));
        }