graphql을 사용하여 좌표 배열을 가져 오려고합니다. 내가 얻을 수 graphiql를 사용Graphql 쿼리 배열
type Country implements Node {
code: String
name: String
dictionary: [CountryDictionary]
language: [CountryLanguage]
loc: [CountryLoc]
creationDate: Date
modifiedDate: Date
_id: ID
id: ID!
}
type CountryConnection {
pageInfo: PageInfo!
edges: [CountryEdge]
count: Float
}
type CountryDictionary {
_id: Generic
value: String
}
input CountryDictionaryInput {
_id: Generic
value: String
}
type CountryEdge {
node: Country
cursor: String!
}
type CountryLanguage {
_id: Generic
code: String
name: String
}
input CountryLanguageInput {
_id: Generic
code: String
name: String
}
type CountryLoc {
type: String
coordinates: [Float]
}
input CountryLocInput {
type: String
coordinates: [Float]
}
: 여기
// Geometry
const GeometrySchema = new mongoose.Schema({
type: { type: String },
coordinates: [ Number ]
}, { _id: false });
// Country
const CountrySchema = new mongoose.Schema({
code: String,
name: String,
dictionary: [ { _id: false, value: String } ],
language: [ { _id: false, code: String, name: String } ],
loc: { type: { type: String }, geometries: [ GeometrySchema ] },
creationDate: Date,
modifiedDate: Date
});
const Country = mongoose.model('Country', CountrySchema);
생성 graphql (graphql/유틸리티) 것 : 나는이 몽구스 모델에서 graphql 유형을 생성하는 릴레이, 몽구스, 낙서 - 몽구스를 사용하고 있습니다 그 나라의 이름은 다음과 같습니다 :
{
country(id:"57b48b73f6d183802aa06fe8"){
name
}
}
loc 정보를 어떻게 검색 할 수 있습니까?
당신이'밖으로 시도해 봤어 :' { 국가 (ID "57b48b73f6d183802aa06fe8을") { 이름 LOC는 { 는 } } 을 조정}? –
예이 응답을 얻으려고합니다. { "statusCode": 400, "오류": "잘못된 요청", "메시지": "예상되는 반복 가능하지만 Country.loc 필드에 하나가 없습니다." } – ric
즉, 문제는 서버 측 구현과 관련이 있습니다. 서버 측에서 좌표의 배열을 제대로 반환했는지 확인하십시오. –