By default hooks from latest @trycourier/react-hooks (^1.53.1) will make queries to an unusual URL: https://fxw3r7gdm9.execute-api.us-east-1.amazonaws.com/production/q
I guess it was supposed to be production but it’s not. The request is passing auth (clientKey) but it doesn’t get any messages.
For example, component from @trycourier/react-inbox
will make requests to https://api.courier.com/client/q and return all my messages successfully with the same provider. So I guess the database is different.
If I change apiUrl to https://api.courier.com/client/q
then it will not work for hooks again, GraphQL schema is different at endpoints.
So this code:
export default function Inbox() {
return (
<CourierProvider
apiUrl="https://api.courier.com/client/q"
userId={USER_ID}
clientKey={MY_KEY}
>
<CustomCourierInbox />
</CourierProvider>
);
}
function CustomCourierInbox() {
const inbox = useElementalInbox();
useEffect(() => {
inbox.fetchMessages();
}, []);
return (
<div>
{inbox?.messages?.map((message, index) => (
<div key={index}>{message?.body}</div>
))}
</div>
);
}
Will make the following query: query GetInboxMessages($params: FilterParamsInput, $limit: Int = 10, $after: String) {\n messages(params: $params, limit: $limit, after: $after) {\n totalCount\n pageInfo {\n startCursor\n hasNextPage\n __typename\n }\n nodes {\n title\n preview\n messageId\n read\n created\n actions {\n background_color\n content\n href\n style\n __typename\n }\n __typename\n }\n __typename\n }\n
At https://api.courier.com/client/q
this query will fail:
[
{
"message": "Cannot query field \"title\" on type \"Messages\".",
"locations": [
{
"line": 10,
"column": 7
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED"
}
},
{
"message": "Cannot query field \"preview\" on type \"Messages\".",
"locations": [
{
"line": 11,
"column": 7
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED"
}
},
{
"message": "Cannot query field \"actions\" on type \"Messages\".",
"locations": [
{
"line": 15,
"column": 7
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED"
}
}
]
This query will work though at https://fxw3r7gdm9.execute-api.us-east-1.amazonaws.com/production/q
but it will not get any messages