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

TypeError: is not a function or its return value is not iterable #45

Open
MincePie opened this issue Oct 12, 2021 · 2 comments
Open

TypeError: is not a function or its return value is not iterable #45

MincePie opened this issue Oct 12, 2021 · 2 comments

Comments

@MincePie
Copy link

At 9:17, this code:

const [{ data, fetching }] = usePostsQuery({
        variables,
      });

is causing an error:

TypeError: (0 , generated_graphql__WEBPACK_IMPORTED_MODULE_4_.usePostsQuery) is not a function or its return value is not iterable

The difference between Ben's updoot branch is that his generated/graphql has got an export as:

export function usePostsQuery(options: Omit<Urql.UseQueryArgs<PostsQueryVariables>, 'query'> = {}) {
  return Urql.useQuery<PostsQuery>({ query: PostsDocument, ...options });
};

Mine does not. I did run the generator successfully and my generated/graphql does include a Query for posts. It does not however have the above export function.

How do I look for the source of this problem? I'm trying to learn as much as I'm trying to solve this particular problem. Any advice for how to approach problem solving would be gratefully received. I thought the generated/graphql file was created by running yarn gen.

Thank you

@aseerkt
Copy link

aseerkt commented Oct 23, 2021

@MincePie Seems like graphql-codegen is not generating hooks in your case. Can you share the codegen.yml file?

@MincePie
Copy link
Author

@aseerkt it's strange because it did create the query. I have given up on trying to figure out this tutorial. I think maybe I found it too late to make it work with the current packages used in the project. I found this tutorial, which is more recent and I'll switch focus to try to learn from that project: https://www.prisma.io/blog/fullstack-nextjs-graphql-prisma-oklidw1rhw. If I find an answer, I'll share it in the discord to try and help anyone else that might get stuck with the same problem. Thanks anyway for offering to help.

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