const searchUsersQuery = (
`query SearchUsers($emails: [String], $phones: [String]) {
searchUsers(emails: $emails, phones: $phones) {
id
username
email
phone
}
}`
);
const emails = ['[email protected]'];
const phones = ['+390000000000'],
API.graphql(graphqlOperation(searchUsersQuery, { emails, phones }));
Produces:
TypeError: In this environment the sources for assign MUST be an object. This error is a performance optimization and not spec compliant.
at Object.assign (blob:http://192.168.1.72:19001/cee5007b-04f9-4e07-9f53-4b7aabf68f86:322:17)
at APIClass.<anonymous> (blob:http://192.168.1.72:19001/cee5007b-04f9-4e07-9f53-4b7aabf68f86:171006:48)
at step (blob:http://192.168.1.72:19001/cee5007b-04f9-4e07-9f53-4b7aabf68f86:170423:31)
at Object.next (blob:http://192.168.1.72:19001/cee5007b-04f9-4e07-9f53-4b7aabf68f86:170353:24)
at fulfilled (blob:http://192.168.1.72:19001/cee5007b-04f9-4e07-9f53-4b7aabf68f86:170305:36)
at tryCallOne (blob:http://192.168.1.72:19001/cee5007b-04f9-4e07-9f53-4b7aabf68f86:3844:14)
at blob:http://192.168.1.72:19001/cee5007b-04f9-4e07-9f53-4b7aabf68f86:3945:17
at blob:http://192.168.1.72:19001/cee5007b-04f9-4e07-9f53-4b7aabf68f86:3228:21
at _callTimer (blob:http://192.168.1.72:19001/cee5007b-04f9-4e07-9f53-4b7aabf68f86:3117:9)
at _callImmediatesPass (blob:http://192.168.1.72:19001/cee5007b-04f9-4e07-9f53-4b7aabf68f86:3153:9)
In package.json I have:
"dependencies": {
"@expo/vector-icons": "^6.3.1",
"amplify": "^0.0.11",
"aws-amplify": "^0.4.4",
"aws-amplify-react-native": "^0.2.15",
"connected-react-router": "^4.3.0",
"email-validator": "^2.0.4",
"expo": "^27.0.1",
"google-libphonenumber": "^3.1.6",
"moment": "^2.22.2",
"native-base": "^2.4.5",
"prop-types": "^15.6.1",
"react": "16.3.1",
"react-native": "^0.55.4",
"react-redux": "^5.0.7",
"react-router-native": "^4.2.0",
"redux": "^4.0.0",
"redux-form": "^7.3.0",
"redux-thunk": "^2.3.0",
"uuid": "^3.2.1"
}
I have the same problem without query variables:
const query = (
`query SearchUsers {
searchUsers(
emails: [${emails.map(email => `"${email}"`).join(', ')}],
phones: [${phones.map(phone => `"${phone}"`).join(', ')}]
) {
id
username
email
phone
}
}`
);
await API.graphql(graphqlOperation(query));
I have a similar issue; my debugging lead to the graphql_headers that I have set:
graphql_headers: async () => {
const { idToken } = await Auth.currentSession();
return { Authorization: idToken.jwtToken };
}
Looking at the stacktrace from the OP, it could be the same cause.
Your AppSync API has authentication method as Cognito UserPools?
For me, it reuses the JWT token for authorization, but that backend accepts it a bit different then the default AWS setup, hence using graphql_headers to override it.
Btw, for me I switched back to Apollo, since I did not see the added value since I'm doing the authorization custom anyway...
I'm experiencing the same if I delete the graphql_headers it works...
This has been fixed with React 16.7.0