There is no problem not worth solving, and no technology not worth learning!

In Laravel 6 and Lighthouse 5, the parameter $args of the method __invoke has an internal order that is inconsistent with the front-end request parameters

前端请求参数如下所示

1. The front-end request parameters are shown below. as shown in Figure 1

前端请求参数如下所示
Figure 1

{
  "query": "\nmutation ThemeUpdate($themeId: ID!, $settings: [ThemeSettingDataInput!], $sections: [ThemeSettingsDataSectionInput!], $appEmbeds: [ThemeSettingsDataBlockInput!], $sessionId: String!) {\n  onlineStoreThemeSettingsDataUpdate(\n    themeId: $themeId\n    settings: $settings\n    sections: $sections\n    appEmbeds: $appEmbeds\n    sessionId: $sessionId\n  ) {\n    sessionId\n    __typename\n  }\n}\n",
  "variables": {
    "themeId": "97cdd852-2ca0-48eb-b119-6afb68e2254c",
    "settings": [],
    "sections": [
      {
        "sectionId": "announcement-bar",
        "disabled": false,
        "type": "announcement-bar",
        "settings": [
          {
            "settingId": "enable",
            "value": "true"
          },
          {
            "settingId": "homepage_only",
            "value": "false"
          },
          {
            "settingId": "sticky",
            "value": "false"
          }
        ],
        "blocks": [
          {
            "blockId": "announcement-bar-0",
            "disabled": true,
            "type": "announcement",
            "settings": [
              {
                "settingId": "text",
                "value": "❤Free Shipping Over $100.0❤"
              },
              {
                "settingId": "image",
                "value": ""
              },
              {
                "settingId": "mobile_image",
                "value": ""
              },
              {
                "settingId": "background_color",
                "value": "#000000"
              },
              {
                "settingId": "text_color",
                "value": "#ffffff"
              },
              {
                "settingId": "link",
                "value": ""
              }
            ]
          }
        ]
      },
      {
        "sectionId": "header",
        "disabled": false,
        "type": "header",
        "settings": [
          {
            "settingId": "sticky",
            "value": "false"
          },
          {
            "settingId": "menu",
            "value": ""
          },
          {
            "settingId": "secondary_menu",
            "value": ""
          },
          {
            "settingId": "text_color",
            "value": "#000000"
          },
          {
            "settingId": "background_color",
            "value": "#ffffff"
          },
          {
            "settingId": "transparent",
            "value": "true"
          },
          {
            "settingId": "transparent_text_color",
            "value": "#ffffff"
          },
          {
            "settingId": "logo",
            "value": ""
          },
          {
            "settingId": "logo_max_width",
            "value": "180"
          }
        ],
        "blocks": []
      },
      {
        "sectionId": "footer",
        "disabled": false,
        "type": "footer",
        "settings": [
          {
            "settingId": "style",
            "value": "first"
          },
          {
            "settingId": "1",
            "value": ""
          },
          {
            "settingId": "text_color",
            "value": "#222222"
          },
          {
            "settingId": "background_color",
            "value": "#f7f7f9"
          },
          {
            "settingId": "4",
            "value": ""
          },
          {
            "settingId": "show_payment_icons",
            "value": "false"
          },
          {
            "settingId": "show_dmca",
            "value": "true"
          }
        ],
        "blocks": []
      }
    ],
    "appEmbeds": [],
    "sessionId": "gY32VAiyjotH8tsfJQZ5aopd9okgAZE4dExf"
  },
  "operationName": "ThemeUpdate"
}


2. The backend converts the parameter $args of the method __invoke to json, which corresponds to the field in the front-end request body: variables. The code is implemented as follows


    public function __invoke($rootValue, array $args, GraphQLContext $context, ResolveInfo $resolveInfo)
    {
        $variables = json_encode($args);
        echo $variables;
        exit;
	}


3. Print the JSON as follows. There are more fields: directive, and then the order of the keys inside the json is inconsistent with the frontend. Appembeds should have been in 4th position, now in 2nd digit


{
  "themeId": "97cdd852-2ca0-48eb-b119-6afb68e2254c",
  "appEmbeds": [],
  "settings": [],
  "sections": [
    {
      "sectionId": "announcement-bar",
      "type": "announcement-bar",
      "disabled": false,
      "settings": [
        {
          "settingId": "enable",
          "value": "true"
        },
        {
          "settingId": "homepage_only",
          "value": "false"
        },
        {
          "settingId": "sticky",
          "value": "false"
        }
      ],
      "blocks": [
        {
          "blockId": "announcement-bar-0",
          "type": "announcement",
          "disabled": true,
          "settings": [
            {
              "settingId": "text",
              "value": "❤Free Shipping Over $100.0❤"
            },
            {
              "settingId": "image",
              "value": ""
            },
            {
              "settingId": "mobile_image",
              "value": ""
            },
            {
              "settingId": "background_color",
              "value": "#000000"
            },
            {
              "settingId": "text_color",
              "value": "#ffffff"
            },
            {
              "settingId": "link",
              "value": ""
            }
          ]
        }
      ]
    },
    {
      "sectionId": "header",
      "type": "header",
      "disabled": false,
      "settings": [
        {
          "settingId": "sticky",
          "value": "false"
        },
        {
          "settingId": "menu",
          "value": ""
        },
        {
          "settingId": "secondary_menu",
          "value": ""
        },
        {
          "settingId": "text_color",
          "value": "#000000"
        },
        {
          "settingId": "background_color",
          "value": "#ffffff"
        },
        {
          "settingId": "transparent",
          "value": "true"
        },
        {
          "settingId": "transparent_text_color",
          "value": "#ffffff"
        },
        {
          "settingId": "logo",
          "value": ""
        },
        {
          "settingId": "logo_max_width",
          "value": "180"
        }
      ],
      "blocks": []
    },
    {
      "sectionId": "footer",
      "type": "footer",
      "disabled": false,
      "settings": [
        {
          "settingId": "style",
          "value": "first"
        },
        {
          "settingId": "1",
          "value": ""
        },
        {
          "settingId": "text_color",
          "value": "#222222"
        },
        {
          "settingId": "background_color",
          "value": "#f7f7f9"
        },
        {
          "settingId": "4",
          "value": ""
        },
        {
          "settingId": "show_payment_icons",
          "value": "false"
        },
        {
          "settingId": "show_dmca",
          "value": "true"
        }
      ],
      "blocks": []
    }
  ],
  "sessionId": "gY32VAiyjotH8tsfJQZ5aopd9okgAZE4dExf",
  "directive": null
}


4. Get the request parameters based on ILUMINATE\HTTP\request. The order is still inconsistent. Appembeds should have been in 4th position and now at 2nd.


print_r($context->request()->input('variables'));
exit;



{
  "themeId": "97cdd852-2ca0-48eb-b119-6afb68e2254c",
  "settings": [],
  "sections": [
    {
      "sectionId": "announcement-bar",
      "disabled": false,
      "type": "announcement-bar",
      "settings": [
        {
          "settingId": "enable",
          "value": "true"
        },
        {
          "settingId": "homepage_only",
          "value": "false"
        },
        {
          "settingId": "sticky",
          "value": "false"
        }
      ],
      "blocks": [
        {
          "blockId": "announcement-bar-0",
          "disabled": false,
          "type": "announcement",
          "settings": [
            {
              "settingId": "text",
              "value": "❤Free Shipping Over $100.0❤"
            },
            {
              "settingId": "image",
              "value": null
            },
            {
              "settingId": "mobile_image",
              "value": null
            },
            {
              "settingId": "background_color",
              "value": "#000000"
            },
            {
              "settingId": "text_color",
              "value": "#ffffff"
            },
            {
              "settingId": "link",
              "value": null
            }
          ]
        }
      ]
    },
    {
      "sectionId": "header",
      "disabled": false,
      "type": "header",
      "settings": [
        {
          "settingId": "sticky",
          "value": "false"
        },
        {
          "settingId": "menu",
          "value": null
        },
        {
          "settingId": "secondary_menu",
          "value": null
        },
        {
          "settingId": "text_color",
          "value": "#000000"
        },
        {
          "settingId": "background_color",
          "value": "#ffffff"
        },
        {
          "settingId": "transparent",
          "value": "true"
        },
        {
          "settingId": "transparent_text_color",
          "value": "#ffffff"
        },
        {
          "settingId": "logo",
          "value": null
        },
        {
          "settingId": "logo_max_width",
          "value": "180"
        }
      ],
      "blocks": []
    },
    {
      "sectionId": "footer",
      "disabled": false,
      "type": "footer",
      "settings": [
        {
          "settingId": "style",
          "value": "first"
        },
        {
          "settingId": "1",
          "value": null
        },
        {
          "settingId": "text_color",
          "value": "#222222"
        },
        {
          "settingId": "background_color",
          "value": "#f7f7f9"
        },
        {
          "settingId": "4",
          "value": null
        },
        {
          "settingId": "show_payment_icons",
          "value": "false"
        },
        {
          "settingId": "show_dmca",
          "value": "true"
        }
      ],
      "blocks": []
    }
  ],
  "appEmbeds": [],
  "sessionId": "gY32VAiyjotH8tsfJQZ5aopd9okgAZE4dExf"
}


