Skip to content

Commit

Permalink
fix(dependencies): Make graphql a direct dependency and eliminate web…
Browse files Browse the repository at this point in the history
…pack
  • Loading branch information
maticzav committed Dec 11, 2018
1 parent ee54b24 commit 22491a3
Show file tree
Hide file tree
Showing 5 changed files with 544 additions and 799 deletions.
23 changes: 10 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,23 @@
"test-ava": "ava",
"test": "npm-run-all test-*"
},
"dependencies": {
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0",
"graphql-import": "^0.7.1",
"graphql-tools": "4.0.3",
"iterall": "1.2.2",
"object-path-immutable": "^3.0.0",
"resolve-cwd": "^2.0.0",
"ts-node": "^7.0.1",
"yargs": "^12.0.2"
},
"devDependencies": {
"@types/graphql": "14.0.3",
"@types/mkdirp": "0.5.2",
"@types/node": "10.12.12",
"@types/yargs": "12.0.1",
"apollo-link": "1.2.4",
"ava": "1.0.0-rc.2",
"graphql": "14.0.2",
"graphql-tag": "2.10.0",
"husky": "1.2.0",
"npm-run-all": "4.1.5",
Expand All @@ -48,17 +57,5 @@
"tslint-config-prettier": "1.17.0",
"tslint-config-standard": "8.0.1",
"typescript": "3.2.2"
},
"dependencies": {
"graphql-import": "^0.7.1",
"graphql-tools": "4.0.3",
"iterall": "1.2.2",
"object-path-immutable": "^3.0.0",
"resolve-cwd": "^2.0.0",
"ts-node": "^7.0.1",
"yargs": "^12.0.2"
},
"peerDependencies": {
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
}
}
33 changes: 8 additions & 25 deletions src/codegen/FlowGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
declare const __non_webpack_require__
const { isNonNullType, isListType, GraphQLObjectType } = (isWebpack => {
if (isWebpack) return require('graphql')

const resolveCwd = require('resolve-cwd')
const graphqlPackagePath = resolveCwd.silent('graphql')

return require(graphqlPackagePath || 'graphql')
})(typeof __non_webpack_require__ !== 'undefined')

import { Generator } from './Generator'

import {
Expand All @@ -24,7 +14,9 @@ import {
GraphQLScalarType,
GraphQLEnumType,
GraphQLFieldMap,
GraphQLObjectType as GraphQLObjectTypeRef,
GraphQLObjectType,
isNonNullType,
isListType,
} from 'graphql'

import { Maybe } from './types'
Expand All @@ -51,22 +43,13 @@ export class FlowGenerator extends Generator {
`
},
GraphQLObjectType: (
type:
| GraphQLObjectTypeRef
| GraphQLInputObjectType
| GraphQLInterfaceType,
type: GraphQLObjectType | GraphQLInputObjectType | GraphQLInterfaceType,
): string => this.renderInterfaceOrObject(type),
GraphQLInterfaceType: (
type:
| GraphQLObjectTypeRef
| GraphQLInputObjectType
| GraphQLInterfaceType,
type: GraphQLObjectType | GraphQLInputObjectType | GraphQLInterfaceType,
): string => this.renderInterfaceOrObject(type),
GraphQLInputObjectType: (
type:
| GraphQLObjectTypeRef
| GraphQLInputObjectType
| GraphQLInterfaceType,
type: GraphQLObjectType | GraphQLInputObjectType | GraphQLInterfaceType,
): string => {
const fieldDefinition = Object.keys(type.getFields())
.map(f => {
Expand Down Expand Up @@ -293,7 +276,7 @@ ${this.renderTypes()}`
}

renderInterfaceOrObject(
type: GraphQLObjectTypeRef | GraphQLInputObjectType | GraphQLInterfaceType,
type: GraphQLObjectType | GraphQLInputObjectType | GraphQLInterfaceType,
): string {
const fieldDefinition: string = Object.keys(type.getFields())
.map(f => {
Expand Down Expand Up @@ -363,7 +346,7 @@ ${this.renderTypes()}`
renderObjectWrapper(
typeName: string,
typeDescription: Maybe<string>,
objects: GraphQLObjectTypeRef[],
objects: GraphQLObjectType[],
fieldDefinition: string,
): string {
return `${this.renderDescription(
Expand Down
25 changes: 6 additions & 19 deletions src/info.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
declare const __non_webpack_require__
const {
GraphQLObjectType,
GraphQLScalarType,
parse,
validate,
Kind,
} = (isWebpack => {
if (isWebpack) return require('graphql')

const resolveCwd = require('resolve-cwd')
const graphqlPackagePath = resolveCwd.silent('graphql')

return require(graphqlPackagePath || 'graphql')
})(typeof __non_webpack_require__ !== 'undefined')

import {
GraphQLSchema,
GraphQLResolveInfo,
FieldNode,
SelectionSetNode,
GraphQLOutputType,
GraphQLObjectType as GraphQLObjectTypeRef,
GraphQLScalarType as GraphQLScalarTypeRef,
GraphQLObjectType,
GraphQLScalarType,
Kind,
getNamedType,
DocumentNode,
print,
parse,
validate,
} from 'graphql'

import { Operation } from './types'
Expand Down Expand Up @@ -274,7 +261,7 @@ export function makeSubInfo(

export function getDeepType(
type: GraphQLOutputType,
): GraphQLObjectTypeRef | GraphQLScalarTypeRef {
): GraphQLObjectType | GraphQLScalarType {
if ((type as any).ofType) {
return getDeepType((type as any).ofType)
}
Expand Down
19 changes: 4 additions & 15 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
declare const __non_webpack_require__
const {
import {
GraphQLSchema,
GraphQLResolveInfo,
GraphQLOutputType,
GraphQLObjectType,
GraphQLScalarType,
GraphQLInterfaceType,
GraphQLUnionType,
GraphQLList,
GraphQLEnumType,
GraphQLNonNull,
} = (isWebpack => {
if (isWebpack) return require('graphql')

const resolveCwd = require('resolve-cwd')
const graphqlPackagePath = resolveCwd.silent('graphql')

return require(graphqlPackagePath || 'graphql')
})(typeof __non_webpack_require__ !== 'undefined')

import {
GraphQLSchema,
GraphQLResolveInfo,
GraphQLOutputType,
print,
} from 'graphql'

Expand Down

0 comments on commit 22491a3

Please sign in to comment.