Skip to content

Commit

Permalink
integrationTests: add Flow test (#2819)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Oct 12, 2020
1 parent 711425e commit 822616f
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
8 changes: 8 additions & 0 deletions integrationTests/flow/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[include]
./index.mjs

[declarations]
.*/node_modules/.*

[options]
include_warnings=true
54 changes: 54 additions & 0 deletions integrationTests/flow/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// @flow strict

import { parse } from 'graphql/language';
import { GraphQLString, GraphQLSchema, GraphQLObjectType } from 'graphql/type';
import { type ExecutionResult, execute } from 'graphql/execution';
import { graphqlSync } from 'graphql';

interface SomeExtension {
number: number;
string: string;
}

const example: SomeExtension = {
number: 42,
string: 'Meaning of life',
};

const queryType: GraphQLObjectType = new GraphQLObjectType({
name: 'Query',
fields: {
sayHi: {
type: GraphQLString,
args: {
who: {
type: GraphQLString,
extensions: {
someArgumentExtension: example,
},
},
},
resolve: (_root, args) => 'Hello ' + (args.who || 'World'),
extensions: {
someFieldExtension: example,
},
},
},
extensions: {
someObjectExtension: example,
},
});

const schema: GraphQLSchema = new GraphQLSchema({
query: queryType,
});

const result: ExecutionResult = graphqlSync({
schema,
source: `
query helloWho($who: String){
test(who: $who)
}
`,
variableValues: { who: 'Dolly' },
});
10 changes: 10 additions & 0 deletions integrationTests/flow/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"private": true,
"scripts": {
"test": "flow check"
},
"dependencies": {
"graphql": "file:../graphql.tgz",
"flow-bin": "0.135.0"
}
}
4 changes: 4 additions & 0 deletions integrationTests/integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ describe('Integration Tests', () => {
testOnNodeProject('ts');
}).timeout(40000);

it('Should compile with Flow', () => {
testOnNodeProject('flow');
}).timeout(10000);

it('Should work on all supported node versions', () => {
testOnNodeProject('node');
}).timeout(40000);
Expand Down
3 changes: 2 additions & 1 deletion resources/build-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ if (require.main === module) {

fs.mkdirSync(path.dirname(destPath), { recursive: true });
if (filepath.endsWith('.js')) {
fs.copyFileSync(srcPath, destPath + '.flow');
const flowBody = '// @flow strict\n' + fs.readFileSync(srcPath, 'utf-8');
fs.writeFileSync(destPath + '.flow', flowBody);

const cjs = babelBuild(srcPath, { envName: 'cjs' });
fs.writeFileSync(destPath, cjs);
Expand Down

0 comments on commit 822616f

Please sign in to comment.