You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For analytics purposes (using App Insights), I need to log the start/finish time of all of the Queries and Mutations and whilst I can easily add this to each of the Query / Mutation resolvers, I would like to try and do it higher up the stack.
I have deployed GraphQL as an Azure function and use the code examples provided in this GitHub project and it builds out a batch execution collection.
var requests = await _requestParser.ReadJsonRequestAsync(req.Body, CancellationToken.None).ConfigureAwait(false);
var executor = await _requestExecutorResolver.GetRequestExecutorAsync().ConfigureAwait(false);
var batchRequest = requests.Select(r => QueryRequestBuilder.From(r).Create());
result = await executor.ExecuteBatchAsync(batchRequest).ConfigureAwait(false);
batchRequest contains a list of all of the operations that need to be executed, which HC will then instantiate the relevant resolver.... So, is there any way I can see what resolvers have been assigned to the operation, which I can then use for logging.
For example, if I have a QueryResolver defined as per below which has two queries. When HC decides what operation it needs to execute, I would like to extract that and then use it as a basis to log my metrics.
[ExtendObjectType(OperationTypeNames.Query)]
public class PersonQuery
{
[GraphQLName("getPersonByID")]
public async Task<IEnumerable<PersonResponse>> IDSearch(string employeeID)
{
.....
}
[GraphQLName("getPersonBySurname")]
public async Task<IEnumerable<PersonResponse>> NameSearch(string surname)
{
.....
}
As mentioned in the opening, I know I can add logging into each operation, but if I could add it at higher level and use some sort of relection analysis, then that would automatically log any future operations that are added, and the developer just needs to concentrate on the actual implementation.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For analytics purposes (using App Insights), I need to log the start/finish time of all of the Queries and Mutations and whilst I can easily add this to each of the Query / Mutation resolvers, I would like to try and do it higher up the stack.
I have deployed GraphQL as an Azure function and use the code examples provided in this GitHub project and it builds out a batch execution collection.
batchRequest
contains a list of all of the operations that need to be executed, which HC will then instantiate the relevant resolver.... So, is there any way I can see what resolvers have been assigned to the operation, which I can then use for logging.For example, if I have a QueryResolver defined as per below which has two queries. When HC decides what operation it needs to execute, I would like to extract that and then use it as a basis to log my metrics.
As mentioned in the opening, I know I can add logging into each operation, but if I could add it at higher level and use some sort of relection analysis, then that would automatically log any future operations that are added, and the developer just needs to concentrate on the actual implementation.
Beta Was this translation helpful? Give feedback.
All reactions