diff --git a/.circleci/config.yml b/.circleci/config.yml index ea528ba09..657d368d9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,6 @@ jobs: - image: circleci/node:8 steps: - checkout - - run: yarn add graphql - run: yarn install - run: yarn test - run: npx semantic-release diff --git a/package.json b/package.json index e71d1685e..97a2833a8 100644 --- a/package.json +++ b/package.json @@ -42,15 +42,11 @@ "ava": "0.25.0", "bundlesize": "0.17.0", "fetch-mock": "5.13.1", - "graphql-tag": "2.9.2", "tslint": "5.9.1", "tslint-config-standard": "7.0.0", "typescript": "2.7.2" }, "dependencies": { "cross-fetch": "2.0.0" - }, - "peerDependencies": { - "graphql": "0.13.2" } } diff --git a/src/index.ts b/src/index.ts index 188849bcd..fa680707b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { ClientError, GraphQLError, Headers as HttpHeaders, Options, Variables } from './types' export { ClientError } from './types' import 'cross-fetch/polyfill' -import { print } from 'graphql' + export class GraphQLClient { private url: string private options: Options @@ -45,13 +45,13 @@ export class GraphQLClient { } async request( - query: string | object, + query: string, variables?: Variables, ): Promise { const { headers, ...others } = this.options - const printedQuery = typeof query === 'object' ? print(query) : query + const body = JSON.stringify({ - query: printedQuery, + query, variables: variables ? variables : undefined, }) @@ -71,7 +71,7 @@ export class GraphQLClient { typeof result === 'string' ? { error: result } : result throw new ClientError( { ...errorResult, status: response.status }, - { query: printedQuery, variables }, + { query, variables }, ) } } diff --git a/tests/index.test.ts b/tests/index.test.ts index 16627cfd7..851064c01 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -2,7 +2,6 @@ import test from 'ava' import * as fetchMock from 'fetch-mock' import { ClientError, rawRequest, request, GraphQLClient } from '../src/index' import { Options } from '../src/types' -import gql from 'graphql-tag' test('minimal query', async (t) => { const data = { @@ -125,21 +124,6 @@ test('extra fetch options', async (t) => { }) }) -test('minimal parsed query', async (t) => { - const data = { - Actor: { - name: "Tom Hardy" - } - } - - /* - This test is flaky because it relies on the internet - but the mock passed for this feature (parsed query) without - the implementation. - */ - t.deepEqual(await request('https://api.graph.cool/simple/v1/movies', gql`query { Actor(name: "Tom Hardy") { name } }`), data) -}) - async function mock(response: any, testFn: () => Promise) { fetchMock.mock({ matcher: '*', diff --git a/tsconfig.json b/tsconfig.json index 3db752bd2..0957ff49f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,7 @@ "strictNullChecks": true, "noUnusedLocals": true, "outDir": "dist", - "lib": ["es2015", "es2016", "dom", "esnext"] + "lib": ["es2015", "es2016", "dom", "esnext.asynciterable"] }, "exclude": [ "node_modules"