-
Notifications
You must be signed in to change notification settings - Fork 63
Closed
Milestone
Description
I want to handle some of my own exceptions, but I can't do it yet, it seems like the system's try-catch feature is preventing it.
I found it in the source code
private async Task<QueryResult> DoExecuteRequestAsync(QueryRequest gql, TContextType? overwriteContext, IServiceProvider? serviceProvider, ClaimsPrincipal? user, ExecutionOptions? options)
{
try
{
if (options == null)
{
options = new ExecutionOptions();
}
GraphQLDocument graphQLDocument = null;
if (options!.EnablePersistedQueries)
{
PersistedQueryExtension persistedQueryExtension = (PersistedQueryExtension)ExpressionUtil.ChangeType(gql.Extensions.GetValueOrDefault("persistedQuery"), typeof(PersistedQueryExtension), null);
if (persistedQueryExtension != null && persistedQueryExtension.Version != 1)
{
throw new EntityGraphQLExecutionException("PersistedQueryNotSupported");
}
string text = persistedQueryExtension?.Sha256Hash;
if (text == null && gql.Query == null)
{
throw new EntityGraphQLExecutionException("Please provide a persisted query hash or a query string");
}
if (text != null)
{
graphQLDocument = queryCache.GetCompiledQueryWithHash(text);
if (graphQLDocument == null && gql.Query == null)
{
throw new EntityGraphQLExecutionException("PersistedQueryNotFound");
}
if (graphQLDocument == null)
{
graphQLDocument = graphQLCompiler.Compile(gql, new QueryRequestContext(AuthorizationService, user));
queryCache.AddCompiledQuery(text, graphQLDocument);
}
}
else if (graphQLDocument == null)
{
graphQLDocument = ((!options!.EnableQueryCache) ? graphQLCompiler.Compile(gql, new QueryRequestContext(AuthorizationService, user)) : CompileQueryWithCache(gql, user));
}
}
else if (options!.EnableQueryCache)
{
graphQLDocument = CompileQueryWithCache(gql, user);
}
else
{
if (gql.Query == null)
{
if (((PersistedQueryExtension)ExpressionUtil.ChangeType(gql.Extensions.GetValueOrDefault("persistedQuery"), typeof(PersistedQueryExtension), null))?.Sha256Hash != null)
{
throw new EntityGraphQLExecutionException("PersistedQueryNotSupported");
}
throw new ArgumentNullException("Query", "Query must be set unless you are using persisted queries");
}
graphQLDocument = graphQLCompiler.Compile(gql, new QueryRequestContext(AuthorizationService, user));
}
return await graphQLDocument.ExecuteQueryAsync(overwriteContext, serviceProvider, gql.Variables, gql.OperationName, options);
}
catch (Exception exception)
{
return HandleException(exception);
}
}
Metadata
Metadata
Assignees
Labels
No labels