GraphQLBundle icon indicating copy to clipboard operation
GraphQLBundle copied to clipboard

Could not find type with alias "Subscription". Did you forget to define it?

Open jsakars opened this issue 1 year ago • 10 comments

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Version/Branch 1.0.0

Using latest stable Symfony and this bundle and given the following config/packages/graphql.yaml content:

overblog_graphql:
    definitions:
        schema:
            query: Query
            mutation: Mutation

Symfony profiler shows the following error when trying to access GraphQL section: An exception has been thrown during the rendering of a template ("Could not find type with alias "Subscription". Did you forget to define it?")..

Now with the following config/packages/graphql.yaml content:

overblog_graphql:
    definitions:
        schema:
            query: Query

Symfony profiler shows the following error when trying to access GraphQL section: An exception has been thrown during the rendering of a template ("Could not find type with alias "Mutation". Did you forget to define it?").

It seems that GraphQL profiler expects ALL types (query, mutations, subscription) to be defined even though one might not have some of them (e.g. only the queries).

It seems to work adding some dummy type definition e.g.:

type Subscription {
    id: ID!
}

Is there something missing in the default configuration?

jsakars avatar Oct 03 '23 22:10 jsakars

Hi @jsakars. I have not been able to reproduce (I though I did, but I had a Subscription defined in my config). Can you confirm that you are on the last version of this bundle? Also, do you mind to send me a trace? This bug was supposed to be addressed by https://github.com/overblog/GraphQLBundle/pull/1122/files#diff-d413d9e605026f2780d7e9daf63a24695e2ec842f163b6101e3a09d8c286806e

Vincz avatar Oct 04 '23 07:10 Vincz

@Vincz hi!

thanks for looking into this. I can confirm I am on a latest stable version of this bundle - ^1.0

here is the full config/packages/graphql.yaml content:

overblog_graphql:
    definitions:
        schema:
            query: Query
            mutation: Mutation
        mappings:
            types:
                -
                    type: graphql
                    dir: "%kernel.project_dir%/config/graphql/types"
                    suffix: null
                -   type: attribute
                    dir: "%kernel.project_dir%/src"
                    suffix: null

when@dev:
    overblog_graphql:
        definitions:
            show_debug_info: true

Here is the stack trace: image

jsakars avatar Oct 04 '23 12:10 jsakars

Also related, the errors messages are not explicit anymore as webonyx perform PHP type checking on the return of type resolution.

In Schema.php line 362:                                                                                                               
GraphQL\Type\Schema::resolveType(): Return value must be of type GraphQL\Type\Definition\Type, null returned  

So we don't know what type is missing in case of missing type.

Vincz avatar Oct 05 '23 07:10 Vincz

Hi, any news on this, please?

vitek-rostislav avatar Dec 21 '23 15:12 vitek-rostislav

@vitek-rostislav Do you still have the issue using the latest commits ? (using master) ?

Vincz avatar Dec 22 '23 08:12 Vincz

Hi, @Vincz, I tried it now using master and sadly yes, the problem is still there. We are using a similar configuration - just queries and mutations, the config is here - https://github.com/shopsys/shopsys/blob/14.0/project-base/app/config/packages/overblog_graphql.yaml

vitek-rostislav avatar Dec 22 '23 11:12 vitek-rostislav

Ok, I'll check asap and publish a new version.

Vincz avatar Dec 22 '23 11:12 Vincz

stack.txt I just got this issue right now as well. I am using v1.10

See attached file for the stack trace provided by Symfonys exception page.

kasperh90 avatar Feb 22 '24 16:02 kasperh90

We've just updated to 1.10 and are hitting the same problem too.

We've written our own wrapper to handle some customised generation we do, so we're calling:

        $schema = $this->executor->getSchema();
        SchemaPrinter::doPrint($schema)

We've found the fix proposed to add $typeResolver->setIgnoreUnresolvableException(true); works, but it'd be great to try and determine why this happens.

Our config is like this:

overblog_graphql:
    definitions:
        config_validation: "%kernel.debug%"
        auto_compile: true
        schema:
            query: Query
            mutation: Mutation
            types:
                ... types

Happy to help debug it if we can.

edhgoose avatar Feb 28 '24 11:02 edhgoose

It's fixed on master. I'll check the other pending PR and publish a new version soon.

Vincz avatar Feb 28 '24 12:02 Vincz