youshido-php/GraphQLBundle

Trying to create a custom Argument

MGDSoft opened this issue · 2 comments

Hi all,

I am trying to create a custom argument

class MedicalProfileInsertField extends AbstractContainerAwareField
{
    public function build(FieldConfig $config)
    {
        $config
            ->setDescription('Mutation')
            ->addArguments([
                'medicalProfilePost'   => new MedicalProfileFormType(),
            ])
        ;
    }

    public function resolve($value, array $args, ResolveInfo $info)
    {
        // todo

        return [];
    }

    /**
     * @return AbstractObjectType|AbstractType
     */
    public function getType()
    {
        return new MedicalProfileType();
    }

}

class MedicalProfileFormType extends AbstractObjectType
{
    /**
     * @param ObjectTypeConfig $config
     * @return void
     */
    public function build($config)
    {
        $config->addFields([
            'username'   => new NonNullType(new StringType()),
            // ....
        ]);
    }
}

But I get this error..

Introspection must provide input type for arguments

For a complex argument, how can I do?

Thanks in advance

@MGDSoft You just have to extend the AbstractInputObjectType and you'll be fine.

OMG thx, and thx for this great bundle 👍