craftcms / gatsby-source-craft

Gatsby source plugin for Craft CMS.
MIT License
54 stars 13 forks source link

Custom type field is missing from Gatsby #32

Closed sjelfull closed 3 years ago

sjelfull commented 3 years ago

Description

I have added a custom type field named imgix to AssetInterface through the TypeManager::EVENT_DEFINE_GQL_TYPE_FIELDS event like this:

 Event::on(
            TypeManager::class,
            TypeManager::EVENT_DEFINE_GQL_TYPE_FIELDS,
            function(DefineGqlTypeFieldsEvent $event) {
                if (in_array($event->typeName, self::GQL_ELEMENT_INTERFACES, true)) {
                    $event->fields['imgix'] = [
                        'name' => 'imgix',
                        'type' => ImgixInterface::getType(),
                        'args' => ImgixArguments::getArguments(),
                        'resolve' => ImgixResolver::class . '::resolve',
                        'description' => 'This query is used to query for Imgix meta data.',
                    ];
                }
            });

This has been working well with the gatsby-source-graphql source, and I have been using it like this:

imgix(maxWidth: 800, maxHeight: 800, quality: 100) {...}

After installing gatsby-source-craft, I still see the custom type (imgix) on AssetInterface, but it doesn't list any of the params.

image

Now, I read the section about Integrating Third-Party Content, but this seems to apply only to source nodes?

Do I need to do anything else for the source to pick them up?

Additional info

andris-sevcenko commented 3 years ago

As discussed on Discord with @sjelfull - this is best-resolved by using custom fragments.