-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: support for @include(if: $foo) directive #302
Comments
Are these two different questions? Do you get any errors (either graphql errors or link errors)? |
No errors, just null responses. The question is one (releated to the |
When using the Example of query:
Types in the schema:
|
@laynor, @smkhalsa, @knaeckeKami Any update on this? We would also like to see e.g.: We would like to see Query:query Posts ($includeAuthors: Boolean!) {
posts {
id
title
text
}
authors @include(if: $includeAuthors) {
id
name
}
} GraphQL schematype Query {
posts: [Post!]!
authors: [Author!]!
} Expected classabstract class GPostsData implements Built<GPostsData, GPostsDataBuilder> {
GPostsData._();
factory GPostsData([Function(GPostsDataBuilder b) updates]) = _$GPostsData;
static void _initializeBuilder(GPostsDataBuilder b) =>
b..G__typename = 'Query';
@BuiltValueField(wireName: '__typename')
String get G__typename;
GPostsData_posts get posts;
GPostsData_authors? get authors;
static Serializer<GPostsData> get serializer => _$GPostsDataSerializer;
Map<String, dynamic> toJson() => (_i1.serializers.serializeWith(
GPostsData.serializer,
this,
) as Map<String, dynamic>);
static GPostsData? fromJson(Map<String, dynamic> json) =>
_i1.serializers.deserializeWith(
GPostsData.serializer,
json,
);
} But we get If this is something we need to add to the ferry, we would be happy to work on it given some guidance on where to look. |
Hi! There is an open draft PR where this feature has been started: It's in gql_code_builder though, a dependency of ferry_generator. I never got to finish finish it, there are some merge conflicts and debug prints still there, and maybe some edge cases missing, but I don't fully remember. |
@knaeckeKami Nice, I will try to work on this when I have some free time. If you remember the edge cases, please comment here as well. |
I took some time to fix the merge conflicts. I also remembered what the issue was, the current state only works on fields, not on fragments, and to make this work, a bigger refactor is needed. (instead of just collecting the selectionNodes, we also need to track if it's in a context that has a skip or include directive to know whether to force the type to be nullable) |
Great, thank you for the update. 🥂 I have put this issue in our backlog as something we should implement. Once we add that into one of our sprints, I'll update here. Since this issue has been here for more than 2 years, I guess it will remain open until we revisit it again :-) |
Does ferry support queries like the one below?
My query works correctly with the Apollo client app, while ferry returns a null
response.data
field.I wonder if I'm doing something wrong - I noticed ferry silently returns a null data field even in the case of union fields if the query is not specifying the
__typename
field, e.g.won't work (returning a null data field), while
will work correctly.
The text was updated successfully, but these errors were encountered: