-
Notifications
You must be signed in to change notification settings - Fork 117
feat(sdk): specify the usage target endpoint for organization access tokens #6574
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
Changes from all commits
0dd9b4e
9c5bf21
0fc1b88
9ca949f
8801074
d5c23e2
2eddb5a
040d7a7
5fa492a
5219487
ede0e7a
ad53ceb
d997ec6
25a00dc
926af55
dc1c124
937176b
daf6b2e
4a9f179
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
'@graphql-hive/envelop': minor | ||
--- | ||
|
||
Add support for providing a target for usage reporting with organization access tokens. | ||
This can either be a slug following the format `$organizationSlug/$projectSlug/$targetSlug` (e.g `the-guild/graphql-hive/staging`) | ||
or an UUID (e.g. `a0f4c605-6541-4350-8cfe-b31f21a4bf80`) | ||
|
||
```ts | ||
import { useHive } from '@graphql-hive/envelop'; | ||
|
||
const hivePlugin = useHive({ | ||
enabled: true, | ||
token: "ORGANIZATION_ACCESS_TOKEN", | ||
usage: { | ||
target: "my-org/my-project/my-target" | ||
} | ||
}) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
'@graphql-hive/core': minor | ||
--- | ||
|
||
Add support for providing a target for usage reporting with organization access tokens. | ||
This can either be a slug following the format `$organizationSlug/$projectSlug/$targetSlug` (e.g `the-guild/graphql-hive/staging`) | ||
or an UUID (e.g. `a0f4c605-6541-4350-8cfe-b31f21a4bf80`) | ||
|
||
```ts | ||
import { createHive } from '@graphql-hive/core'; | ||
|
||
const hive = createHive({ | ||
enabled: true, | ||
token: "ORGANIZATION_ACCESS_TOKEN", | ||
usage: { | ||
target: "my-org/my-project/my-target" | ||
} | ||
}) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
'@graphql-hive/yoga': minor | ||
--- | ||
|
||
Add support for providing a target for usage reporting with organization access tokens. | ||
This can either be a slug following the format `$organizationSlug/$projectSlug/$targetSlug` (e.g `the-guild/graphql-hive/staging`) | ||
or an UUID (e.g. `a0f4c605-6541-4350-8cfe-b31f21a4bf80`) | ||
|
||
```ts | ||
import { useHive } from '@graphql-hive/yoga'; | ||
|
||
const hivePlugin = useHive({ | ||
enabled: true, | ||
token: "ORGANIZATION_ACCESS_TOKEN", | ||
usage: { | ||
target: "my-org/my-project/my-target" | ||
} | ||
}) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
'@graphql-hive/apollo': minor | ||
--- | ||
|
||
Add support for providing a target for usage reporting with organization access tokens. | ||
This can either be a slug following the format `$organizationSlug/$projectSlug/$targetSlug` (e.g `the-guild/graphql-hive/staging`) | ||
or an UUID (e.g. `a0f4c605-6541-4350-8cfe-b31f21a4bf80`) | ||
|
||
```ts | ||
import { useHive } from '@graphql-hive/apollo' | ||
|
||
const hivePlugin = useHive({ | ||
enabled: true, | ||
token: "ORGANIZATION_ACCESS_TOKEN", | ||
usage: { | ||
target: "my-org/my-project/my-target" | ||
} | ||
}) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,16 +75,18 @@ export function createUsage(pluginOptions: HivePluginOptions): UsageCollector { | |
const collector = memo(createCollector, arg => arg.schema); | ||
const excludeSet = new Set(options.exclude ?? []); | ||
|
||
const baseEndpoint = | ||
n1ru4l marked this conversation as resolved.
Show resolved
Hide resolved
|
||
selfHostingOptions?.usageEndpoint ?? options.endpoint ?? 'https://app.graphql-hive.com/usage'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible for someone to enter an endpoint with a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I would treat this as a user error and not be to smart about trying to auto-fix it. Thinking more about it self-hosters could have their usage behind a custom proxy that requires a trailing |
||
|
||
const endpoint = baseEndpoint + (options?.target ? `/${options.target}` : ''); | ||
|
||
const agent = createAgent<AgentAction>( | ||
{ | ||
...(pluginOptions.agent ?? { | ||
maxSize: 1500, | ||
}), | ||
logger, | ||
endpoint: | ||
selfHostingOptions?.usageEndpoint ?? | ||
options.endpoint ?? | ||
'https://app.graphql-hive.com/usage', | ||
endpoint, | ||
token: pluginOptions.token, | ||
enabled: pluginOptions.enabled, | ||
debug: pluginOptions.debug, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Code comment does not match actual configuration
The
REQUEST_LOGGING
is set to'1'
which typically enables logging, but the comment says "disabled". This inconsistency might lead to confusion.🏁 Script executed:
Length of output: 7534
Update Inline Comment for REQUEST_LOGGING
'1'
means request logging is enabled.REQUEST_LOGGING: '1', // enabled
) or remove it if it’s no longer necessary to avoid confusion.