This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #356 from comigor/missing-fragment
Add throwable errors for missing root object and used query fragments
- Loading branch information
Showing
7 changed files
with
124 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'package:artemis/builder.dart'; | ||
import 'package:artemis/generator/errors.dart'; | ||
import 'package:build/build.dart'; | ||
import 'package:build_test/build_test.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('On errors', () { | ||
test('When there\'s a missing fragment being used', () async { | ||
final anotherBuilder = graphQLQueryBuilder(BuilderOptions({ | ||
'generate_helpers': false, | ||
'schema_mapping': [ | ||
{ | ||
'schema': 'api.schema.graphql', | ||
'queries_glob': 'lib/queries/some_query.graphql', | ||
'output': 'lib/output/some_query.graphql.dart', | ||
}, | ||
], | ||
})); | ||
|
||
expect( | ||
() => testBuilder( | ||
anotherBuilder, | ||
{ | ||
'a|api.schema.graphql': ''' | ||
type Query { | ||
a: String! | ||
} | ||
''', | ||
'a|lib/queries/some_query.graphql': | ||
'query { ...nonExistentFragment }', | ||
}, | ||
onLog: print, | ||
), | ||
throwsA(predicate((e) => | ||
e is MissingFragmentException && | ||
e.fragmentName == 'NonExistentFragmentMixin' && | ||
e.className == r'SomeQuery$Query')), | ||
); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:artemis/builder.dart'; | ||
import 'package:artemis/generator/errors.dart'; | ||
import 'package:build/build.dart'; | ||
import 'package:build_test/build_test.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('On errors', () { | ||
test('When there\'s no root type on schema', () async { | ||
final anotherBuilder = graphQLQueryBuilder(BuilderOptions({ | ||
'generate_helpers': false, | ||
'schema_mapping': [ | ||
{ | ||
'schema': 'lib/api.schema.graphql', | ||
'queries_glob': 'lib/**.query.graphql', | ||
'output': 'lib/some_query.graphql.dart', | ||
}, | ||
], | ||
})); | ||
|
||
anotherBuilder.onBuild = expectAsync1((_) {}, count: 0); | ||
|
||
expect( | ||
() => testBuilder( | ||
anotherBuilder, | ||
{ | ||
'a|lib/api.schema.graphql': '', | ||
'a|lib/some.query.graphql': 'query { a }', | ||
}, | ||
onLog: print, | ||
), | ||
throwsA(predicate((e) => e is MissingRootTypeException)), | ||
); | ||
}); | ||
}); | ||
} |