Skip to content

Commit

Permalink
cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslt committed Aug 19, 2022
1 parent c4c8cfe commit 36dc69d
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions packages/utils/src/get-arguments-with-directives.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { DirectiveUsage } from './types.js';

import {
ASTNode,
DocumentNode,
Kind,
ObjectTypeDefinitionNode,
ObjectTypeExtensionNode,
valueFromASTUntyped,
} from 'graphql';
import { ASTNode, DocumentNode, Kind, ObjectTypeDefinitionNode, valueFromASTUntyped } from 'graphql';

function isTypeWithFields(t: ASTNode): t is ObjectTypeDefinitionNode {
return t.kind === Kind.OBJECT_TYPE_DEFINITION || t.kind === Kind.OBJECT_TYPE_EXTENSION;
Expand Down Expand Up @@ -40,7 +33,6 @@ export function getArgumentsWithDirectives(documentNode: DocumentNode): TypeAndF
const typeFieldResult = (result[`${type.name.value}.${field.name.value}`] = {});

for (const arg of argsWithDirectives) {
// TODO share that code with getFieldsWithDirectives
const directives: DirectiveUsage[] = arg.directives.map(d => ({
name: d.name.value,
args: (d.arguments || []).reduce(
Expand All @@ -55,16 +47,4 @@ export function getArgumentsWithDirectives(documentNode: DocumentNode): TypeAndF
}

return result;

return Object.assign(
{},
...allTypes.map((type: ObjectTypeDefinitionNode | ObjectTypeExtensionNode) => {
const typeName = type.name.value;
return _.chain(type.fields)
.keyBy(getNodeName)
.mapValues(field => ({ type, field }))
.mapKeys((_, fieldName) => `${typeName}.${fieldName}`)
.value();
})
);
}

0 comments on commit 36dc69d

Please sign in to comment.