diff --git a/.flowconfig b/.flowconfig index b3969cf..68f4c21 100644 --- a/.flowconfig +++ b/.flowconfig @@ -9,5 +9,6 @@ [lints] [options] +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe [strict] diff --git a/package.json b/package.json index 10b4559..efbf7a0 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "test": "NODE_ENV='test' jest --coverage", "test:watch": "npm run test -- --watch", "flow": "flow", - "flow-coverage": "hsu-scripts flow --threshold 66", + "flow-coverage": "hsu-scripts flow --threshold 71", "eslint": "eslint ./", "format": "prettier --write '**/*.{js,json,md,css,yaml,yml}' '*.{js,json,md,css,yaml,yml}'", "changelog": "conventional-changelog --infile ./CHANGELOG.md --same-file --release-count 0 --output-unreleased" @@ -48,7 +48,8 @@ "testPathIgnorePatterns": [ "/node_modules/", "/lib/", - "/es/" + "/es/", + "/src/__tests__/flow.test.js" ], "resetMocks": true, "resetModules": true diff --git a/src/__tests__/flow.test.js b/src/__tests__/flow.test.js new file mode 100644 index 0000000..5c36371 --- /dev/null +++ b/src/__tests__/flow.test.js @@ -0,0 +1,29 @@ +// @flow +import { loader, gql } from '../index'; + +// $FlowFixMe number [1] is incompatible with string +export const loaderWithNumber = loader(3); +export const loaderWithString = loader('./fixtures/query3.graphql'); + +export const PostFragment = gql` + fragment Post on PostType { + title + date + } +`; +export const queryWithFragment = gql` + query User { + posts(id: 5) { + lastName + ...PostFragment + } + } + ${PostFragment} +`; +export const queryWithoutFragment = gql` + query User { + posts(id: 5) { + lastName + } + } +`; diff --git a/src/index.js b/src/index.js index c38e3ee..15eaf3c 100644 --- a/src/index.js +++ b/src/index.js @@ -13,4 +13,5 @@ export type TemplateStringsArray = $ReadOnlyArray; export const loader = (filePath: string): DocumentNode => ({}: DocumentNode); export const gql = ( taggedTemplateLiteral: TemplateStringsArray, + ...placeholders: any[] ): DocumentNode => ({}: DocumentNode);