5. Obtain the original content of the request body based on illuminate\http\request. The order of the front and back ends is the same. The location of Appembeds is now 4th. The code is implemented as follows


$content = json_decode($context->request()->getContent(), true);
echo json_encode($content['variables']);
exit;



{
  "themeId": "97cdd852-2ca0-48eb-b119-6afb68e2254c",
  "settings": [],
  "sections": [
    {
      "sectionId": "announcement-bar",
      "disabled": false,
      "type": "announcement-bar",
      "settings": [
        {
          "settingId": "enable",
          "value": "true"
        },
        {
          "settingId": "homepage_only",
          "value": "false"
        },
        {
          "settingId": "sticky",
          "value": "false"
        }
      ],
      "blocks": [
        {
          "blockId": "announcement-bar-0",
          "disabled": false,
          "type": "announcement",
          "settings": [
            {
              "settingId": "text",
              "value": "❤Free Shipping Over $100.0❤"
            },
            {
              "settingId": "image",
              "value": ""
            },
            {
              "settingId": "mobile_image",
              "value": ""
            },
            {
              "settingId": "background_color",
              "value": "#000000"
            },
            {
              "settingId": "text_color",
              "value": "#ffffff"
            },
            {
              "settingId": "link",
              "value": ""
            }
          ]
        }
      ]
    },
    {
      "sectionId": "header",
      "disabled": false,
      "type": "header",
      "settings": [
        {
          "settingId": "sticky",
          "value": "false"
        },
        {
          "settingId": "menu",
          "value": ""
        },
        {
          "settingId": "secondary_menu",
          "value": ""
        },
        {
          "settingId": "text_color",
          "value": "#000000"
        },
        {
          "settingId": "background_color",
          "value": "#ffffff"
        },
        {
          "settingId": "transparent",
          "value": "true"
        },
        {
          "settingId": "transparent_text_color",
          "value": "#ffffff"
        },
        {
          "settingId": "logo",
          "value": ""
        },
        {
          "settingId": "logo_max_width",
          "value": "180"
        }
      ],
      "blocks": []
    },
    {
      "sectionId": "footer",
      "disabled": false,
      "type": "footer",
      "settings": [
        {
          "settingId": "style",
          "value": "first"
        },
        {
          "settingId": "1",
          "value": ""
        },
        {
          "settingId": "text_color",
          "value": "#222222"
        },
        {
          "settingId": "background_color",
          "value": "#f7f7f9"
        },
        {
          "settingId": "4",
          "value": ""
        },
        {
          "settingId": "show_payment_icons",
          "value": "false"
        },
        {
          "settingId": "show_dmca",
          "value": "true"
        }
      ],
      "blocks": []
    }
  ],
  "appEmbeds": [],
  "sessionId": "gY32VAiyjotH8tsfJQZ5aopd9okgAZE4dExf"
}


PHP / Laravel / Yii2 Legacy Project Maintenance & Long-Term Technical Support

If your PHP / Laravel / Yii2 project is already in production but needs bug fixing, API troubleshooting, performance optimization, developer handover support, or long-term maintenance, feel free to contact me for remote technical support.

Ideal For:
✅ PHP legacy systems without active maintenance
✅ Laravel / Yii2 project bug fixes
✅ Admin panel feature iterations
✅ RESTful API troubleshooting
✅ MySQL / Redis / Nginx performance issues
✅ Long-term remote part-time maintenance

We can start with a small task:
✅ Production error troubleshooting
✅ API issue analysis
✅ Slow query and performance bottleneck diagnosis
✅ Initial code structure review
✅ Deployment environment and log inspection

If you would like to discuss your project, please contact me and mention: PHP Maintenance Consultation.

Contact Me:
Telegram: @shuijingwan
WeChat: 13980074657
Email: shuijingwanwq@gmail.com

评论

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.