나는 문서의 예를 http://dev.apollodata.com/tools/graphql-tools/mocking.html#Default-mock-example
조롱 서비스의 실행 매개 변수화 쿼리는 아폴로 graphql 반응
내가, 표준 반성 쿼리 내 스키마를 수출 스키마 객체를 구축하고이를 사용하고 같이 서비스를 조롱하기 위해 노력하고있어 문서에서 언급 한대로 쿼리를 실행하려고 할 때.
import * as introspectionResult from "../../graphql/schema.json"
const GRAPHQL_QUERY = `
query eventsFeatured(
$type: String!,
$entity_type: String,
$market__role: String,
$outcome__odds_rank_unique: Int,
$limit: Int
) {
featured(
type: $type,
entity_type: $entity_type,
market__role: $market__role,
outcome__odds_rank_unique: $outcome__odds_rank_unique,
limit: $limit
) {
...FeaturedFragment
media {
description
extralarge
large
medium
preview
__typename
}
event {
...EventFragment
market {
...MarketFragment
outcome {
...OutcomeFragment
media_logo {
preview
small
__typename
}
bookie {
...BookieFragment
__typename
}
__typename
}
__typename
}
article {
...ArticleFragment
__typename
}
category3 {
...AllCategoriesFragment
__typename
}
__typename
}
offer {
id
name
conditions
deeplink
domain {
...EventFragment
__typename
}
__typename
}
__typename
}
}
fragment EventFragment on Event {
id
name
canonicalised_name
display_name
date
date_human
date_short
type
__typename
}
fragment MarketFragment on Market {
id
name
display_name
canonicalised_name
type
role {
name
__typename
}
__typename
}
fragment OutcomeFragment on Outcome {
id
name
display_name
canonicalised_name
odds
odds_decimal
odds_rank
deeplink
home_or_away
type
__typename
}
fragment BookieFragment on Bookie {
name
__typename
}
fragment ArticleFragment on BaseArticle {
title
body
excerpt
author
date_no_time
date_stamp
date_human
date_short
date
__typename
}
fragment AllCategoriesFragment on Category3 {
...Category3Fragment
category2 {
...Category2Fragment
category1 {
...Category1Fragment
__typename
}
__typename
}
__typename
}
fragment Category1Fragment on Category1 {
name
canonicalised_name
__typename
}
fragment Category2Fragment on Category2 {
name
canonicalised_name
__typename
}
fragment Category3Fragment on Category3 {
name
canonicalised_name
__typename
}
fragment FeaturedFragment on Featured {
id
type
display_order
__typename
}
`
// this builds our mock apollo schema
const schema = buildClientSchema(introspectionResult)
addMockFunctionsToSchema({ schema })
// execute the supplied apollo query
graphql(schema, GRAPHQL_QUERY, {
options: (props) => ({
variables: {
type: "IMAGEGRIDHOMEPAGE"
},
})})
.then(graphqlResult => {
.... etc
```
However, I am seeing the following error:
```
{ errors:
[ GraphQLError {
message: 'Variable "$type" of required type "String!" was not provided.',
locations: [Object],
path: undefined } ] }
첫째 인수로 스키마 객체를 갖는 이러한 맥락에서 사용될 때 graphql
기능, 표준 옵션 개체 이상하지 variables
정의를 인식하지 못하는 것 같다. 내가 여기 소스에 파고 시도했지만 내 타이프 최고의 아니다 - https://github.com/apollographql/react-apollo/blob/master/src/graphql.tsx
흠, 피클 묽게 함 elmpp. 아무도 대답을 모른다면 나는 방황한다. – elmpp