Skip to content

Instantly share code, notes, and snippets.

@maartenvanvliet
Created January 22, 2022 18:25
Show Gist options
  • Save maartenvanvliet/3f1026812d5ebd7b822c4a6f0b54a12f to your computer and use it in GitHub Desktop.
Save maartenvanvliet/3f1026812d5ebd7b822c4a6f0b54a12f to your computer and use it in GitHub Desktop.
removes __schema node from a query.
defmodule SkipIntrospection do
@behaviour Absinthe.Phase
def run(doc, options \\ []) do
node = Absinthe.Blueprint.prewalk(doc, &handle_node/1)
{:ok, node}
end
defp handle_node(%Absinthe.Blueprint.Document.Operation{} = node) do
selections =
node.selections
|> Enum.reduce([], fn e, acc ->
if e.schema_node.identifier == :__schema do
acc
else
[e | acc]
end
end)
|> Enum.reverse()
%{node | selections: selections}
end
defp handle_node(node) do
node
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment