Create and Deploy a GraphQL API From Your Phone
Published: 2022-07-09 14:55:23

Today I saw an inspiring [post about development from mobile](https://dev.to/eludadev/i-made-an-entire-full-stack-app-using-only-my-phone-4apg) on DEV.to, so I noodled around with [Termux](https://github.com/termux/termux-app#installation) and [StepZen](https://stepzen.com/) and deployed a GraphQL API from my phone! For context, Termux is an Android terminal application, and StepZen is a service that uploads and deploys GraphQL APIs for you with very little code (useful when you’re typing on your phone). I’ll explain how you can do this project on Android 10 in the following paragraphs.

Install Termux and Node.js
--------------------------

Navigate to F-Droid, an open-source app repository, to [install Termux](https://f-droid.org/en/packages/com.termux/). In order to get it to work, I had to install the APK, which is not the big blue F-Droid button, but the smaller APK link that says ‘Download APK’:

<img src="/images/blog/termux1.png" alt="screenshot of termux home page" width="500"/>

If you run into any trouble with this step, I highly recommend visiting the [Termux community](https://www.reddit.com/r/termux/) on Reddit.

When you open Termux, run these commands to make sure you’re updated on the latest releases.

```
pkg upgrade
pkg update
```

Then, to install Node.js, run this command, which ensures you’ll receive [long-term support](https://nodejs.org/en/about/releases/#:~:text=LTS%20release%20status%20is%20%22long,Codename) for node.

```jsx
`pkg install nodejs-lts`

```

Double-check that you’ve successfully installed Node.js (as I write this, the latest version is 18.4.0) by running the following command.

```jsx
`node --version`

```

Install StepZen
---------------

Next up, [install StepZen](https://stepzen.com/docs/quick-start/install-and-setup)!

<img src="/images/blog/termux2.png" alt="npm install -g stepzen, stepzen —version" width="500"/>

Here, install StepZen globally with `npm install -g stepzen`, then double-checked that it was installed with `stepzen --version`.

Then, create a new folder by running `mkdir stepzen-app && cd stepzen-app`. In this folder, you’ll be importing and deploying a GraphQL API, as I’ll explain in the next step.

Import a GraphQL API
--------------------

To import a GraphQL API, run `stepzen import graphql`. When prompted for an endpoint, you can use the example endpoint from StepZen’s [Getting Started wiki](https://stepzen.com/getting-started?details=examples&example=graphql), `https://graphqldd.stepzen.net/api/dd1cf47f51ac830fe21dc00ec80cee65/__graphql`.

<img src="/images/blog/termux3.png" alt="stepzen import graphql" width="500"/>

When prompted, enter a GraphQL prefix of `phone_` and decline to send any headers. Then, StepZen downloaded my schema into a folder called `graphql`. Take a look at the contents of the folder with `cat index.graphql` and see your schema! The schema includes the prefix specified, as in `phone_frankfurter_convertedAmount` , for example.

<img src="/images/blog/termux4.png" alt="cat index.graphql" width="500"/>

Deploy the GraphQL API
----------------------

To deploy the API, run `stepzen start`. You can [sign up for a StepZen account](https://stepzen.com/signup) to log in, or continue without logging in, as I did. Note that if you do not log in, your endpoint is public and will expire in 30 days.

<img src="/images/blog/termux5.png" alt="stepzen start" width="500"/>

Success!
--------

You’ll see a message pop up informing you that your schema has been deployed, and which endpoint it’s been deployed to.

<img src="/images/blog/termux6.png" alt="stepzen success message" width="500"/>

Your API is deployed at the endpoint displayed at the bottom. You can test it with the curl command. The `localhost:5001` endpoint is accessible only to you. I tried it out on my phone (first time I’ve opened localhost on my mobile!) and I could see my data coming back loud and clear! As you can see, StepZen’s sample API returns the currency names for various countries.

[object Object]

Where To Go From Here
---------------------

I got a real kick out of creating and deploying a GraphQL API from my phone, and I hope this article empowers you to do it too! If you have any more questions about StepZen, here are some resources:

*   Join our [Discord](https://discord.com/invite/9k2VdPn2FR)!
*   StepZen [Documentation](https://stepzen.com/docs)
*   StepZen [Blog](https://stepzen.com/blog)
*   [Getting Started Tutorial](https://stepzen.com/getting-started)