mirror of
https://github.com/vale981/apollo-server
synced 2025-03-04 17:21:42 -05:00
Typescript Improvements and esModuleInterop fix (#1210)
* add string input to gql tag * remove esModuleInterop, tested locally * change IMPORT_FUNCTION to something real * fix the rest of the tests
This commit is contained in:
parent
406b4fda4b
commit
9af856c2c8
25 changed files with 42 additions and 43 deletions
|
@ -25,10 +25,11 @@ const typeDefs = gql`
|
|||
`;
|
||||
|
||||
//Some projects use schemas imported from external files
|
||||
const typeDefs = gql`${IMPORT_FUNCTION('./schema-file')}`;
|
||||
const fs = require('fs');
|
||||
const typeDefs = gql`${fs.readFileSync(__dirname.concat('/schema.graphql'), 'utf8')}`;
|
||||
|
||||
//gql can also be used as regular function to convert a string to an AST
|
||||
const typeDefs = gql(IMPORT_FUNCTION('./schema-file'))
|
||||
const typeDefs = gql(fs.readFileSync(__dirname.concat('/schema.graphql'), 'utf8'))
|
||||
```
|
||||
|
||||
<h2 id="app-deps">Changes to app dependencies</h2>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import CachePolicy from 'http-cache-semantics';
|
||||
import CachePolicy = require('http-cache-semantics');
|
||||
|
||||
import { KeyValueCache, InMemoryLRUCache } from 'apollo-server-caching';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import LRU from 'lru-cache';
|
||||
import * as LRU from 'lru-cache';
|
||||
import { KeyValueCache } from './KeyValueCache';
|
||||
|
||||
export class InMemoryLRUCache implements KeyValueCache {
|
||||
|
|
|
@ -32,6 +32,6 @@ export * from 'graphql-subscriptions';
|
|||
import { DocumentNode } from 'graphql';
|
||||
import gqlTag from 'graphql-tag';
|
||||
export const gql: (
|
||||
template: TemplateStringsArray,
|
||||
template: TemplateStringsArray | string,
|
||||
...substitutions: any[]
|
||||
) => DocumentNode = gqlTag;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* tslint:disable:no-unused-expression */
|
||||
import { expect } from 'chai';
|
||||
import 'mocha';
|
||||
import MockReq from 'mock-req';
|
||||
import * as MockReq from 'mock-req';
|
||||
|
||||
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from 'graphql';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ExecutionResult } from 'graphql';
|
||||
import sha256 from 'hash.js/lib/hash/sha/256';
|
||||
import * as sha256 from 'hash.js/lib/hash/sha/256';
|
||||
|
||||
import { runQuery, QueryOptions } from './runQuery';
|
||||
import {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* tslint:disable:no-unused-expression */
|
||||
import { expect } from 'chai';
|
||||
import { stub } from 'sinon';
|
||||
import MockReq from 'mock-req';
|
||||
import * as MockReq from 'mock-req';
|
||||
import 'mocha';
|
||||
|
||||
import {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { GraphQLSchema, DocumentNode } from 'graphql';
|
||||
import { SchemaDirectiveVisitor, IResolvers, IMocks } from 'graphql-tools';
|
||||
import { ConnectionContext } from 'subscriptions-transport-ws';
|
||||
import WebSocket from 'ws';
|
||||
import * as WebSocket from 'ws';
|
||||
import { GraphQLExtension } from 'graphql-extensions';
|
||||
import { EngineReportingOptions } from 'apollo-engine-reporting';
|
||||
export { GraphQLExtension } from 'graphql-extensions';
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { expect } from 'chai';
|
||||
import 'mocha';
|
||||
import express from 'express';
|
||||
import * as express from 'express';
|
||||
|
||||
import net from 'net';
|
||||
import http from 'http';
|
||||
import * as net from 'net';
|
||||
import * as http from 'http';
|
||||
|
||||
import request from 'request';
|
||||
import FormData from 'form-data';
|
||||
import fs from 'fs';
|
||||
import * as request from 'request';
|
||||
import * as FormData from 'form-data';
|
||||
import * as fs from 'fs';
|
||||
import fetch from 'node-fetch';
|
||||
import { createApolloFetch } from 'apollo-fetch';
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import express from 'express';
|
||||
import corsMiddleware from 'cors';
|
||||
import * as express from 'express';
|
||||
import * as corsMiddleware from 'cors';
|
||||
import { json, OptionsJson } from 'body-parser';
|
||||
import playgroundMiddleware from 'graphql-playground-middleware-express';
|
||||
import { MiddlewareOptions as PlaygroundMiddlewareOptions } from 'graphql-playground-html';
|
||||
import { ApolloServerBase, formatApolloErrors } from 'apollo-server-core';
|
||||
import accepts from 'accepts';
|
||||
import typeis from 'type-is';
|
||||
import * as accepts from 'accepts';
|
||||
import * as typeis from 'type-is';
|
||||
|
||||
import { graphqlExpress } from './expressApollo';
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ import { graphqlExpress } from './expressApollo';
|
|||
*/
|
||||
|
||||
import { expect } from 'chai';
|
||||
import zlib from 'zlib';
|
||||
import multer from 'multer';
|
||||
import bodyParser from 'body-parser';
|
||||
import * as zlib from 'zlib';
|
||||
import * as multer from 'multer';
|
||||
import * as bodyParser from 'body-parser';
|
||||
const request = require('supertest');
|
||||
const express4 = require('express'); // modern
|
||||
import {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import connect from 'connect';
|
||||
import query from 'qs-middleware';
|
||||
import * as connect from 'connect';
|
||||
import * as query from 'qs-middleware';
|
||||
import { ApolloServer } from './ApolloServer';
|
||||
import { Config } from 'apollo-server-core';
|
||||
import 'mocha';
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { expect } from 'chai';
|
||||
import 'mocha';
|
||||
import express from 'express';
|
||||
import * as express from 'express';
|
||||
|
||||
import http from 'http';
|
||||
import * as http from 'http';
|
||||
|
||||
import { RESTDataSource } from 'apollo-datasource-rest';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import express from 'express';
|
||||
import * as express from 'express';
|
||||
import { ApolloServer } from './ApolloServer';
|
||||
import testSuite, {
|
||||
schema as Schema,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import express from 'express';
|
||||
import * as express from 'express';
|
||||
import {
|
||||
GraphQLOptions,
|
||||
HttpQueryError,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import hapi from 'hapi';
|
||||
import * as hapi from 'hapi';
|
||||
import { ApolloServerBase } from 'apollo-server-core';
|
||||
import { parseAll } from 'accept';
|
||||
import {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import hapi from 'hapi';
|
||||
import * as hapi from 'hapi';
|
||||
import { ApolloServer } from './ApolloServer';
|
||||
import { Config } from 'apollo-server-core';
|
||||
import 'mocha';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import Boom from 'boom';
|
||||
import * as Boom from 'boom';
|
||||
import { Server, Request } from 'hapi';
|
||||
import {
|
||||
GraphQLOptions,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* tslint:disable:no-unused-expression */
|
||||
import { expect } from 'chai';
|
||||
import { stub } from 'sinon';
|
||||
import http from 'http';
|
||||
import net from 'net';
|
||||
import * as http from 'http';
|
||||
import * as net from 'net';
|
||||
import 'mocha';
|
||||
import { sha256 } from 'js-sha256';
|
||||
|
||||
|
@ -17,7 +17,7 @@ import {
|
|||
|
||||
import { PubSub } from 'graphql-subscriptions';
|
||||
import { SubscriptionClient } from 'subscriptions-transport-ws';
|
||||
import WebSocket from 'ws';
|
||||
import * as WebSocket from 'ws';
|
||||
|
||||
import { execute } from 'apollo-link';
|
||||
import { createHttpLink } from 'apollo-link-http';
|
||||
|
|
|
@ -17,8 +17,7 @@ import {
|
|||
BREAK,
|
||||
} from 'graphql';
|
||||
|
||||
// tslint:disable-next-line
|
||||
const request = require('supertest');
|
||||
import request = require('supertest');
|
||||
|
||||
import { GraphQLOptions, Config } from 'apollo-server-core';
|
||||
import gql from 'graphql-tag';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { KeyValueCache } from 'apollo-server-caching';
|
||||
import Memcached from 'memcached';
|
||||
import * as Memcached from 'memcached';
|
||||
import { promisify } from 'util';
|
||||
|
||||
export class MemcachedCache implements KeyValueCache {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { KeyValueCache } from 'apollo-server-caching';
|
||||
import Redis from 'redis';
|
||||
import * as Redis from 'redis';
|
||||
import { promisify } from 'util';
|
||||
|
||||
export class RedisCache implements KeyValueCache {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { expect } from 'chai';
|
||||
import 'mocha';
|
||||
|
||||
import request from 'request';
|
||||
import * as request from 'request';
|
||||
import { createApolloFetch } from 'apollo-fetch';
|
||||
|
||||
import { gql, ApolloServer } from './index';
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
// an express app for you instead of registerServer (which you might not even
|
||||
// use with express). The dependency is unused otherwise, so don't worry if
|
||||
// you're not using express or your version doesn't quite match up.
|
||||
import express from 'express';
|
||||
import http from 'http';
|
||||
import net from 'net';
|
||||
import * as express from 'express';
|
||||
import * as http from 'http';
|
||||
import * as net from 'net';
|
||||
import { ApolloServer as ApolloServerBase } from 'apollo-server-express';
|
||||
|
||||
export { GraphQLOptions, GraphQLExtension, gql } from 'apollo-server-core';
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
"target": "es2016",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
|
|
Loading…
Add table
Reference in a new issue