GraphQL Expected Iterable, but did not find one for field xxx.yyy

I ran into this problem as well. It appears that what you’re returning from your resolver doesn’t match the return type in your schema. Specifically for the error message Expected Iterable, but did not find one for field library.user., your schema expects an array(Iterable) but you aren’t returning an array in your resolver I had … Read more

Get GraphQL whole schema query

Update Using graphql-cli is now the recommended workflow to get and update your schema. The following commands will get you started: # install via NPM npm install -g graphql-cli # Setup your .graphqlconfig file (configure endpoints + schema path) graphql init # Download the schema from the server graphql get-schema You can even listen for … Read more

What’s the point of input type in GraphQL?

From the spec: The GraphQL Object type (ObjectTypeDefinition)… is inappropriate for re‐use [as an input], because Object types can contain fields that define arguments or contain references to interfaces and unions, neither of which is appropriate for use as an input argument. For this reason, input objects have a separate type in the system. That’s … Read more

In GraphQL what’s the meaning of “edges” and “node”?

Let’s begin with a short introduction in simple words GraphQl Relay specifications mechanism for refetching an object description of how to page through connections structure around mutations to make them predictable Connections: a connection is a collection of objects with metadata such as edges, pageInfo… pageInfo will contain hasNextPage, hasPreviousPage, startCursor, endCursor hasNextPage will tell … Read more

How to properly make mock throw an error in Jest?

Change .mockReturnValue with .mockImplementation: yourMockInstance.mockImplementation(() => { throw new Error(); }); in case you want to assert test(‘the fetch fails with an error’, () => { return expect(fetchData()).rejects.toMatch(‘error’); }); If it’s a promise you can also to .rejects www.jestjs.io/docs/en/asynchronous#resolves–rejects

When and How to use GraphQL with microservice architecture

Definitely approach #1. Having your clients talk to multiple GraphQL services (as in approach #2) entirely defeats the purpose of using GraphQL in the first place, which is to provide a schema over your entire application data to allow fetching it in a single roundtrip. Having a shared nothing architecture might seem reasonable from the … Read more