1
votes

I have got an error during a graphql API call in AWS amplify

I import the queries like (just like in the documentation with *):

import * as queries from '../graphql/queries';

This is my API request where I receive the error (Must provide Source):

const data = await API.graphql(graphqlOperation(queries.nearbyZVL, {filter: filter}));

And in the same file another API request like below is working correctly:

const result = await API.graphql(graphqlOperation(queries.getProfile, { id: cognitoUserId }));

The nearbyZVL is a custom query and resolver in AWS appsync. In the appsync console the query is working fine!

Some help is appreciated! :)

1

1 Answers

0
votes

Not sure why it is not generated in codegen - to create custom resolvers, did you manually edit on appsync console, or adding files under /amplify/backend? For the latter, it should codegen. If you did the former, consider do the latter.

In your case, you can simply do below:

const GetNearbyZVL = `...` // the query that works in appsync console

const data = await API.graphql(graphqlOperation(GetNearbyZVL, {filter: filter}));