如何使用以下查询阻止对Apollo服务器的嵌套攻击:
{
authors {
firstName
posts {
title
author {
firstName
posts{
title
author {
firstName
posts {
title
[n author]
[n post]
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
换句话说,如何限制查询中提交的递归数量?这可能是潜在的服务器漏洞.
使用时<md-icon>
出现此错误:
原始异常:没有 Http 提供者!
所以我添加HTTP_PROVIDERS
到我的组件中并解决了这个问题。所以我的问题...为什么我需要添加HTTP_PROVIDERS
到我的组件才能开始<md-icon>
工作,即使我没有HTTP_PROVIDERS
在我的应用程序中使用?
这是我的工作组件。从提供者数组中删除HTTP_PROVIDERS
会引发上述错误。
import { Component } from '@angular/core';
import { HTTP_PROVIDERS } from '@angular/http';
import { MdIcon, MdIconRegistry } from '@angular2-material/icon';
@Component({
moduleId: module.id,
selector: 'foo-app',
template: `<md-icon>face</md-icon>`,
directives: [ MdIcon ],
providers: [MdIconRegistry, HTTP_PROVIDERS]
})
export class FooAppComponent {
title = 'Material 2 Foo App';
}
Run Code Online (Sandbox Code Playgroud)
另请注意,这一行将显示没有 Http 错误且不需要的图标HTTP_PROVIDERS
:
<i class="material-icons">face</i>
Run Code Online (Sandbox Code Playgroud)