Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jsakars opened this issue Oct 3, 2023 · 10 comments
Open
Assignees
Labels

Comments

@jsakars
Copy link

jsakars commented Oct 3, 2023

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?

@Vincz
Copy link
Collaborator

Vincz commented Oct 4, 2023

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

@jsakars
Copy link
Author

jsakars commented Oct 4, 2023

@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

@Vincz
Copy link
Collaborator

Vincz commented Oct 5, 2023

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 Vincz self-assigned this Oct 5, 2023
@Vincz Vincz added the bug label Oct 5, 2023
@jsakars jsakars closed this as completed Oct 5, 2023
@jsakars jsakars reopened this Oct 5, 2023
@vitek-rostislav
Copy link

Hi, any news on this, please?

@Vincz
Copy link
Collaborator

Vincz commented Dec 22, 2023

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

@vitek-rostislav
Copy link

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

@Vincz
Copy link
Collaborator

Vincz commented Dec 22, 2023

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

@kasperh90
Copy link

kasperh90 commented Feb 22, 2024

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.

@edhgoose
Copy link
Contributor

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.

@Vincz
Copy link
Collaborator

Vincz commented Feb 28, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants