Skip to content

Conversation

@dyontaistaton
Copy link
Contributor

…custom content types with POST method requests

What does this implement/fix? Explain your changes.

This adds a filter to the WPGraphQL\Request\is_valid_http_content_type function which would allow someone to control this bool on special occasions. I am using a plugin which uses multipart/form-data as the content type to achieve file uploads. My uploads were failing do to a conditional using this bool down the line. With this filter now I can allow for "multipart/form-data" as a valid content type.

Does this close any currently open issues?

I haven't seen anyone with this issue.

Any relevant logs, error output, GraphiQL screenshots, etc?

For anyone else out there I am using this plugin WPGraphQL Upload and am getting this error "HTTP POST requests must have Content-Type: application/json header. Received: multipart/form-data; boundary=----WebKitFormBoundaryVpEsC5PmSqBvXqK5"

Any other comments?

Good work fellow engineers

Where has this been tested?

Operating System:
Mac OS: 15.2

WordPress Version:
6.7.2

…custom content types with POST method requests
@jasonbahl
Copy link
Collaborator

Related #3323

@coveralls
Copy link

coveralls commented Feb 28, 2025

Coverage Status

coverage: 82.702% (-0.005%) from 82.707%
when pulling be34b45 on dyontaistaton:patch-1
into aedd4f6 on wp-graphql:develop.

justlevine
justlevine previously approved these changes Mar 3, 2025
Copy link
Collaborator

@justlevine justlevine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than unnecessary whitespace that leaked, this LGTM.

Ideally I'd want to dogfood this with a matching PR in WPGraphQL Upload just to confirm there's nothing beyond the filter that we're overlooking, but I'm traveling and not sure if/when I'll have time

@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit 9cec147 and detected 0 issues on this pull request.

View more on Code Climate.

@jasonbahl jasonbahl merged commit 8490d24 into wp-graphql:develop Mar 4, 2025
4 checks passed
@jasonbahl jasonbahl mentioned this pull request Mar 4, 2025
3 tasks
@jasonbahl jasonbahl changed the title feat: add filter to Request::is_valid_http_content_type to allow for … feat: add filter to Request::is_valid_http_content_type to allow for custom content types with POST method requests Mar 4, 2025
<exclude name="WordPress.WP.Capabilities.Undetermined" />

<!-- Include only once we support PHP 8.3 and above -->
<exclude name="SlevomatCodingStandard.TypeHints.ClassConstantTypeHint" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justlevine - Commenting for myself so I remember to update wpgraphql-coding-standards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants