Types is not iterable

Hello hwillson

thanks for your answer. Yes, I am using libphonenumber-js

const { parsePhoneNumber } = require(“libphonenumber-js”);
Yes, I check the console.log and the state is writing correctly, just the error but after I change the value String to Int in the type definition, graphql-tools/merge crash and showed me this error.

node_modules/@graphql-tools/merge/index.cjs.js:785
for (const type of types) {
^

TypeError: types is not iterable

I make a simple replication of the config I am using for.

It does not make anything, just a quick view of the way the project is build

Does somebody know what is the problem? and how to solve it?

This is the problem and the open with the code I am using.

Kind regards

A few suggestions:

  1. I highly recommend you use TypeScript for building your projects, it can be tremendously valuable in debugging these sorts of things. GraphQL and TypeScript go together really well!

  2. You have a typo in one of your directory names in your reproduction — grapqhl should be graphql. I don’t know if this was causing a problem sinc the enum.js was the same in both places, but I removed it.

  3. The schema was not defined in the index.js. I imported it by adding:

    const { schema } = require('./utils/schema');
    
  4. Your ./utils/schema is using ECMAScript modules (e.g., export const) but the rest of your project is all in CommonJS (e.g., expecting module.exports).

  5. Once I fixed all these things, I still received the error:

    Error: Unknown type "UserRoleEnum".
    
    Unknown type "User".
    

    … which seems to show that some pieces are still missing.

I recommend taking a bit more time to put together a reproduction and going through each of the errors I’ve noted above and carefully observing their error messages. In every case except the misspelling of GraphQL (something I personally do all the time by the way!), the console output or VS Code interface (which I also recommend!) showed me the source of the error.

It’s also worth noting that we have a great Apollo Odyssey tutorial available called Lift-off available. It does not use GraphQL Tools (a project which Apollo no longer maintains) but it does require familiarity and comfort with JavaScript.

Hello @abernix
Thanks for your response, the problem I solved it with put the types in an array and the resollver too, import them one by one.

And then merge them with graphql-tools

I watched the Odyssey, but until now it doesn´t mentioned something on how to do this.

Could you help me to find the best way of Apollo do this, also taking into account production settings. I am also added gateway but that will be a future improvement. By now I justa want to make the basic setting but also the most secure and performer way. I am attaching you a repo of the config I am doing. The current repo shows an error. I cannot fix it yet. I just copy from the original, it suppose that it mustn´t contain errors but …
The main problem is I am using correctly nested input in the resolver as well as type and also the DB is well done. as even when I create a user it shows me in the DB but in the playground shows me “retailer”: null and I cannot fix it yet. I think leave it as that is very bad practice.

Sorry for the questions. I am not a back-end experienced developer.

Also this is my folder structure, I added just two schemas and two resolvers but
I have this situation. With the service.resolver.js when I run it in playground, shows me null;
But I created this one for you to see you.

I leave you the link to the repo to clone it. Hope you can help me as well as teach me some best practices.

Thank you beforehand

copythelinkasitdoesn´tleavemepasteit —> thisisthelinkhttps://github.com/CesarAdan1/Project"

Blockquote