Read the quick start guide to generate your client and start writing queries.
You can stay up to date with the latest changes subscribing to the Genql changelog.
🔥 Features
First generate your client executing
npm i -D @genql/cli # cli to generate the client code
genql --schema ./schema.graphql --output ./generated
Then you can use your client as follow
import { createClient, everything } from './generated'
const client = createClient()
client
.query({
countries: {
// pass arguments to the query
__args: {
filter: {
currency: {
eq: 'EUR',
},
},
},
name: true,
code: true,
nestedField: {
// fetch all scalar fields
__scalar: true,
},
},
})
.then(console.log)
The code above will fetch the graphql query below
query {
countries(filter: { currency: { eq: "EUR" } }) {
name
code
nestedField {
scalarField1
scalarField2
}
}
}
Genql has a lot of benefits over other writing graphql queries by hand:
__scalar: true
graphql
package dependencyVersion | Tag | Published |
---|---|---|
1.1.28 | latest | 2yrs ago |
2.0.3 | beta | 3yrs ago |