spqr与geojson的成员类型不明确

时间:2019-11-18 06:49:46

标签: graphql-java graphql-spqr

有人尝试在graphql-spqr中包含geojson类型吗?我试图包括但没有成功 找到了这个https://github.com/leangen/graphql-spqr/wiki/Errors#ambiguous-member-type并尝试为下面的geojson注册ObjectTypeMapper

public class GeoJsonMapper extends ObjectTypeMapper {

    @Override
    public GraphQLInputObjectType toGraphQLInputType(final String typeName, final AnnotatedType javaType, final OperationMapper operationMapper, final BuildContext buildContext) {
        GraphQLInputObjectType.Builder typeBuilder = newInputObject()
                .name(typeName)
                .description(buildContext.typeInfoGenerator.generateInputTypeDescription(javaType, buildContext.messageBundle));

        final Set<InputField> fields = new HashSet<>();
        fields.add(new InputField("geo", "geo json point", new TypeToken<GeoJson<List<Double>>>(){}.getAnnotatedType(), new TypeToken<GeoJson<List<Double>>>(){}.getAnnotatedType(), null, null));

        fields.forEach(field -> typeBuilder.field(operationMapper.toGraphQLInputField(field, buildContext)));

        return typeBuilder.build();
    }


    @Override
    public boolean supports(AnnotatedType type) {
        return GeoJsonPoint.class.equals(type.getType());
    }
}

0 个答案:

没有答案