protected function convertDirectives(DocumentAST $document): Collection
    {
        return $document->directiveDefinitions()
            ->map(function (DirectiveDefinitionNode $directive) {
                return new Directive([
                    'name' => $directive->name->value,
                    'description' => data_get($directive->description, 'value'),
                    'locations' => (new Collection($directive->locations))
                        ->map(function ($location) {
                            return $location->value;
                        })
                        ->toArray(),
                    'args' => (new Collection($directive->arguments))
                        ->map(function (InputValueDefinitionNode $argument) {
                            $fieldArgumentConfig = [
                                'name' => $argument->name->value,
                                'description' => data_get($argument->description, 'value'),
                                'type' => $this->definitionNodeConverter->toType($argument->type),
                            ];

                            if ($defaultValue = $argument->defaultValue) {
                                $fieldArgumentConfig += [
                                    'defaultValue' => $defaultValue,
                                ];
                            }

                            return new FieldArgument($fieldArgumentConfig);
                        })
                        ->toArray(),
                    'astNode' => $directive,
                ]);
            });
    }