Skip to content

Commit

Permalink
feat(hive): options for selfhosting
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Feb 13, 2023
1 parent 2efe7e2 commit 989a478
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/metal-baboons-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-mesh/plugin-hive': minor
'@graphql-mesh/types': patch
---

Options for self hosting
3 changes: 2 additions & 1 deletion packages/plugins/hive/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createHive, HivePluginOptions, useHive } from '@graphql-hive/client';
import { MeshPlugin, MeshPluginOptions, YamlConfig } from '@graphql-mesh/types';
import { process } from '@graphql-mesh/cross-helpers';
import { stringInterpolator } from '@graphql-mesh/string-interpolation';
import { MeshPlugin, MeshPluginOptions, YamlConfig } from '@graphql-mesh/types';

export default function useMeshHive(
pluginOptions: MeshPluginOptions<YamlConfig.HivePlugin>,
Expand Down Expand Up @@ -69,6 +69,7 @@ export default function useMeshHive(
agent,
usage,
reporting,
selfHosting: pluginOptions.selfHosting,
});
const id = pluginOptions.pubsub.subscribe('destroy', () => {
hiveClient
Expand Down
26 changes: 26 additions & 0 deletions packages/plugins/hive/yaml-config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ type HivePlugin @md {
Schema reporting
"""
reporting: HiveReportingOptions
"""
Options for self-hosting
[See more](https://github.com/kamilkisiela/graphql-hive/tree/main/packages/libraries/client#self-hosting)
"""
selfHosting: HiveSelfHostingOptions
}

type HiveAgentOptions {
Expand Down Expand Up @@ -104,3 +109,24 @@ type HiveReportingOptions {
serviceName: String
serviceUrl: String
}

type HiveSelfHostingOptions {
"""
Point to your own instance of GraphQL Hive API
Used by schema reporting and token info.
"""
graphqlEndpoint: String!
"""
Address of your own GraphQL Hive application
Used by token info to generate a link to the organization, project and target.
"""
applicationUrl: String!
"""
Point to your own instance of GraphQL Hive Usage API
Used by usage reporting.
"""
usageEndpoint: String
}
24 changes: 24 additions & 0 deletions packages/types/src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,10 @@
"reporting": {
"$ref": "#/definitions/HiveReportingOptions",
"description": "Schema reporting"
},
"selfHosting": {
"$ref": "#/definitions/HiveSelfHostingOptions",
"description": "Options for self-hosting\n[See more](https://github.com/kamilkisiela/graphql-hive/tree/main/packages/libraries/client#self-hosting)"
}
},
"required": ["token"]
Expand Down Expand Up @@ -2037,6 +2041,26 @@
},
"required": ["author", "commit"]
},
"HiveSelfHostingOptions": {
"additionalProperties": false,
"type": "object",
"title": "HiveSelfHostingOptions",
"properties": {
"graphqlEndpoint": {
"type": "string",
"description": "Point to your own instance of GraphQL Hive API\n\nUsed by schema reporting and token info."
},
"applicationUrl": {
"type": "string",
"description": "Address of your own GraphQL Hive application\n\nUsed by token info to generate a link to the organization, project and target."
},
"usageEndpoint": {
"type": "string",
"description": "Point to your own instance of GraphQL Hive Usage API\n\nUsed by usage reporting."
}
},
"required": ["graphqlEndpoint", "applicationUrl"]
},
"HTTPDetailsExtensionsConfig": {
"additionalProperties": false,
"type": "object",
Expand Down
25 changes: 25 additions & 0 deletions packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,7 @@ export interface HivePlugin {
agent?: HiveAgentOptions;
usage?: HiveUsageOptions;
reporting?: HiveReportingOptions;
selfHosting?: HiveSelfHostingOptions;
}
/**
* Agent Options
Expand Down Expand Up @@ -1737,6 +1738,30 @@ export interface HiveReportingOptions {
serviceName?: string;
serviceUrl?: string;
}
/**
* Options for self-hosting
* [See more](https://github.com/kamilkisiela/graphql-hive/tree/main/packages/libraries/client#self-hosting)
*/
export interface HiveSelfHostingOptions {
/**
* Point to your own instance of GraphQL Hive API
*
* Used by schema reporting and token info.
*/
graphqlEndpoint: string;
/**
* Address of your own GraphQL Hive application
*
* Used by token info to generate a link to the organization, project and target.
*/
applicationUrl: string;
/**
* Point to your own instance of GraphQL Hive Usage API
*
* Used by usage reporting.
*/
usageEndpoint?: string;
}
export interface HTTPDetailsExtensionsConfig {
if?: any;
}
Expand Down
13 changes: 12 additions & 1 deletion website/src/generated-markdown/HivePlugin.generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,15 @@ Default: false
* `author` (type: `String`, required) - Author of current version of the schema
* `commit` (type: `String`, required) - Commit SHA hash (or any identifier) related to the schema version
* `serviceName` (type: `String`)
* `serviceUrl` (type: `String`)
* `serviceUrl` (type: `String`)
* `selfHosting` (type: `Object`) - Options for self-hosting
[See more](https://github.com/kamilkisiela/graphql-hive/tree/main/packages/libraries/client#self-hosting):
* `graphqlEndpoint` (type: `String`, required) - Point to your own instance of GraphQL Hive API

Used by schema reporting and token info.
* `applicationUrl` (type: `String`, required) - Address of your own GraphQL Hive application

Used by token info to generate a link to the organization, project and target.
* `usageEndpoint` (type: `String`) - Point to your own instance of GraphQL Hive Usage API

Used by usage reporting.

0 comments on commit 989a478

Please sign in to comment.