wp-graphql-acf
wp-graphql-acf copied to clipboard
Internal server error when using particular ACF meta fields
I ran into an issue this morning where using the "Page Link" field caused internal server errors. The only fix was to change the field type from "Page Link" to "Relationship". This stopped Apollo from throwing the internal server errors, but this is something my team and I have run into before.
Occasionally, we will encounter internal server errors and the only solution is to either delete the ACF field that is causing the issue and recreate it, or to change the meta field type. The only way we can figure out which field is causing the issue is via trial and error.
Any help would be greatly appreciated!
Side note. In this particular case, when using the Graphiql interface from the WP backend, the queries would successfully return data, even before we changed the field type. When queried from the frontend, it would fail.
This, however, is not always the case. There have been times in the past few months when we have experienced the issue on both the backend and frontend, only on the backend, or only on the frontend.
Same problem ... Looks like the inline fragmentation is killing it
// hmm back-ticks ruin the format...
const QUERY_POST_BY_ID = gql` query QUERY_POST_BY_ID($ID: ID!) { post(id: $ID) { postId id title author { lastName firstName } acf_posts { fieldGroupName posts { ... on WPGraphQL_Post_AcfPosts_acfPosts_Posts_Hero { fieldGroupName title wysiwyg } } } } } `
When removing ...on WPGraphQL_Post_AcfPosts_acfPosts_Posts_Hero
it works fine.
Let me know if some one has a solution.
update: When creating queries from http://localhost:8000/___graphql it doesn't work, but creating the queries using the WP GraphiQL plugin does work. There is a small difference (I don't know why both tools are reading the inline fragmentation differently)
difference: ___graphql creates: ... on WPGraphQL_Post_AcfPosts_acfPosts_Posts_Hero WP GraphiQL creates: ... on Post_AcfPosts_acfPosts_Posts_Hero
This one is going to be tough to reproduce, as the issue is so intermittent and inconsistent in it's behavior. I did run into it again yesterday, where I was receiving an internal server error through the graphiql interface in WP admin, but requests made from my own client application would work as intended. The issue resolved on its own after about ten minutes of troubleshooting.
@SunooBertsch could you maybe provide a PHP or JSON config for the particular ACF Field Group that's causing the issue so I can set it up the same as you locally?
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_5cccac8d93cd4',
'title' => 'Image Meta',
'fields' => array(
array(
'key' => 'field_5cccac9d781a1',
'label' => 'Video URL',
'name' => 'video_url',
'type' => 'url',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
),
array(
'key' => 'field_5cccacb8781a2',
'label' => 'Primary Color',
'name' => 'primary_color',
'type' => 'color_picker',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
),
array(
'key' => 'field_5d8eabc56cc17',
'label' => 'Focal Point X',
'name' => 'focal_point_x',
'type' => 'number',
'instructions' => 'Horizontal coordinate',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => 'focal-point',
'id' => 'focal-point-x',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '%',
'append' => '',
'min' => 0,
'max' => 100,
'step' => '',
),
array(
'key' => 'field_5d8eac216cc19',
'label' => 'Focal Point Y',
'name' => 'focal_point_y',
'type' => 'number',
'instructions' => 'Vertical coordinate',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => 'focal-point',
'id' => 'focal-point-y',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '%',
'append' => '',
'min' => 0,
'max' => 100,
'step' => '',
),
),
'location' => array(
array(
array(
'param' => 'attachment',
'operator' => '==',
'value' => 'image',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_graphql' => 1,
'graphql_field_name' => 'acfImageMeta',
));
acf_add_local_field_group(array(
'key' => 'group_5dbb4ce359157',
'title' => 'Page Meta',
'fields' => array(
array(
'key' => 'field_5dd73813f7711',
'label' => 'Video URL',
'name' => 'video_url',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5dbb4d6320348',
'label' => 'Director',
'name' => 'director',
'type' => 'relationship',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'post_type' => array(
0 => 'page',
),
'taxonomy' => '',
'filters' => array(
0 => 'search',
1 => 'post_type',
),
'elements' => array(
0 => 'featured_image',
),
'min' => '',
'max' => '',
'return_format' => 'id',
),
array(
'key' => 'field_5de6af307b092',
'label' => 'Related',
'name' => 'related',
'type' => 'relationship',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'post_type' => array(
0 => 'page',
1 => 'post',
),
'taxonomy' => '',
'filters' => array(
0 => 'search',
1 => 'post_type',
2 => 'taxonomy',
),
'elements' => array(
0 => 'featured_image',
),
'min' => '',
'max' => '',
'return_format' => 'id',
),
array(
'key' => 'field_5de6b2da66d67',
'label' => 'Credits',
'name' => 'credits',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'collapsed' => '',
'min' => 0,
'max' => 0,
'layout' => 'table',
'button_label' => '',
'sub_fields' => array(
array(
'key' => 'field_5de6b3673f6ac',
'label' => 'Name',
'name' => 'name',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5de6b3f63f6ad',
'label' => 'Value',
'name' => 'value',
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'new_lines' => '',
),
),
),
array(
'key' => 'field_5de6b44dba9fe',
'label' => 'Gallery',
'name' => 'gallery',
'type' => 'gallery',
'instructions' => 'Behind the scenes',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'return_format' => 'id',
'preview_size' => 'medium',
'insert' => 'append',
'library' => 'all',
'min' => '',
'max' => '',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
),
array(
'key' => 'field_5de6b516bfd89',
'label' => 'Accolades',
'name' => 'accolades',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'collapsed' => '',
'min' => 0,
'max' => 0,
'layout' => 'table',
'button_label' => '',
'sub_fields' => array(
array(
'key' => 'field_5de6b524bfd8a',
'label' => 'SVG',
'name' => 'svg',
'type' => 'image',
'instructions' => 'Works best when svgs are white.',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'return_format' => 'id',
'preview_size' => 'medium',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => 'svg, png',
),
array(
'key' => 'field_5de6b554bfd8b',
'label' => 'Text',
'name' => 'text',
'type' => 'textarea',
'instructions' => 'Separate each accolade by new line',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'new_lines' => '',
),
),
),
array(
'key' => 'field_5e29ed1bdfde8',
'label' => 'Press',
'name' => 'press',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'collapsed' => '',
'min' => 0,
'max' => 0,
'layout' => 'table',
'button_label' => '',
'sub_fields' => array(
array(
'key' => 'field_5e29ed2cdfde9',
'label' => 'Headline',
'name' => 'headline',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5e29ed35dfdea',
'label' => 'Outlet',
'name' => 'outlet',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5e29ed3bdfdeb',
'label' => 'Link',
'name' => 'link',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5e4052960d0ee',
'label' => 'Image',
'name' => 'image',
'type' => 'image',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'return_format' => 'array',
'preview_size' => 'medium',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
),
),
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 0,
'position' => 'side',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_graphql' => 1,
'graphql_field_name' => 'acfPageMeta',
));
acf_add_local_field_group(array(
'key' => 'group_5e41a62408ebe',
'title' => 'Secondary Featured Image',
'fields' => array(
array(
'key' => 'field_5e41a637e781f',
'label' => '',
'name' => 'secondary_featured_image',
'type' => 'image',
'instructions' => 'Image to be displayed on hover',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'show_in_graphql' => 1,
'return_format' => 'id',
'preview_size' => 'medium',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 0,
'position' => 'side',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_graphql' => 1,
'graphql_field_name' => 'acfSecondaryFeaturedImage',
));
acf_add_local_field_group(array(
'key' => 'group_5cae81a34f41b',
'title' => 'Developer Settings',
'fields' => array(
array(
'key' => 'field_5cae81f90d654',
'label' => 'Prevent non-developer deletion:',
'name' => 'prevent_deletion',
'type' => 'true_false',
'instructions' => 'This prevents this page from being deleted by a non-developer user.',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'message' => '',
'default_value' => 0,
'ui' => 1,
'ui_on_text' => '',
'ui_off_text' => '',
),
array(
'key' => 'field_5cae827c0d655',
'label' => 'Force text editor:',
'name' => 'force_text_editor',
'type' => 'true_false',
'instructions' => 'Force the WYSIWYG editor into text mode for this page.',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'message' => '',
'default_value' => 0,
'ui' => 1,
'ui_on_text' => '',
'ui_off_text' => '',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
array(
'param' => 'current_user_role',
'operator' => '==',
'value' => 'developer',
),
),
),
'menu_order' => 10,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'field',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_graphql' => 0,
'graphql_field_name' => 'acfDeveloperSettings',
));
endif;
This is our entire acf PHP file. The issue doesn't occur with a specific field, but rather any acf field at any given moment.
Just experienced the same issue as @SunooBertsch
closed by #301