All Projects → sikanhe → apollo-tracing-elixir

sikanhe / apollo-tracing-elixir

Licence: other
Apollo Tracing middleware for Absinthe

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to apollo-tracing-elixir

simple graphql client
SimpleGraphqlClient is a graphql client, focused on simplicity and ease of use.
Stars: ✭ 17 (-85.09%)
Mutual labels:  absinthe, absinthe-graphql
pokedex
📕 DIY full-stack workshop teaching you Elixir, Absinthe GraphQL, React and Relay
Stars: ✭ 17 (-85.09%)
Mutual labels:  absinthe, absinthe-graphql
phoenix-react-apollo-demo
Example app using the Phoenix Framework with React and GraphQL
Stars: ✭ 37 (-67.54%)
Mutual labels:  apollo, absinthe
NASSP
Project Apollo - NASSP
Stars: ✭ 110 (-3.51%)
Mutual labels:  apollo
Heighliner
A GraphQL Server for NewSpring Web
Stars: ✭ 13 (-88.6%)
Mutual labels:  apollo
graphqlizer
Make your meteor mongo collections accessible over a graphql endpoint
Stars: ✭ 37 (-67.54%)
Mutual labels:  apollo
graphX
A simple blog based on Nuxt and graphQL
Stars: ✭ 19 (-83.33%)
Mutual labels:  apollo
RxApolloClient
RxSwift extensions for Apollo Client
Stars: ✭ 46 (-59.65%)
Mutual labels:  apollo
create-full-stack
Set up a TypeScript full stack with one command.
Stars: ✭ 94 (-17.54%)
Mutual labels:  apollo
rogue.js
The "nearly invisible" way to server-render React applications
Stars: ✭ 1,914 (+1578.95%)
Mutual labels:  apollo
swifters
Browse Swift users on GitHub
Stars: ✭ 13 (-88.6%)
Mutual labels:  apollo
shopify-node-react-app
Shopify paid app in Node.js & React.js that connects to a store and lets merchants select products to automatically discount them in the Shopify admin interface.
Stars: ✭ 29 (-74.56%)
Mutual labels:  apollo
mern-apollo-graphql-boilerplate
MERN + Apollo-Graphql Boilerplate
Stars: ✭ 21 (-81.58%)
Mutual labels:  apollo
apollo-phoenix-websocket
An Apollo networkInterface for executing GraphQL queries via Phoenix Channels
Stars: ✭ 91 (-20.18%)
Mutual labels:  absinthe
DiscoveryPlatform
☀️ Nepxion DiscoveryPlatform is a platform for Nepxion Discovery with service governance, release orchestration, flow inspection, instance blacklist, gateway route 服务治理、蓝绿灰度编排、流量侦测、实例摘除、网关路由的平台
Stars: ✭ 63 (-44.74%)
Mutual labels:  apollo
erxes-widgets-api
Deprecated: Repo is now integrated with erxes-api
Stars: ✭ 22 (-80.7%)
Mutual labels:  apollo
matnbaz
📚 The source-code for matnbaz.net. A monorepo containing the back-end (NestJS/Prisma/Apollo), front-end (Next.js/Apollo) and some tooling.
Stars: ✭ 481 (+321.93%)
Mutual labels:  apollo
react-apollo-mutation-state
A React HOC wrapper for Apollo GraphQL mutation, provides loading and error in props
Stars: ✭ 16 (-85.96%)
Mutual labels:  apollo
kerrigan
基于Tornado实现的一套配置中心,可基于分项目、环境管理配置,语法高亮、对比历史版本、快速回滚等,并提供Restful风格的API
Stars: ✭ 57 (-50%)
Mutual labels:  apollo
kernel xiaomi sm8250
CLO Rebased kernel for Xiaomi SM8250 series devices updated to CAF tag LA.UM.9.12.r1-14700-SMxx50 with AOSP android-4.19-stable merged.
Stars: ✭ 111 (-2.63%)
Mutual labels:  apollo

ApolloTracing (for Elixir)

ApolloTracing adds data to your GraphQL query response so that an Apollo Engine can provide insights into your Absinthe-based GraphQL service.

Supported Apollo Features

Installation

Add :apollo_tracing to your deps

def deps do
  [
    {:apollo_tracing, "~> 0.4.0"}
  ]
end

Usage

Register the Middlewares

ApolloTracing uses the Absinthe's middleware functionality to track field-level resolution times. In order to register our custom middleware, you have a few options:

Add use ApolloTracing to your schema file:

def MyApp.Schema do
  use Absinthe.Schema
  use ApolloTracing
end

If you have a custom middleware stack, add the apollo tracing middlewares to the beginning of your middleware stack:

def middleware(middleware, _field, _object),
  do: [ApolloTracing.Middleware.Tracing, ApolloTracing.Middleware.Caching] ++ [...your other middlewares]

If you prefer to only add tracing to some fields, you can selectively add tracing information:

field :selected_field, :string do
  middleware ApolloTracing.Middleware # Has to be the first middleware
  resolve fn _, _ -> {:ok, "this field is now added to be traced"} end
end

Register the Pipeline

ApolloTracing currently requires you to use a custom Pipeline in order to register 'Phases' in the correct order during resolution. Phases are used for measuring overall query times as well as appending the custom data to the response (including cache hints).

Specify the pipeline in your Absinthe.Plug endpoint:

forward "/graphql", Absinthe.Plug,
  schema: MyApp.Schema,
  pipeline: {ApolloTracing.Pipeline, :plug}

If you have your own pipeline function, you can add the phases directly:

def my_pipeline_creator(config, pipeline_opts) do
  config.schema_mod
  |> Absinthe.Pipeline.for_document(pipeline_opts)
  |> add_my_phases() # w.e your custom phases are
  |> ApolloTracing.Pipeline.add_phases() # Add apollo at the end
end

When you want to just call run a query with tracing, but without going through a Plug endpoint:

def custom_absinthe_runner(query, opts \\ []) do
  pipeline = ApolloTracing.Pipeline.default(YourSchema, opts)
  case Absinthe.Pipeline.run(query, pipeline) do
    {:ok, %{result: result}, _} -> {:ok, result}
    {:error, err, _} -> {:ok, err}
  end
end

"""
  query {
    fielda
    fieldb
  }
"""
|> custom_absinthe_runner()

Add Cache Metadata

You can configure caching by adding metadata to your Absinthe objects:

object :user do
  meta :cache, max_age: 30
end

# or

object :user, meta: [cache: [max_age: 30]] do
  # ...
end

To ensure that the object is not cached across users, you can mark it as private:

object :user do
  meta :cache, max_age: 30, scope: :private
end

See the Apollo docs for more information about cache scope.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].