You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for really useful package! Our team is using this heavily.
We found one problem, the Fragment based on wrong type will pass the code generation process.
Env:
graphql_codegen: ^0.13.11
build_runner: ^2.4.8
Code:
typeQuery {
foo(id: ID!): FooCore!bar(id: ID!): BarCore!
}
typeBarCore {
something: Something!
}
typeFooCore {
something: Something!
}
typeSomething {
id: ID!
}
queryFooQuery {
foo(id: "1") {
...Share
}
bar(id: "1") {
# ⭐ It should be error but code generation will not be error...Share
}
}
fragmentShareonFooCore {
something {
id
}
}
Command line:
➜ graphql_codegen_trouble2 flutter pub run build_runner build
Deprecated. Use `dart run` instead.
[INFO] Generating build script completed, took 222ms
[INFO] Reading cached asset graph completed, took 63ms
[INFO] Checking for updates since last build completed, took 684ms
[INFO] Running build completed, took 257ms
[INFO] Caching finalized dependency graph completed, took 34ms
[INFO] Succeeded after 295ms with 1 outputs (1 actions)
Output:
Part of `Query$FooQuery`
foo is typed as Fragment$Share, bar is typed as Query$FooQuery$bar.
classQuery$FooQuery {
Query$FooQuery({
requiredthis.foo,
requiredthis.bar,
this.$__typename ='Query',
});
factoryQuery$FooQuery.fromJson(Map<String, dynamic> json) {
final l$foo = json['foo'];
final l$bar = json['bar'];
final l$$__typename = json['__typename'];
returnQuery$FooQuery(
foo:Fragment$Share.fromJson((l$foo asMap<String, dynamic>)),
bar:Query$FooQuery$bar.fromJson((l$bar asMap<String, dynamic>)),
$__typename: (l$$__typename asString),
);
}
finalFragment$Share foo;
finalQuery$FooQuery$bar bar;
finalString $__typename;
Map<String, dynamic> toJson() {
final _resultData =<String, dynamic>{};
final l$foo = foo;
_resultData['foo'] = l$foo.toJson();
final l$bar = bar;
_resultData['bar'] = l$bar.toJson();
final l$$__typename = $__typename;
_resultData['__typename'] = l$$__typename;
return _resultData;
}
@overrideintget hashCode {
final l$foo = foo;
final l$bar = bar;
final l$$__typename = $__typename;
returnObject.hashAll([
l$foo,
l$bar,
l$$__typename,
]);
}
@overridebooloperator==(Object other) {
if (identical(this, other)) {
returntrue;
}
if (!(other isQuery$FooQuery) || runtimeType != other.runtimeType) {
returnfalse;
}
final l$foo = foo;
final lOther$foo = other.foo;
if (l$foo != lOther$foo) {
returnfalse;
}
final l$bar = bar;
final lOther$bar = other.bar;
if (l$bar != lOther$bar) {
returnfalse;
}
final l$$__typename = $__typename;
final lOther$$__typename = other.$__typename;
if (l$$__typename != lOther$$__typename) {
returnfalse;
}
returntrue;
}
}
Part of `Query$FooQuery$bar`
Has complete fileds.
classFragment$Share {
Fragment$Share({
requiredthis.something,
this.$__typename ='FooCore',
});
factoryFragment$Share.fromJson(Map<String, dynamic> json) {
final l$something = json['something'];
final l$$__typename = json['__typename'];
returnFragment$Share(
something:Fragment$Share$something.fromJson(
(l$something asMap<String, dynamic>)),
$__typename: (l$$__typename asString),
);
}
finalFragment$Share$something something;
finalString $__typename;
Map<String, dynamic> toJson() {
final _resultData =<String, dynamic>{};
final l$something = something;
_resultData['something'] = l$something.toJson();
final l$$__typename = $__typename;
_resultData['__typename'] = l$$__typename;
return _resultData;
}
@overrideintget hashCode {
final l$something = something;
final l$$__typename = $__typename;
returnObject.hashAll([
l$something,
l$$__typename,
]);
}
@overridebooloperator==(Object other) {
if (identical(this, other)) {
returntrue;
}
if (!(other isFragment$Share) || runtimeType != other.runtimeType) {
returnfalse;
}
final l$something = something;
final lOther$something = other.something;
if (l$something != lOther$something) {
returnfalse;
}
final l$$__typename = $__typename;
final lOther$$__typename = other.$__typename;
if (l$$__typename != lOther$$__typename) {
returnfalse;
}
returntrue;
}
}
Part of `Query$FooQuery$bar`
No fields.
classQuery$FooQuery$bar {
Query$FooQuery$bar({this.$__typename ='BarCore'});
factoryQuery$FooQuery$bar.fromJson(Map<String, dynamic> json) {
final l$$__typename = json['__typename'];
returnQuery$FooQuery$bar($__typename: (l$$__typename asString));
}
finalString $__typename;
Map<String, dynamic> toJson() {
final _resultData =<String, dynamic>{};
final l$$__typename = $__typename;
_resultData['__typename'] = l$$__typename;
return _resultData;
}
@overrideintget hashCode {
final l$$__typename = $__typename;
returnObject.hashAll([l$$__typename]);
}
@overridebooloperator==(Object other) {
if (identical(this, other)) {
returntrue;
}
if (!(other isQuery$FooQuery$bar) || runtimeType != other.runtimeType) {
returnfalse;
}
final l$$__typename = $__typename;
final lOther$$__typename = other.$__typename;
if (l$$__typename != lOther$$__typename) {
returnfalse;
}
returntrue;
}
}
It looks expanding Share in bar I marked with ⭐ should be error, but It success code generation.
(IntelliJ's Graphql plugin shows error
)
It doesn't stop our work, but it caused a little trouble.
We hope this behavior will fix!
The text was updated successfully, but these errors were encountered:
👋 @kikuchy
Thank you for raising an issue. I will investigate the issue and get back to you as soon as possible.
Please make sure you have provided enough context.
This library is created and maintained by me, @budde377. Please consider supporting my work and ensure our survival by donating here.
Thank you for really useful package! Our team is using this heavily.
We found one problem, the Fragment based on wrong type will pass the code generation process.
Env:
Code:
Command line:
Output:
Part of `Query$FooQuery`
foo
is typed asFragment$Share
,bar
is typed asQuery$FooQuery$bar
.Part of `Query$FooQuery$bar`
Has complete fileds.
Part of `Query$FooQuery$bar`
No fields.
It looks expanding
Share
inbar
I marked with ⭐ should be error, but It success code generation.(IntelliJ's Graphql plugin shows error
)
It doesn't stop our work, but it caused a little trouble.
We hope this behavior will fix!
The text was updated successfully, but these errors were encountered: