Skip to content

filter out non operation definition when naming #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: absinthe-telemetry
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/new_relic/telemetry/absinthe/metadata.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
defmodule NewRelic.Telemetry.Absinthe.Metadata do
alias Absinthe.Language.OperationDefinition

def resolver_name(middleware) do
Enum.find_value(middleware, fn
{{Absinthe.Resolution, :call}, resolver_fn} ->
Expand Down Expand Up @@ -27,8 +29,9 @@ defmodule NewRelic.Telemetry.Absinthe.Metadata do
def operation_span_name(input) when is_binary(input) do
with {:ok, tokens} <- Absinthe.Lexer.tokenize(input),
{:ok, parsed} <- :absinthe_parser.parse(tokens),
%Absinthe.Language.OperationDefinition{} = definition <-
Enum.find(parsed.definitions, fn x -> x.operation in [:query, :mutation] end) do
op_defs = Enum.filter(parsed.definitions, &match?(%OperationDefinition{}, &1)),
definition when not is_nil(definition) <-
Enum.find(ops_defs, fn x -> x.operation in [:query, :mutation] end) do
"#{definition.operation}:#{definition.name || definition.selection_set.selections |> selections_name()}"
end
end
Expand Down