Use Graphql Queries In Flutter Without Package

Akifcan Kara
1 min readDec 19, 2021

Hola☺️. In this article I’ll show you how send graphql request with Flutter without use any package.

Let’s suppose this is our query (query or mutation).

And we need to pass parameters. 2 String, 1 Number and 1 String Array ty pe in this case.

And I passed variables in a map variable.

Now let’s send request to our graphql server!.

Note: I’ll use http package for that.

Now we can send requests to our graphql server.

In my app I am sending many graphql request in my app. So I created a class for manage requests like this.

I used singleton pattern because I don’t need to create many instances of this class thats why I preffered singleton pattern.

Also I’am using jwt token in my app. I sent token in headers object.

GraphqlResponse response = await GraphqlService.instance.sendRequest(query, variables);

Thanks for reading 😇😇. I hope this article. Hope this article helped you.

Bye

--

--