graphql과 openFeign을 쓰면서 겪은 수많은 오류들

728x90
  1. Spring boot 3.1.* 버전은 openFeign 4.0.3 부터 호환이 됨
  2. GraphQL 스키마 내 필드 이름과 컨트롤러 이름은 같아야함. 안같으면 schemaMapping(typeName="") 이거나 @QueryMapping(name="") 이걸로 맞춰줘야함
    1. 위에서 SchemaMapping 과 QueryMapping의 차이점은 쿼리 매핑은 쿼리만 지원하고(ex getmapping) 스키마 매핑은 해당되는 스키마를 매핑 시킨다. 거기에 쿼리나 뮤테이션 등 같은 이름을 가진 스키마가 존재할경우 쿼리나 스키마도 명시 해줘야함 약간 RequestMapping 같다고 이해하면 될듯?
  3. OpenFeign 과 Spring Cloud OpenFeign은 서로 호환되는 어노테이션이 조금씩 다름 ex QueryMap
    1. https://cloud.spring.io/spring-cloud-static/spring-cloud-openfeign/2.2.0.RC1/reference/html/#feign-querymap-support
  4. (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator) 관련 오류가 났을때는 해당 오브젝트에 
@NoArgsConstructor
@AllArgsConstructor
@ToString

이거 추가로 달아주기. 

왜냐면

Caused by: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `com.skb.ft.synopsisservice.domain.euxp.vo.StillCut` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:406) ~[spring-web-6.0.11.jar:6.0.11]
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:354) ~[spring-web-6.0.11.jar:6.0.11]
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:103) ~[spring-web-6.0.11.jar:6.0.11]
... 87 common frames omitted

보면 Jackson라이브러리를 사용하는 것을 알 수 있는데 jackson 라이브러리를 사용해서 역직렬화를 할 때 기본 생성자를 사용함. 이떄 String 타입의 인자만 갖는 오브젝트의 경우 빈 생성자가 필요함. 이때문에 NoArgs~ 필요.

 

++OpenFeign 컨픽 설정할때 @Configuration이거 헤더 달아놓으면 모든 클라이언트에 다 적용되기때문에 특정 클라이언트에만 적용하고 싶음 @FeignClient(configuration=AAA.class) 이렇게 박아놓으면 됨

 

Spring Cloud OpenFeign

This project provides OpenFeign integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms.

cloud.spring.io

 

왠만한 사용법 다 적혀있는 공식문서

https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/#spring-cloud-feign-overriding-defaults

 

Spring Cloud OpenFeign

Feign is a declarative web service client. It makes writing web service clients easier. To use Feign create an interface and annotate it. It has pluggable annotation support including Feign annotations and JAX-RS annotations. Feign also supports pluggable

docs.spring.io

 

728x90