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

Code splitting: "Invariant Violation: RelayModernGraphQLTag: Expected a request, , got {}" when using async getQuery #294

Closed
dminkovsky opened this issue Jun 30, 2019 · 3 comments

Comments

@dminkovsky
Copy link
Contributor

dminkovsky commented Jun 30, 2019

In Thread.js

export const threadQuery = graphql`
    # some query
`;

Fails:

{
        path: '/message',
        getComponent: async () => {
                const module = await import('./Thread');
                return module.default;
        },
        getQuery: async () => {
                const module = await import('./Thread');
                return module.threadQuery;
        },
},

Screen Shot 2019-06-30 at 7 34 11 AM

Does getQuery() have to be sync?

Screen Shot 2019-06-30 at 7 39 47 AM

Thank you

PS. Obviously not a blocking issue.

@dminkovsky dminkovsky changed the title "Invariant Violation: RelayModernGraphQLTag: Expected a request, , got {}" when using async getQuery Code splitting: "Invariant Violation: RelayModernGraphQLTag: Expected a request, , got {}" when using async getQuery Jun 30, 2019
@taion
Copy link
Member

taion commented Jun 30, 2019

We don't currently support async getQuery calls. In general this is not necessarily what you'd want anyway. It seems that in most code splitting use cases, it makes more sense to have the query in the main bundle, and fetch both the data and the new code in parallel, as opposed to waiting for the code fetching to complete before requesting the data.

@dminkovsky
Copy link
Contributor Author

Ah makes a lot of sense. Thank you.

@taion
Copy link
Member

taion commented Jul 1, 2019

Tracking this as a feature request in #297

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

No branches or pull requests

2 participants