public static function attachDirectiveToObjectTypeFields(DocumentAST $documentAST, DirectiveNode $directive): DocumentAST
    {
        return $documentAST->objectTypeDefinitions()
            ->reduce(
                function (DocumentAST $document, ObjectTypeDefinitionNode $objectType) use ($directive): DocumentAST {
                    if (! data_get($objectType, 'name.value')) {
                        return $document;
                    }

                    $objectType->fields = new NodeList(
                        (new Collection($objectType->fields))
                            ->map(function (FieldDefinitionNode $field) use ($directive): FieldDefinitionNode {
                                $field->directives = $field->directives->merge([$directive]);

                                return $field;
                            })
                            ->all()
                    );

                    $document->setDefinition($objectType);

                    return $document;
                },
                $documentAST
            );
    }