# How to write script for login users

**URL:** <https://community.gatling.io/t/how-to-write-script-for-login-users/6654>\
**Category:** Gatling (Open-Source)\
**Created:** [April 7, 2022, 1:06pm UTC](https://community.gatling.io/t/how-to-write-script-for-login-users/6654 "2022-04-07T13:06:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beata](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@Beata](https://community.gatling.io/u/Beata)\
**Post date:** [April 7, 2022, 1:06pm UTC](https://community.gatling.io/t/how-to-write-script-for-login-users/6654/1 "2022-04-07T13:06:28Z")

</div>

I’m working on preparing scripts for load tests of the app which uses GraphQL requests. I’m stuck at the login stage. I have no idea how to make it possible to use dynamic variables. I am a very beginner to Gatling. Maybe someone could advise me with an example?

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [April 7, 2022, 1:44pm UTC](https://community.gatling.io/t/how-to-write-script-for-login-users/6654/2 "2022-04-07T13:44:20Z")

</div>

There are plenty of examples in the [tutorials](https://gatling.io/docs/gatling/tutorials/) and the [Gatling Academy](https://gatling.io/academy/). You should check them.

---

<div class="post-metadata">

**Author:** ![Beata](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@Beata](https://community.gatling.io/u/Beata)\
**Post date:** [April 7, 2022, 1:51pm UTC](https://community.gatling.io/t/how-to-write-script-for-login-users/6654/3 "2022-04-07T13:51:47Z")

</div>

Perhaps I can use:

.body(RawFileBody("#{payloadPath}"))

and a few json files with credentials for test users.  
Is is a good idea?  
I have to send emails and passwords of my test users in GraphQL query.

---

<div class="post-metadata">

**Author:** ![Beata](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@Beata](https://community.gatling.io/u/Beata)\
**Post date:** [April 8, 2022, 6:18am UTC](https://community.gatling.io/t/how-to-write-script-for-login-users/6654/4 "2022-04-08T06:18:34Z")

</div>

Yes, I went through Gatling Academy both modules and I was searching the tutorials. But I did not find any example for GraphQL requests.

---

<div class="post-metadata">

**Author:** ![Beata](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@Beata](https://community.gatling.io/u/Beata)\
**Post date:** [April 8, 2022, 6:49am UTC](https://community.gatling.io/t/how-to-write-script-for-login-users/6654/5 "2022-04-08T06:49:58Z")

</div>

I’ve just managed it. I used feeder and  
.body(StringBody("{“query”:“query{mosn{subject}}”}"))  
My test users log in.

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [April 8, 2022, 6:57am UTC](https://community.gatling.io/t/how-to-write-script-for-login-users/6654/6 "2022-04-08T06:57:00Z")

</div>

You won’t find any tutorial dedicated to GraphQL. GraphQL is just JSON over HTTP.

---

<div class="post-metadata">

**Author:** ![Beata](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@Beata](https://community.gatling.io/u/Beata)\
**Post date:** [April 8, 2022, 6:58am UTC](https://community.gatling.io/t/how-to-write-script-for-login-users/6654/7 "2022-04-08T06:58:35Z")

</div>

Ok, that’s right.  
Thank you.
