graphql-php icon indicating copy to clipboard operation
graphql-php copied to clipboard

Allow deprecation of input values

Open simPod opened this issue 8 years ago • 4 comments

I haven't find anything about it in gql specs. Am I missing something?

private static function printInputObject(InputObjectType $type)
    {
        $fields = array_values($type->getFields());
        return self::printDescription($type) . 
            "input {$type->name} {\n" .
                implode("\n", array_map(function($f, $i) {
                    return self::printDescription($f, '  ', !$i) . '  ' . self::printInputValue($f);
                }, $fields, array_keys($fields))) . "\n" .
            "}";
    }

doesn't print deprecation reason vs

private static function printObject(ObjectType $type)
    {
        $interfaces = $type->getInterfaces();
        $implementedInterfaces = !empty($interfaces) ?
            ' implements ' . implode(', ', array_map(function($i) {
                return $i->name;
            }, $interfaces)) : '';
        return self::printDescription($type) .
            "type {$type->name}$implementedInterfaces {\n" .
                self::printFields($type) . "\n" .
            "}";
    }

private static function printFields($type)
    {
        $fields = array_values($type->getFields());
        return implode("\n", array_map(function($f, $i) {
                return self::printDescription($f, '  ', !$i) . '  ' .
                    $f->name . self::printArgs($f->args, '  ') . ': ' .
                    (string) $f->getType() . self::printDeprecated($f);
            }, $fields, array_keys($fields)));
    }

Thanks!

simPod avatar Apr 11 '17 12:04 simPod

While it makes sense for me, but deprecation is not described for input object types in GraphQL specs (or reference implementation). So I guess this question should be first raised in spec repo.

I'll close it for now, but will track specs / reference implementation updates in this regard.

vladar avatar Apr 24 '17 10:04 vladar

There is a PR that was created 9 days ago to handle deprecation of input fields. Once it will be merged we can make the changes to this repo! https://github.com/facebook/graphql/issues/197

bginsburg avatar Nov 02 '18 02:11 bginsburg

@vladar I think this should be reopened now: https://github.com/graphql/graphql-spec/pull/525

enumag avatar Jan 11 '21 08:01 enumag

This should be a great first PR, a relatively straightforward port of https://github.com/graphql/graphql-js/pull/2733. Any takers?

~Progress on this seems to hang on https://github.com/graphql/graphql-spec/pull/805 though.~ The specification now allows this.

spawnia avatar Jan 11 '21 13:01 spawnia

Hello, @spawnia I've created a PR to resolve this issue: #1382

TaProhm avatar May 09 '23 23:05 TaProhm

Thank you @TaProhm, released with https://github.com/webonyx/graphql-php/releases/tag/v15.4.0.

spawnia avatar May 11 '23 10:05 spawnia