From 989a478027b703ab969d529f09bc83071fe4f96f Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Tue, 14 Feb 2023 02:16:16 +0300 Subject: [PATCH] feat(hive): options for selfhosting --- .changeset/metal-baboons-scream.md | 6 +++++ packages/plugins/hive/src/index.ts | 3 ++- packages/plugins/hive/yaml-config.graphql | 26 +++++++++++++++++++ packages/types/src/config-schema.json | 24 +++++++++++++++++ packages/types/src/config.ts | 25 ++++++++++++++++++ .../HivePlugin.generated.md | 13 +++++++++- 6 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 .changeset/metal-baboons-scream.md diff --git a/.changeset/metal-baboons-scream.md b/.changeset/metal-baboons-scream.md new file mode 100644 index 0000000000000..42ca72b6a32cf --- /dev/null +++ b/.changeset/metal-baboons-scream.md @@ -0,0 +1,6 @@ +--- +'@graphql-mesh/plugin-hive': minor +'@graphql-mesh/types': patch +--- + +Options for self hosting diff --git a/packages/plugins/hive/src/index.ts b/packages/plugins/hive/src/index.ts index 13ab17ad5eb0a..611a99c8b18b1 100644 --- a/packages/plugins/hive/src/index.ts +++ b/packages/plugins/hive/src/index.ts @@ -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, @@ -69,6 +69,7 @@ export default function useMeshHive( agent, usage, reporting, + selfHosting: pluginOptions.selfHosting, }); const id = pluginOptions.pubsub.subscribe('destroy', () => { hiveClient diff --git a/packages/plugins/hive/yaml-config.graphql b/packages/plugins/hive/yaml-config.graphql index 16205412da80c..020259d87eb49 100644 --- a/packages/plugins/hive/yaml-config.graphql +++ b/packages/plugins/hive/yaml-config.graphql @@ -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 { @@ -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 +} diff --git a/packages/types/src/config-schema.json b/packages/types/src/config-schema.json index 0fdd021a5c129..e73eb0693f8ce 100644 --- a/packages/types/src/config-schema.json +++ b/packages/types/src/config-schema.json @@ -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"] @@ -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", diff --git a/packages/types/src/config.ts b/packages/types/src/config.ts index c6adbb533d964..553688f14362d 100644 --- a/packages/types/src/config.ts +++ b/packages/types/src/config.ts @@ -1647,6 +1647,7 @@ export interface HivePlugin { agent?: HiveAgentOptions; usage?: HiveUsageOptions; reporting?: HiveReportingOptions; + selfHosting?: HiveSelfHostingOptions; } /** * Agent Options @@ -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; } diff --git a/website/src/generated-markdown/HivePlugin.generated.md b/website/src/generated-markdown/HivePlugin.generated.md index 277abf5a20c6e..97ee70c408389 100644 --- a/website/src/generated-markdown/HivePlugin.generated.md +++ b/website/src/generated-markdown/HivePlugin.generated.md @@ -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`) \ No newline at end of file + * `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. \ No newline at end of file