Apoll query works locally but returns 400 during the build on Vercel
Unanswered
Afghan Hound posted this in #help-forum
Afghan HoundOP
I hope someone has some new ideas. I've checked it locally a million times and run the query from my graphql endpoint with no problem. BUT everytime I try to push that to Vercel, the build fails with a 400 error. I think I may have tracked it down to $or but can't guarantee it.
typedef:
resolver:
query:
component using apollo nextjs 13 experimental :
Is there something going on between Apollo and Next that is causing the build error with Vercel?
typedef:
searchUsers(searchTerm: String): [Users]resolver:
searchUsers: async (_, { searchTerm }) => {
try {
const db = await dbConnect();
const users = await Users.find({
$or: [
{ first_name: { $regex: searchTerm, $options: 'i' } },
{ user_name: { $regex: searchTerm, $options: 'i' } }
]
});
return users;
} catch (error) {
// Log the error and any additional information
console.log('Error in searchUsers resolver:', error);
console.log('Search term:', searchTerm);
// log the error stack trace
console.log('Error stack trace:', error.stack);
}
}query:
export const QUERY_USER_SEARCH_RESULTS = gql`
query searchUsers($searchTerm: String) {
searchUsers(searchTerm: $searchTerm) {
first_name
last_name
headline
user_name
user_or_real
profile_url
photoURL
firebase_uid
}
}`component using apollo nextjs 13 experimental :
const { data, error } = useSuspenseQuery(QUERY_USER_SEARCH_RESULTS,
{
variables: {
"searchTerm": searchTerm
}
})
console.log(JSON.stringify(data) + ' data from server in results component')
if (error) {
console.log('Error in getting profile data in User Search: ' + error.message);
}Is there something going on between Apollo and Next that is causing the build error with Vercel?