fix for #124 is incomplete
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Bắt đầu với com.netflix.graphql.dgs.client.codegen.InputValueSerializer và GraphQLQueryRequest.serialize, sau đó xem xét commit kiểm thử bị lỗi được liên kết và các quy tắc literal chuỗi của GraphQL October 2021. Tái hiện các ví dụ chứa ký tự xuống dòng về đầu dòng, null và các ký tự điều khiển bằng thiết lập client codegen. Được xem là hoàn tất khi các truy vấn đã serialize được phân tích cú pháp thành công đối với các trường hợp này và các kiểm thử liên quan bao quát hành vi escaping.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happened
The com.netflix.graphql.dgs.client.codegen.InputValueSerializer from com.netflix.graphql.dgs.codegen:graphql-dgs-codegen-client-core:5.1.16 did not emit a GraphQL compliant string literal causing the server to which the request was sent to error while trying to parse the GraphQL query
How to reproduce it
- Create a
schema1.graphqlsas below - Use the codegen plugin with
generateClient = true - Create a driver class as show below
- Observe the parse error when parsing the return from
.serialize
I have a failing test, too, although it was just some "hello world" failures, and does not attempt to enumerate all of the missing edge cases
Samples
schema1.graphqls
input PersonInput {
name: String
}
type Person {
name: String
}
type Query {
friends(like: PersonInput): Person
}
Driver.java
package com.example;
import com.example.gql.client.FriendsGraphQLQuery;
import com.example.gql.client.FriendsProjectionRoot;
import com.example.gql.types.PersonInput;
import com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest;
import graphql.parser.Parser;
public class Driver {
public static void main(String[] args) {
final var names = new String[] {
// but unicode is already correct
"💣",
"\r\n",
"\u0000",
"\u001F",
};
for (var name : names) {
final String gql = new GraphQLQueryRequest(
FriendsGraphQLQuery.newRequest()
.like(PersonInput.newBuilder()
.name(name)
.build())
.build(),
new FriendsProjectionRoot().name()
).serialize();
System.out.printf("gql = <<%s>>%n", gql);
var doc = Parser.parse(gql);
System.out.println("doc = " + doc);
}
}
}
What was expected
GraphQLQueryRequest.serialize should return legal GraphQL query text
Versions
- id("com.netflix.dgs.codegen") version "5.1.16"
- implementation("com.netflix.graphql.dgs:graphql-dgs-client:4.9.16")
Workaround
In case someone else stumbles upon this issue, I have a work-around until it is fixed: supersede the scalars parameter and register a JSON-safe graphql.scalar.GraphqlStringCoercing:
final Map<Class<?>, Coercing<?, ?>> scalars = Map.of(String.class, new GraphqlStringCoercing() {
@Override
public String serialize(final Object input) {
final var s = (String) input;
// this one was chosen because dgs-client uses it,
// meaning it will be present everywhere GraphQLQueryRequest is
return net.minidev.json.JSONValue.escape(s);
}
});
final String gql = new GraphQLQueryRequest(
FriendsGraphQLQuery.newRequest()
.like(PersonInput.newBuilder()
.name(name)
.build())
.build(),
new FriendsProjectionRoot().name(),
scalars
).serialize();
// and now gql will parse successfully
- Ngôn ngữ chính
- Kotlin
- Star
- 220
- Fork
- 123
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Netflix/dgs-codegen
-
Integer default values on `Float` input fields generate code that does not compile (Java and Kotlin)Có thể đã có người làm @0z5a đã nhận 9 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
Netflix/dgs-codegen#1015 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
Netflix/dgs-codegen#1002 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Object literal default value on a custom scalar fails with NoSuchElementExceptionCó thể đã có người làm @nboisnea đã nhận 49 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Netflix/dgs-codegen#982 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
HV000271: Using @Valid on a container (java.util.List) is deprecated. You should apply the annotation on the type argument(s).Có thể đã có người làm @jiholee17 đã nhận 73 ngày trước. Đang mởenhancement
Netflix/dgs-codegen#954 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support Immutable java Data TypesCó thể làm lại được @jiholee17 đã nhận 184 ngày trước và không có pull request nào đang mở. Đang mởenhancement
Netflix/dgs-codegen#944 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Netflix/dgs-codegen
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
DojoCodingLabs/hermit#23 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
signalapp/Signal-Android#15148 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
PranshulGG/WeatherMaster#1266 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày