Skip to content

Commit

Permalink
Merge pull request #21 from AEB-labs/custom-input-operation-args
Browse files Browse the repository at this point in the history
feature: implement custom operation input args hook
  • Loading branch information
henkesn authored Dec 4, 2023
2 parents fbf41fc + 4b2563d commit b14d62a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/soap2graphql/schema-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,19 @@ export class SchemaResolver {
}

createSoapOperationFieldArgs(operation: SoapOperation): GraphQLFieldConfigArgumentMap {
const args: GraphQLFieldConfigArgumentMap = {};
let args: GraphQLFieldConfigArgumentMap = {};
const inputType = operation.inputType();
switch (inputType.kind) {
case 'complexType':
const gqlInputType = this.inputResolver.resolve({
type: operation.inputType(),
}) as GraphQLInputObjectType;
return gqlInputType.getFields();
args = gqlInputType.getFields();
break;
case 'simpleType':
args['input'] = { type: this.scalarResolver.resolve(inputType) };
}
return args;
return { ...args, ...(this.options.additionalOperationArgs || {}) };
}

resolveSoapOperationReturnType(operation: SoapOperation): GraphQLOutputType {
Expand Down
7 changes: 7 additions & 0 deletions src/soap2graphql/soap2graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SoapCaller } from './soap-caller';
import { GraphQLSchemaConfig } from 'graphql/type/schema';
import { SchemaResolver } from './schema-resolver';
import { Logger } from './logger';
import { GraphQLFieldConfigArgumentMap } from 'graphql/index';

/**
* Options for the GraphQL schema.
Expand Down Expand Up @@ -84,6 +85,12 @@ export type SchemaOptions = {
* default: __attributes
*/
attributesKey?: string;

/**
* Possibility to add custom input fields to each operation mutation e. g. for metadata or http headers.
* You'll probably want to implement a custom NodeSoapCaller when using this field.
*/
additionalOperationArgs?: GraphQLFieldConfigArgumentMap;
};

export function createSchemaConfig(
Expand Down

0 comments on commit b14d62a

Please sign in to comment.