The `ER_NET_PACKET_TOO_LARGE` error from Ghost Content API while building Gatsby

I’ve just got this error while building Gatsby:

“gatsby-source-ghost” threw an error while running the sourceNodes lifecycle:

select distinct users.*, posts_authors.post_id as _pivot_post_id, posts_authors.author_id as _pivot_author_id, posts_authors.sort_order as _pivot_sort_order from users inner join posts_authors on posts_authors.author_id = users.id where posts_authors.post_id in (‘5e1f
4adab2bc9211f8af859c’, …
', ‘5d4af5f3f500122f6e3e9366’, ‘5d4962f0f500122f6e3e8e9e’) order by sort_order ASC - ER_NET_PACKET_TOO_LARGE: Got a packet bigger than ‘max_allowed_pa
cket’ bytes

As I understand here’s the error:

ER_NET_PACKET_TOO_LARGE: Got a packet bigger than 'max_allowed_pa
cket’ bytes

I’ve Googled a bit and it seems it comes from MySQL. Anyone encountered that error? The current value in mysqld.cnf is 16M:

max_allowed_packet = 16M

I can make a fix by increasing max_allowed_packet to say 100M, by not sure that’s the right way to go. I’m wondering how a simple select could go over 16M and it never happened with handlebars engine

I’ve done some investigation. max_allowed_packet is defined for both client mysql and server mysqld. The value from mysqld.cnf is 16M, but when I ran the query I got the error:

[S1000] Packet for query is too large (2,127 > 2,048). You can change this value on the server by setting the ‘max_allowed_packet’ variable.

with the limit of 2048. So I ran:

SHOW VARIABLES LIKE 'max_allowed_packet';

which gave me the exact value 2048. So the problem seems to be with the limit on client side, not the server. Now I need to set the client side limit to 16 Mb. Started looking how to do that.