Skip to content
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

fix(transform-hive): filter non-existing delegated argument #8256

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pink-crews-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-mesh/transform-hive': patch
---

Remove non-existing delegated argument from the document while reporting to Hive
29 changes: 15 additions & 14 deletions packages/legacy/transforms/hive/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Kind, visit, type ExecutionResult, type GraphQLSchema } from 'graphql';
import { Kind, visit, visitWithTypeInfo, type ExecutionResult, type GraphQLSchema } from 'graphql';
import { createHive, type HiveClient, type HivePluginOptions } from '@graphql-hive/core';
import { process } from '@graphql-mesh/cross-helpers';
import { stringInterpolator } from '@graphql-mesh/string-interpolation';
import type { MeshTransform, MeshTransformOptions, YamlConfig } from '@graphql-mesh/types';
import type { DelegationContext } from '@graphql-tools/delegate';
import { getTypeInfo, type DelegationContext } from '@graphql-tools/delegate';
import { mapMaybePromise, type ExecutionRequest } from '@graphql-tools/utils';

interface TransformationContext {
Expand Down Expand Up @@ -88,7 +88,7 @@ export default class HiveTransform implements MeshTransform {

transformRequest(
request: ExecutionRequest,
delegationContext: DelegationContext,
_delegationContext: DelegationContext,
transformationContext: TransformationContext,
) {
try {
Expand All @@ -102,25 +102,26 @@ export default class HiveTransform implements MeshTransform {

transformResult(
result: ExecutionResult,
delegationContext: DelegationContext,
_delegationContext: DelegationContext,
transformationContext: TransformationContext,
) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises -- we dont really care about usage reporting result
try {
const typeInfo = getTypeInfo(this.schema);
transformationContext
.collectUsageCallback?.(
{
schema: this.schema,
document: visit(transformationContext.request.document, {
[Kind.FIELD](node) {
if (!node.arguments) {
return {
...node,
arguments: [],
};
}
},
}),
document: visit(
transformationContext.request.document,
visitWithTypeInfo(typeInfo, {
Argument: () => {
if (!typeInfo.getArgument()) {
return null;
}
},
}),
),
rootValue: transformationContext.request.rootValue,
contextValue: transformationContext.request.context,
variableValues: transformationContext.request.variables,
Expand Down
Loading