graphql-schema-query
yarn add graphql-schema-query# or npm install graphql-schema-query
This small library is made to execute a GraphQL query or mutation without the need of any http request, and just using the GraphQL schema generated from TypeGraphQL, Nexus Schema or any other.
Useful for testing, referencing your own resolvers without any hassle or repeating code.
And specially the reason I made this library, for getServerSideProps and getStaticProps usage in Next.js
Usage
; // ...; ; // or ; ; // ... ;
Then, anywhere you need to use it:
;;// import gql from "graphql-tag"; also works ;
Protip
This library is using graphql-tag-ts, which can give you some nice type-safety from the gql tag itself, writing less code without any performance penalty.
For example:
;;// import gql, { DocumentNode } from "graphql-tag-ts"; also works , > = gql` query($anyVariable: String!) { helloWorld(anyVariable: $anyVariable) }`; ;