Skip to content

Commit

Permalink
updating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shashitnak committed Mar 10, 2024
1 parent f4bf024 commit e04371d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions docs/guides/apollo-studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,57 @@ Before you configure `tailcall`, you will need to create a `Monolith` graph on A
![insert-gql-schema.png](../../static/images/apollo-studio/insert-gql-schema.png)

- Copy the fields `APOLLO_KEY` and `APOLLO_GRAPH_REF` as they are required by `tailcall` to be able to send the usage metrics.
- Navigate to `Local Schema` and insert your schema generated by `tailcall` and click `Upload`.<br/>_Note: you can get the schema by running `tailcall check --schema <path-to-config>`_(click [here](./cli.md) to know more).
- There are two ways to let Apollo know about your GraphQL schema:

- Navigate to `Local Introspection`. If you have a deployed instance of your GraphQL server you can put the URL pointing to that in `Endpoint URL`. If not, start a local instance of `tailcall` and put the local url here, similar to how is shown in the image below.<br/>
_Note: You can start a local instance of tailcall by running `tailcall start <path-to-config>`(click [here](./cli.md) to know more)._

![local-introspection.png](../../static/images/apollo-studio/local-introspection.png)

- Or, Navigate to `Local Schema` and insert your schema generated by `tailcall` and click `Upload`.<br/>
_Note: you can get the schema by running `tailcall check --schema <path-to-config>`_(click [here](./cli.md) to know more).

![local-schema.png](../../static/images/apollo-studio/local-schema.png)

You have now successfully created a Monolith graph in Apollo Studio. The next step is to configure `tailcall` to use the `APOLLO_API_KEY` and `APOLLO_GRAPH_REF`. Follow instructions [here](../operators/telemetry.md).

## Check the metrics in Apollo Studio

To see the metrics for you queries follow these instructions:
To see the metrics for your queries follow these instructions:

- Start `tailcall` with the appropriate configuration for Apollo. Below is an example of what a config may look like.

```graphql
schema
@server(port: 8000, graphiql: true, hostname: "0.0.0.0")
@upstream(baseURL: "http://jsonplaceholder.typicode.com")
@telemetry(
export: {
apollo: {
# Make sure you set the appropriate values for APOLLO_API_KEY and APOLLO_GRAPH_REF
# in the ENV, as was acquired from the Apollo Studio website.
api_key: "{{env.APOLLO_API_KEY}}"
graph_ref: "{{env.APOLLO_GRAPH_REF}}"
}
}
) {
query: Query
}

type Query {
posts: [Post] @http(path: "/posts")
}

type Post {
id: Int!
userId: Int!
title: String!
body: String!
}
```

- Start `tailcall` with the appropriate configuration for Apollo.
- Create a query like below and run it multiple times to send it to Apollo Studio.
- Visit `http://localhost:8000/graphql` and create a query with an appropriate name (below is an example query named `MyQuery`) and run it multiple times to send the metrics to Apollo Studio.<br/>
_Note: Naming the query is not required to be able to send the metrics, but it helps to organize the metrics with appropriate names when viewed in Apollo Studio._

```graphql
query MyQuery {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e04371d

Please sign in to comment.