Skip to content

Commit

Permalink
update to graphql 13 and match code
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha committed Mar 13, 2018
1 parent 433dfd7 commit 59e065a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
node_modules
.idea
lerna-debug.log
.yarnclean
.yarnclean
yarn-error.log
4 changes: 2 additions & 2 deletions packages/graphql-codegen-cli/package.json
Expand Up @@ -72,8 +72,8 @@
"@types/mkdirp": "^0.3.29",
"@types/node": "7",
"@types/request": "^0.0.45",
"graphql": "^0.12.3",
"graphql-tag": "^2.4.2",
"graphql": "^0.13.1",
"graphql-tag": "^2.8.0",
"jest": "^22.4.2",
"rimraf": "^2.6.1",
"ts-jest": "^22.4.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql-codegen-compiler/package.json
Expand Up @@ -13,9 +13,9 @@
"@types/common-tags": "^1.2.5",
"@types/jest": "^22.2.0",
"@types/node": "7",
"graphql": "^0.10.4",
"graphql-tag": "^2.4.2",
"graphql-tools": "^1.0.0",
"graphql": "^0.13.1",
"graphql-tag": "^2.8.0",
"graphql-tools": "^2.21.0",
"jest": "^22.4.2",
"rimraf": "^2.6.1",
"ts-jest": "^22.4.1",
Expand Down
14 changes: 7 additions & 7 deletions packages/graphql-codegen-core/package.json
Expand Up @@ -60,20 +60,20 @@
]
},
"dependencies": {
"graphql-tag": "^2.6.1",
"graphql-tools": "^2.14.1"
"graphql-tag": "2.8.0",
"graphql-tools": "2.21.0"
},
"peerDependencies": {
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0"
},
"devDependencies": {
"@types/graphql": "^0.11.7",
"@types/graphql": "0.12.4",
"@types/jest": "22.2.0",
"@types/node": "7",
"apollo-link": "^1.0.7",
"graphql": "^0.12.3",
"@types/node": "9.4.7",
"apollo-link": "1.2.1",
"graphql": "0.13.1",
"jest": "22.4.2",
"rimraf": "^2.6.2",
"rimraf": "2.6.2",
"ts-jest": "22.4.1",
"tslint": "5.9.1",
"typescript": "2.7.2"
Expand Down
Expand Up @@ -4,10 +4,10 @@ import {
SelectionSetItem, isInlineFragmentNode, isFieldNode
} from '../types';
import {
Kind,
FieldNode, FragmentSpreadNode, getNamedType, GraphQLSchema, GraphQLType, InlineFragmentNode, SelectionNode,
SelectionSetNode, typeFromAST
} from 'graphql';
import { FIELD, FRAGMENT_SPREAD, INLINE_FRAGMENT } from 'graphql/language/kinds';
import { getFieldDef } from '../utils/get-field-def';
import { resolveType } from '../schema/resolve-type';
import { debugLog } from '../debugging';
Expand All @@ -30,7 +30,7 @@ export function separateSelectionSet(selectionSet: SelectionSetItem[]): any {

export function buildSelectionSet(schema: GraphQLSchema, rootObject: GraphQLType, node: SelectionSetNode): SelectionSetItem[] {
return ((node && node.selections ? node.selections : []) as SelectionNode[]).map<SelectionSetItem>((selectionNode: SelectionNode): SelectionSetItem => {
if (selectionNode.kind === FIELD) {
if (selectionNode.kind === Kind.FIELD) {
const fieldNode = selectionNode as FieldNode;
const name = fieldNode.alias && fieldNode.alias.value ? fieldNode.alias.value : fieldNode.name.value;
debugLog(`[buildSelectionSet] transforming FIELD with name ${name}`);
Expand Down Expand Up @@ -65,7 +65,7 @@ export function buildSelectionSet(schema: GraphQLSchema, rootObject: GraphQLType
isInputType: indicators.isInputType,
isType: indicators.isType,
} as SelectionSetFieldNode;
} else if (selectionNode.kind === FRAGMENT_SPREAD) {
} else if (selectionNode.kind === Kind.FRAGMENT_SPREAD) {
const fieldNode = selectionNode as FragmentSpreadNode;
debugLog(`[buildSelectionSet] transforming FRAGMENT_SPREAD with name ${fieldNode.name.value}...`);

Expand All @@ -76,7 +76,7 @@ export function buildSelectionSet(schema: GraphQLSchema, rootObject: GraphQLType
isLeaf: true,
fragmentName: fieldNode.name.value,
} as SelectionSetFragmentSpread;
} else if (selectionNode.kind === INLINE_FRAGMENT) {
} else if (selectionNode.kind === Kind.INLINE_FRAGMENT) {
debugLog(`[buildSelectionSet] transforming INLINE_FRAGMENT...`);

const fieldNode = selectionNode as InlineFragmentNode;
Expand Down
@@ -1,7 +1,6 @@
import { DefinitionNode, DocumentNode, FragmentDefinitionNode, GraphQLSchema, OperationDefinitionNode, printType } from 'graphql';
import { Kind, DefinitionNode, DocumentNode, FragmentDefinitionNode, GraphQLSchema, OperationDefinitionNode } from 'graphql';
import { Document } from '../types';
import { transformFragment } from './transform-fragment-document';
import { OPERATION_DEFINITION, FRAGMENT_DEFINITION } from 'graphql/language/kinds';
import { transformOperation } from './transform-operation';
import { debugLog } from '../debugging';

Expand All @@ -18,12 +17,12 @@ export function transformDocument(schema: GraphQLSchema, documentNode: DocumentN
debugLog(`[transformDocument] transforming total of ${definitions.length} definitions...`);

definitions.forEach((definitionNode: DefinitionNode) => {
if (definitionNode.kind === OPERATION_DEFINITION) {
if (definitionNode.kind === Kind.OPERATION_DEFINITION) {
result.operations.push(transformOperation(schema, definitionNode as OperationDefinitionNode));
} else if (definitionNode.kind === FRAGMENT_DEFINITION) {
} else if (definitionNode.kind === Kind.FRAGMENT_DEFINITION) {
result.fragments.push(transformFragment(schema, definitionNode as FragmentDefinitionNode));
} else {
console.log(`WARNING: It seems like you provided a GraphQL schema instead of GraphQL document: `);
console.log(`WARNING: It seems like you provided an invalid GraphQL document: `);
console.log(definitionNode);
}
});
Expand Down
49 changes: 13 additions & 36 deletions yarn.lock
Expand Up @@ -50,13 +50,9 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/graphql@^0.11.7":
version "0.11.8"
resolved "https://registry.yarnpkg.com/@types/graphql/-/graphql-0.11.8.tgz#53ff3604e99db810dd43347f19fcd1c59725a7bb"

"@types/graphql@^0.9.0":
version "0.9.4"
resolved "https://registry.yarnpkg.com/@types/graphql/-/graphql-0.9.4.tgz#cdeb6bcbef9b6c584374b81aa7f48ecf3da404fa"
"@types/graphql@0.12.4":
version "0.12.4"
resolved "https://registry.yarnpkg.com/@types/graphql/-/graphql-0.12.4.tgz#d43bb55d45c6de0178bbd11dd59d04fd42138d94"

"@types/handlebars@^4.0.33":
version "4.0.36"
Expand All @@ -80,7 +76,7 @@
dependencies:
moment "*"

"@types/node@*", "@types/node@^9.4.6":
"@types/node@*", "@types/node@9.4.7", "@types/node@^9.4.6":
version "9.4.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.7.tgz#57d81cd98719df2c9de118f2d5f3b1120dcd7275"

Expand Down Expand Up @@ -210,7 +206,7 @@ anymatch@^2.0.0:
micromatch "^3.1.4"
normalize-path "^2.1.1"

apollo-link@^1.0.7, apollo-link@^1.1.0:
apollo-link@1.2.1, apollo-link@^1.1.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/apollo-link/-/apollo-link-1.2.1.tgz#c120b16059f9bd93401b9f72b94d2f80f3f305d2"
dependencies:
Expand Down Expand Up @@ -2124,20 +2120,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

graphql-tag@^2.4.2, graphql-tag@^2.6.1:
graphql-tag@2.8.0, graphql-tag@^2.8.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.8.0.tgz#52cdea07a842154ec11a2e840c11b977f9b835ce"

graphql-tools@^1.0.0:
version "1.2.3"
resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-1.2.3.tgz#079bf4d157e46c0a0bae9fec117e0eea6e03ba2c"
dependencies:
deprecated-decorator "^0.1.6"
uuid "^3.0.1"
optionalDependencies:
"@types/graphql" "^0.9.0"

graphql-tools@^2.14.1:
graphql-tools@2.21.0, graphql-tools@^2.21.0:
version "2.21.0"
resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-2.21.0.tgz#c0d0fbda6f40a87c8d267a2989ade2ae8b9a288e"
dependencies:
Expand All @@ -2147,17 +2134,11 @@ graphql-tools@^2.14.1:
iterall "^1.1.3"
uuid "^3.1.0"

graphql@^0.10.4:
version "0.10.5"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.10.5.tgz#c9be17ca2bdfdbd134077ffd9bbaa48b8becd298"
dependencies:
iterall "^1.1.0"

graphql@^0.12.3:
version "0.12.3"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.12.3.tgz#11668458bbe28261c0dcb6e265f515ba79f6ce07"
graphql@0.13.1, graphql@^0.13.1:
version "0.13.1"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.13.1.tgz#9b3db3d8e40d1827e4172404bfdd2e4e17a58b55"
dependencies:
iterall "1.1.3"
iterall "^1.2.0"

growly@^1.3.0:
version "1.3.0"
Expand Down Expand Up @@ -2795,11 +2776,7 @@ istanbul-reports@^1.3.0:
dependencies:
handlebars "^4.0.3"

iterall@1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.1.3.tgz#1cbbff96204056dde6656e2ed2e2226d0e6d72c9"

iterall@^1.1.0, iterall@^1.1.3:
iterall@^1.1.3, iterall@^1.2.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.2.2.tgz#92d70deb8028e0c39ff3164fdbf4d8b088130cd7"

Expand Down Expand Up @@ -4409,7 +4386,7 @@ right-align@^0.1.1:
dependencies:
align-text "^0.1.1"

rimraf@2, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.2:
rimraf@2, rimraf@2.6.2, rimraf@^2.5.1, rimraf@^2.5.4:
version "2.6.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
dependencies:
Expand Down

0 comments on commit 59e065a

Please sign in to comment.