Closed lubiah closed 11 months ago
The problem is that $extra
is array<string, mixed>
, not sure if we can just encode the value as type String
🤔. What sort of data usually gets stored here?
Source:
The problem is that
$extra
isarray<string, mixed>
, not sure if we can just encode the value as typeString
🤔. What sort of data usually gets stored here?
It stores data about about the styles or scripts.
For scripts,
For styles
@justlevine , I suggest we create two new ObjectTypes
for the extra found in an enqueuedScript and for that found in an enqueuedStyle
The problem is that
$extra
isarray<string, mixed>
, not sure if we can just encode the value as typeString
🤔. What sort of data usually gets stored here?It stores data about about the styles or scripts.
For scripts,
- data
- group
- strategy
For styles
- rlt
- suffix
- path
- conditional
@lubiah any chance you could point me to some documentation or a source of truth in the codebase for any of these? I need to understand the possible types and shapes in order to get this into core.
(I tried searching myself, and the best I could come up with is a script _WP_Dependency
also using the $extra['conditional']
var over here. )
@justlevine , there is no documentation though I can provide you with information where you can find them.
If you have the Wordpress codebase downloaded on your computer, a simple search for wp_style_add_data
or wp_script_add_data
or add_data
in your code editor can help you to find where it's being used.
The WP_Scripts
class and WP_Styles
class both inherit the WP_Dependencies
class which has a method called add_data
.
The method is responsible for adding data to the extra
so wherever it's being called can give you a hint of the possible types.
Would you need any more info??
Description
If you are trying to query about the extra information of an enqueued asset whether it being a style or a script, you get the wrong results.
Here are the reasons for the error.
extra
field tries to return a string, meanwhile it's an supposed to be an object.extra.data
and this property only exists on scripts, making it hard to extract other information. Also, there are other fields other than extra.data which whiles on the object so by returning onlyextra.data
, we are unable to access the other data.Here's proof.
Over here, you can see it's returning null for the data.
By using GraphQL debug, we can verify that many properties exist on the extra field but it's being forced to return a string
Steps to reproduce
1) Use this query on any random posts
Additional context
No response
WPGraphQL Version
Version 1.16.0
WordPress Version
6.3.1
PHP Version
PHP version 8.2.4
Additional enviornment details
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have disabled ALL plugins except for WPGraphQL.