rivet-graphql
Advanced tools
Comparing version 0.4.0 to 0.5.0-canary-20230119003206
@@ -6,3 +6,3 @@ declare function _exports(url: string, options: import("graphql-request/dist/types.dom").RequestInit & { | ||
<T = any>({ query, dependencies, variables }: { | ||
query: string; | ||
query: string | DocumentNode; | ||
dependencies?: { | ||
@@ -17,2 +17,3 @@ fragmentSpec?: FragmentSpec; | ||
export type GQLRequestInit = import("graphql-request/dist/types.dom").RequestInit; | ||
export type DocumentNode = import("graphql/language/ast").DocumentNode; | ||
export type exports = import("graphql-request").GraphQLClient; | ||
@@ -19,0 +20,0 @@ export type FragmentSpec = { |
11
index.js
@@ -7,2 +7,3 @@ //@ts-check | ||
/** @typedef { import("graphql-request/dist/types.dom").RequestInit} GQLRequestInit */ | ||
/** @typedef { import("graphql/language/ast").DocumentNode} DocumentNode */ | ||
/** @typedef { import("graphql-request").GraphQLClient } */ | ||
@@ -41,3 +42,3 @@ | ||
* @param {Object} params | ||
* @param {string} params.query | ||
* @param {string | DocumentNode} params.query | ||
* @param {{ fragmentSpec?: FragmentSpec }[]} [params.dependencies] | ||
@@ -112,3 +113,3 @@ * @param {Record<string, any>} [params.variables] | ||
* @param {Record<string, unknown>} variables | ||
* @param {string} query | ||
* @param {string | DocumentNode} query | ||
* @returns {string} | ||
@@ -122,7 +123,9 @@ */ | ||
// If there are no variables, we can return | ||
if (!Object.keys(vars).length) return query | ||
if (!Object.keys(vars).length) { | ||
return typeof query === 'string' ? query : print(query) | ||
} | ||
// Otherwise, inject those variables into the query's params. | ||
// First we parse the query into an AST | ||
const ast = parse(query) | ||
const ast = typeof query === 'string' ? parse(query) : query | ||
@@ -129,0 +132,0 @@ // See function definition below for details |
{ | ||
"name": "rivet-graphql", | ||
"description": "a relay-like graphql data loading system for nextjs", | ||
"version": "0.4.0", | ||
"version": "0.5.0-canary-20230119003206", | ||
"author": "Jeff Escalante", | ||
@@ -14,4 +14,5 @@ "bugs": { | ||
"devDependencies": { | ||
"@changesets/changelog-github": "^0.4.8", | ||
"@changesets/cli": "^2.26.0", | ||
"jest": "^26.4.2", | ||
"release": "^6.3.0", | ||
"rewire": "^5.0.0", | ||
@@ -35,5 +36,3 @@ "typescript": "^4.6.2" | ||
"scripts": { | ||
"release:major": "npm run generate:types && release major && npm publish", | ||
"release:minor": "npm run generate:types && release minor && npm publish", | ||
"release:patch": "npm run generate:types && release patch && npm publish", | ||
"release:canary": "npm run generate:types && changeset publish --tag canary", | ||
"test": "jest", | ||
@@ -40,0 +39,0 @@ "generate:types": "tsc -p ." |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
37019
12
281
5
3