1. The table field names use lowercase letters with underscores. See Figure 1.

2. The API is implemented based on GraphQL, and the specification requires that the field names in the API response use camelCase.
type ThemeAsset
{
"ID"
id: ID!
"主题ID"
themeId: String!,
"版本"
version: String!,
"内容"
content: String,
"路径,相对于主题的路径,如 ages/index.blade.php"
key: String!,
"MIME 类型"
mimeType: String!,
"类别,page、component、config(仅这3种类型有配置),asset、unknown"
category: String!,
"主题的 Schema,包括页面、主题、组件"
schema: String,
"创建时间"
createdAt: DateTime!
"更新时间"
updatedAt: DateTime
}
3. Print $themeAssets in the method of the resolver /Modules/ThemeStore/Resolver/OnlineStoreTheme/ThemeAssetsResolver.php, and the object property names use lowercase letters with underscores. See Figure 2.

<?php
namespace Modules\ThemeStore\Resolver\OnlineStoreTheme;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
use GraphQL\Type\Definition\ResolveInfo;
use Modules\ThemeStore\Entities\ThemeAsset;
class ThemeAssetsResolver
{
public function __invoke($rootValue, array $args, GraphQLContext $context, ResolveInfo $resolveInfo)
{
$themeId = $rootValue['themeAssets']['theme_id'];
$themeAssets = ThemeAsset::where('theme_id', $themeId)->get();
print_r($themeAssets);
exit;
}
}4. Option 1 is to iterate over $themeAssets using a foreach loop, assign the values to a new array, and set the keys to camelCase in this array. Option 2 is to rename the fields to camelCase directly in the select query statement. I ultimately decided to adopt Option 2.
public function __invoke($rootValue, array $args, GraphQLContext $context, ResolveInfo $resolveInfo)
{
$themeId = $rootValue['themeAssets']['theme_id'];
$themeAssets = ThemeAsset::where('theme_id', $themeId)
->select(
'id',
'theme_id as themeId',
'version',
'content',
'asset_key as key',
'mime_type as mimeType',
'category',
'schema',
'created_at as createdAt',
'updated_at as updatedAt'
)
->get();
return $themeAssets;
}
5. Request the API, and the response field names are in camelCase. This meets expectations. See Figure 3.

6. View the generated raw SQL statement in the logs. See Figure 4.

select
`id`,
`theme_id` as `themeId`,
`version`,
`content`,
`asset_key` as `key`,
`mime_type` as `mimeType`,
`category`,
`schema`,
`created_at` as `createdAt`,
`updated_at` as `updated_at`
from
`theme_asset`
where
`theme_id` = 'vogue'
