Actix GraphQL Example
참고로 한 것은 본가 actix의 example의 juniper-advanced입니다.
htps : // 기주 b. 코 m / 아 c 치 x / 에 mp ぇ s / t 리에 / 마 s r / 쥬니 페 r 아 d ゔ 펜 세
우선 mysql의 install
명령
sudo apt install mysql-server mysql-client
루트 비밀번호 설정(필요 없음)
명령
sudo mysql_secure_installation
출력
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.
New password: <=10文字くらいのパスワードを入力しました
Re-enter new password:
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
루트로 들어가서 웹 앱에서 사용할 사용자를 만들고 sql 파일을 실행합니다.
명령
sudo mysql -u root -p
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
use dbname
SOURCE /home/ubuntu/examples/juniper-advanced/mysql-schema.sql
사용자에게 권한 추가
명령
grant create on *.* to user@localhost;
grant update on *.* to user@localhost;
grant delete on *.* to user@localhost;
show grants for user@localhost;
출력
show grants for user@localhost;
.env를 복사하여 cargo 실행
명령
cp .env.example .env
cargo run
이런 식으로 출력되면 성공
출력
Finished dev [unoptimized + debuginfo] target(s) in 0.13s
Running `/home/ubuntu/examples/target/debug/juniper-advanced`
[2020-10-11T03:53:38Z INFO actix_server::builder] Starting 12 workers
[2020-10-11T03:53:38Z INFO actix_server::builder] Starting "actix-web-service-127.0.0.1:8080" service on 127.0.0.1:8080
[2020-10-11T03:54:10Z INFO actix_web::middleware::logger] 127.0.0.1:56920 "GET /graphiql HTTP/1.1" 200 1684 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0" 0.000352
graphiql 방문
htp://127.0.0.1:8080/g 등 p ql "
화면 오른쪽의 오류가 조회를 던져 실패했습니다.
아직 GraphQL을 사용하는 방법을 모르기 때문에 학습합니다.
이상
Reference
이 문제에 관하여(Actix GraphQL Example), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ito-masahiro/items/5f055ed9ebde96d22a08텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)