Example #1
0
    public static object?Handle(
        IExecutorContext context,
        ObjectDefinition objectDefinition,
        string fieldName,
        TypeBase fieldType,
        FieldSelection fieldSelection,
        object?completedValue,
        Exception error,
        NodePath path)
    {
        if (error is not QueryExecutionException)
        {
            error = new QueryExecutionException(
                "",
                error,
                path,
                fieldSelection);
        }

        if (fieldType is NonNullType)
        {
            throw error;
        }

        context.AddError(error);
        return(completedValue);
    }
Example #2
0
        public IEnumerable <TResource> EnumerateAll <TResource>(string query, AttributesToFetch attributes = null) where TResource : RmResource
        {
            attributes = attributes ?? AttributesToFetch.All;

            var ctx = LogContext.WithConfigFormat();

            Initialize();

            try
            {
                _log.Debug(ctx.Format("Executing simple enumeration: {0} with attributes {1}"), query, attributes.GetNames().ToJSON());

                var results = _defaultClient.Enumerate(query, attributes.GetNames())
                              .Cast <TResource>()
                              .ToList();

                log_query_executed(ctx, "Simple enumeration {0} returned {1} results", query, results.Count);

                return(results);
            }
            catch (Exception exc)
            {
                var qee = new QueryExecutionException(query, exc);

                _log.ErrorException(ctx.Format("Error when trying to execute query " + query), qee);

                throw qee;
            }
        }
Example #3
0
        public static object Handle(
            IExecutorContext context,
            ObjectType objectType,
            string fieldName,
            IType fieldType,
            GraphQLFieldSelection fieldSelection,
            object completedValue,
            Exception error,
            NodePath path)
        {
            if (!(error is QueryExecutionException))
            {
                error = new QueryExecutionException(
                    "",
                    error,
                    path,
                    fieldSelection);
            }

            if (fieldType is NonNull)
            {
                throw error;
            }

            context.AddError(error);
            return(completedValue);
        }
Example #4
0
        public DataPage <TResource> EnumeratePage <TResource>(string query, Pagination pagination, SortingInstructions sorting, AttributesToFetch attributes = null) where TResource : RmResource
        {
            if (pagination == null)
            {
                throw new ArgumentNullException("pagination");
            }
            if (sorting == null)
            {
                throw new ArgumentNullException("sorting");
            }

            try
            {
                return(ExecuteAdjustedQuery <TResource>(query, pagination, sorting, attributes));
            }
            catch (Exception exc)
            {
                var qee = new QueryExecutionException(query, exc);

                _log.ErrorException("Error when trying to execute query " + query, qee);

                throw qee;
            }
        }