netlify-graph-auth
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -0,1 +1,2 @@ | ||
import { findMissingAuthServices } from './helpers'; | ||
import type { Storage } from './storage'; | ||
@@ -118,4 +119,4 @@ declare type Timer = ReturnType<typeof setTimeout>; | ||
destroy: () => void; | ||
findMissingAuthServices: any; | ||
findMissingAuthServices: typeof findMissingAuthServices; | ||
} | ||
export default NetlifyGraphAuth; |
@@ -1,1 +0,15 @@ | ||
export declare function findMissingAuthServices(results: any): any[]; | ||
declare type error = { | ||
extensions?: { | ||
type: string; | ||
graphQLField?: string; | ||
}; | ||
}; | ||
declare type results = { | ||
errors?: error[]; | ||
graphQLErrors?: error[]; | ||
}; | ||
declare type MissingAuthService = { | ||
graphQLField: string; | ||
}; | ||
export declare function findMissingAuthServices(results: results | error[]): MissingAuthService[]; | ||
export {}; |
@@ -10,10 +10,14 @@ "use strict"; | ||
*/ | ||
var errors = results && | ||
// Full GraphQL result | ||
(results.errors || | ||
// Apollo error | ||
results.graphQLErrors || | ||
// Possibly result.errors | ||
results); | ||
// If errors aren't an array, bail | ||
var errors; | ||
if (Array.isArray(results)) { | ||
errors = results; | ||
} | ||
else if (results != null && | ||
('errors' in results || 'graphQLErrors' in results)) { | ||
errors = | ||
// Full GraphQL result | ||
results.errors || | ||
// Apollo error | ||
results.graphQLErrors; | ||
} | ||
if (!Array.isArray(errors)) { | ||
@@ -24,3 +28,9 @@ return []; | ||
var missingServices = missingServiceErrors | ||
.map(function (error) { return error.extensions.graphQLField; }) | ||
.map(function (error) { | ||
var _a; | ||
var field = (_a = error === null || error === void 0 ? void 0 : error.extensions) === null || _a === void 0 ? void 0 : _a.graphQLField; | ||
if (field != null) { | ||
return { graphQLField: field }; | ||
} | ||
}) | ||
.filter(Boolean); | ||
@@ -27,0 +37,0 @@ return missingServices; |
{ | ||
"name": "netlify-graph-auth", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Client-side authentication for Netlify GraphQL APIs", | ||
@@ -14,3 +14,4 @@ "main": "dist/index.js", | ||
"prepare": "npm run build", | ||
"prettier": "prettier --write \"src/**/*.ts\"" | ||
"prettier": "prettier --write \"src/**/*.ts\"", | ||
"release": "yarn build && npm publish" | ||
}, | ||
@@ -17,0 +18,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
94608
1380