本文整理汇总了TypeScript中apollo-utilities.isTest函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isTest函数的具体用法?TypeScript isTest怎么用?TypeScript isTest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isTest函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: shouldWarn
function shouldWarn() {
const answer = !haveWarned;
/* istanbul ignore if */
if (!isTest()) {
haveWarned = true;
}
return answer;
}
开发者ID:apollostack,项目名称:apollo-client,代码行数:8,代码来源:fragmentMatcher.ts
示例2: match
public match(
idValue: IdValue,
typeCondition: string,
context: ReadStoreContext,
): boolean {
const obj = context.store.get(idValue.id);
if (!obj) {
return false;
}
if (!obj.__typename) {
if (!haveWarned) {
console.warn(`You're using fragments in your queries, but either don't have the addTypename:
true option set in Apollo Client, or you are trying to write a fragment to the store without the __typename.
Please turn on the addTypename option and include __typename when writing fragments so that Apollo Client
can accurately match fragments.`);
console.warn(
'Could not find __typename on Fragment ',
typeCondition,
obj,
);
console.warn(
`DEPRECATION WARNING: using fragments without __typename is unsupported behavior ` +
`and will be removed in future versions of Apollo client. You should fix this and set addTypename to true now.`,
);
/* istanbul ignore if */
if (!isTest()) {
// When running tests, we want to print the warning every time
haveWarned = true;
}
}
context.returnPartialData = true;
return true;
}
if (obj.__typename === typeCondition) {
return true;
}
// XXX here we reach an issue - we don't know if this fragment should match or not. It's either:
// 1. A fragment on a non-matching concrete type or interface or union
// 2. A fragment on a matching interface or union
// If it's 1, we don't want to return anything, if it's 2 we want to match. We can't tell the
// difference, so we warn the user, but still try to match it (backcompat).
warnOnceInDevelopment(
`You are using the simple (heuristic) fragment matcher, but your queries contain union or interface types.
Apollo Client will not be able to able to accurately map fragments.` +
`To make this error go away, use the IntrospectionFragmentMatcher as described in the docs: ` +
`http://dev.apollodata.com/react/initialization.html#fragment-matcher`,
'error',
);
context.returnPartialData = true;
return true;
}
开发者ID:ianlikono,项目名称:apollo-client,代码行数:58,代码来源:fragmentMatcher.ts
注:本文中的apollo-utilities.isTest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论