Example of creating an application for the API on the basis of Yii2.
git clone git@github.com:kuaukutsu/yii2-example-api.git
cd ./www
composer global require "fxp/composer-asset-plugin:^1.3.1"
composer install --no-dev
composer run post-create-project-cmd
GET,POST https://rest.localhost/v1/user
GET,POST https://rest.localhost/ajax/user?token=xxx
GET,POST https://rest.localhost/graphql
query {
user(id:1) {
username
}
}
mutation {
user(id:1) {
save(input:{username:"test"}) {
username
}
}
}
Success:
{
"success": true,
"data": {
"user": {
"save": {
"username": "test"
}
}
}
}
Error:
{
"success": false,
"errors": [
[
{
"name": "username",
"message": [
"Необходимо заполнить «Username»."
]
}
]
]
}