Chalk v0.1.0 Chalk View Source
Chalk
is a client to make your life easy when you need to request GraphQL API's
Link to this section Summary
Functions
It builds a query in format expected in Graphql
Make a GrahpQL query to a client and returns %GraphQLResponse{} struct
Link to this section Functions
It builds a query in format expected in Graphql
Arguments
- query_params, keyword with params to build the query
Examples
iex> query_params = [users: [:name, :age, friends: [:id, :name]]] iex> Chalk.build_query(query_params) "query{users{name age friends{id name}}}"
iex> query_params = ["User(id: $id)": [:name, :age, friends: [:id, :name]]] iex> Chalk.build_query(query_params) "query{User(id: $id){name age friends{id name}}}"
Make a GrahpQL query to a client and returns %GraphQLResponse{} struct
Arguments
request_params, a keyword that could contains
- url, the client url
- options, keyworkd with options to the request
- headers, keyworkd with headers to the request, i.e: [{"authorization", "Bearer 234"}]
- query_params, keyword with params to build the query
- variables, map with variables that will be uses in the query
Examples
iex> request_params = [url: "https://test.com/] iex> query_params = [users: [:name, :age, friends: [:id, :name]]] iex> Chalk.query(request_params, query_params) %GraphQLResponse{}
iex> request_params = [url: "https://test.com/, headers: [{"Authorization", "Bearer 23333"}]] iex> query_params = ["User(id: $id)": [:name, :age, friends: [:id, :name]]] iex> variables = %{id: 123} iex> Chalk.query(request_params, query_params, variables) %GraphQLResponse{}