1.0.0 • Published 2 years ago

make-graphql-query v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

make-graphql-query

The point of this library is to have a super simple way to make graphql queries that is framework agnostic.pub

  • install npm install make-graphql-query

  • create your query function

const makeGraphQLQuery = require("make-graphql-query");

const graphQLQuery = makeGraphQLQuery({
  url: "xxxxxxxxxxxxxxxxxxxx.hasura.app/v1/graphql",
  headers: {
    "x-hasura-admin-secret":
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  },
});
  • make your queries or mutation, first argument takes two properties as arguments, query and variables (for graphql variables).
graphQLQuery({
  query: `{
        habits {
          id
          habit
          count
        }
      }`,
})
.then(data => console.log(data.habits))
1.0.0

2 years ago