graphql-request
Advanced tools
Comparing version 1.0.0 to 1.1.0
import { Options, Variables } from './types'; | ||
export { ClientError } from './types'; | ||
import 'isomorphic-fetch'; | ||
export default function request<T extends any>(url: string, query: string, variables?: Variables): Promise<T>; | ||
export declare function request<T extends any>(url: string, query: string, variables?: Variables): Promise<T>; | ||
export declare class GraphQLClient { | ||
@@ -6,0 +6,0 @@ private url; |
@@ -51,3 +51,3 @@ "use strict"; | ||
} | ||
exports.default = request; | ||
exports.request = request; | ||
var GraphQLClient = (function () { | ||
@@ -54,0 +54,0 @@ function GraphQLClient(url, options) { |
@@ -59,3 +59,3 @@ "use strict"; | ||
_b = (_a = t).deepEqual; | ||
return [4 /*yield*/, index_1.default('https://mock-api.com/graphql', "{ viewer { id } }")]; | ||
return [4 /*yield*/, index_1.request('https://mock-api.com/graphql', "{ viewer { id } }")]; | ||
case 1: | ||
@@ -92,3 +92,3 @@ _b.apply(_a, [_c.sent(), data]); | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, t.throws(index_1.default('https://mock-api.com/graphql', "x"))]; | ||
case 0: return [4 /*yield*/, t.throws(index_1.request('https://mock-api.com/graphql', "x"))]; | ||
case 1: | ||
@@ -95,0 +95,0 @@ err = _a.sent(); |
{ | ||
"name": "graphql-request", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "dist/src/index.js", | ||
@@ -9,3 +9,19 @@ "typings": "./dist/src/index.d.ts", | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/graphcool/graphql-request.git" | ||
}, | ||
"keywords": [ | ||
"graphql", | ||
"request", | ||
"fetch", | ||
"graphql-client", | ||
"apollo" | ||
], | ||
"author": "Johannes Schickling <johannes@graph.cool>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/graphcool/graphql-request/issues" | ||
}, | ||
"homepage": "https://github.com/graphcool/graphql-request", | ||
"scripts": { | ||
@@ -12,0 +28,0 @@ "prepublish": "npm run build", |
@@ -23,3 +23,3 @@ # graphql-request [![Build Status](https://travis-ci.org/graphcool/graphql-request.svg?branch=master)](https://travis-ci.org/graphcool/graphql-request) [![npm version](https://badge.fury.io/js/graphql-request.svg)](https://badge.fury.io/js/graphql-request) | ||
```js | ||
import request from 'graphql-request' | ||
import { request } from 'graphql-request' | ||
@@ -35,4 +35,3 @@ const query = `{ | ||
request('https://api.graph.cool/simple/v1/movies', query) | ||
.then(({ Movie }) => console.log(Movie)) | ||
request('https://api.graph.cool/simple/v1/movies', query).then(data => console.log(data)) | ||
``` | ||
@@ -43,3 +42,3 @@ | ||
```js | ||
import request, { GraphQLClient } from 'graphql-request' | ||
import { request, GraphQLClient } from 'graphql-request' | ||
@@ -56,3 +55,3 @@ // Run GraphQL queries/mutations using a static function | ||
### Authenication via HTTP header | ||
### Authentication via HTTP header | ||
@@ -83,3 +82,3 @@ ```js | ||
```js | ||
import request from 'graphql-request' | ||
import { request } from 'graphql-request' | ||
@@ -105,3 +104,3 @@ const query = `query getMovie(title: String!) { | ||
```js | ||
import request from 'graphql-request' | ||
import { request } from 'graphql-request' | ||
@@ -120,2 +119,19 @@ const wrongQuery = `{ | ||
### Using `require` instead of `import` | ||
```js | ||
const { request } = require('graphql-request') | ||
const query = `{ | ||
Movie(title: "Inception") { | ||
releaseDate | ||
actors { | ||
name | ||
} | ||
} | ||
}` | ||
request('my-endpoint', query).then(data => console.log(data)) | ||
``` | ||
### More examples coming soon... | ||
@@ -122,0 +138,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
21995
0
0
154
0