You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-Each`queryName`must only be used once per operation.
56
-
-Each`field`must be used only once in a selection (we cannot query `id`twice under`token`)
57
-
-Some`field`s or queries (like`tokens`) return complex types that require a selection of sub-field. Not providing a selection when expected (or providing one when not expected - for example, on`id`) will raise an error. To know a field type, please refer to[Graph Explorer](/subgraphs/explorer/).
55
+
-Cada`queryName`só pode ser usado uma vez por operação.
56
+
-Cada`field`deve ser usado apenas uma vez numa seleção (não podemos solicitar a `id`duas vezes sob o`token`)
57
+
-Alguns`field`s ou queries (como`tokens`) retornam tipos complexos que exigem uma seleção de sub-campo. Caso uma seleção não seja fornecida quando esperada (ou fornecida quando não é esperada — por exemplo, em`id`), aparecerá um erro. Para conhecer um tipo de campo, consulte o[Graph Explorer](/subgraphs/explorer/).
58
58
- Qualquer variável apontada a um argumento deve corresponder ao seu tipo.
59
59
- Em uma lista dada de variáveis, cada uma delas deve ser única.
60
60
- Todas as variáveis definidas devem ser usadas.
61
61
62
-
> Note: Failing to follow these rules will result in an error from The Graph API.
62
+
> Não seguir as regras acima causará um erro da API do The Graph.
63
63
64
-
For a complete list of rules with code examples, check out [GraphQL Validations guide](/resources/release-notes/graphql-validations-migration-guide/).
64
+
Para uma lista completa de regras com exemplos de código, veja o [guia de Validações da GraphQL](/resources/release-notes/graphql-validations-migration-guide/).
65
65
66
66
### Como enviar um query a uma API GraphQL
67
67
68
-
GraphQL is a language and set of conventions that transport over HTTP.
68
+
GraphQL é uma linguagem e um conjunto de convenções transportadas através do HTTP.
69
69
70
-
It means that you can query a GraphQL API using standard `fetch`(natively or via `@whatwg-node/fetch`or`isomorphic-fetch`).
70
+
Ou seja, dá para fazer um query numa API GraphQL com o `fetch`normal (nativamente ou via `@whatwg-node/fetch`ou`isomorphic-fetch`).
71
71
72
-
However, as mentioned in["Querying from an Application"](/subgraphs/querying/from-an-application/), it's recommended to use `graph-client`, which supports the following unique features:
72
+
Porém, conforme mencionado em["Como Fazer Queries de Um Aplicativo"](/subgraphs/querying/from-an-application/), recomendamos usar o `graph-client`, que apoia as seguintes funções únicas:
73
73
74
74
- Gestão de Subgraph Cross-chain: Queries de múltiplos subgraphs numa única consulta
@@ -187,18 +187,18 @@ const result = await execute(query, {
187
187
})
188
188
```
189
189
190
-
> Note: The opposite directive is`@skip(if: ...)`.
190
+
> Observação: a diretiva oposta é`@skip(if: ...)`.
191
191
192
192
### Pergunte pelo que queres
193
193
194
-
GraphQL became famous for its "Ask for what you want" tagline.
194
+
A GraphQL ficou famosa por sua frase de efeito "pergunte pelo que queres".
195
195
196
-
For this reason, there is no way, in GraphQL, to get all available fields without having to list them individually.
196
+
Por isto, no GraphQL, não há como obter todos os campos disponíveis sem ter que listá-los individualmente.
197
197
198
198
- Ao consultar APIs GraphQL, sempre considere fazer query apenas dos campos que serão usados.
199
-
-Make sure queries only fetch as many entities as you actually need. By default, queries will fetch 100 entities in a collection, which is usually much more than what will actually be used, e.g., for display to the user. This applies not just to top-level collections in a query, but even more so to nested collections of entities.
199
+
-Tenha certeza que os queries só retornarão o máximo necessário de entidades. Por natureza, os queries retirarão 100 entidades em uma coleção, muito mais do que realmente será usado; por ex., para fins de amostra ao usuário. Isto serve não só para coleções de alto nível em um query, mas também — especialmente — para coleções aninhadas de entidades.
200
200
201
-
For example, in the following query:
201
+
Por exemplo, no query seguinte:
202
202
203
203
```graphql
204
204
querylistTokens {
@@ -213,15 +213,15 @@ query listTokens {
213
213
}
214
214
```
215
215
216
-
The response could contain 100 transactions for each of the 100 tokens.
216
+
A resposta pode conter 100 transações para cada um dos 100 tokens.
217
217
218
-
If the application only needs 10 transactions, the query should explicitly set`first: 10`on the transactions field.
218
+
Se o aplicativo só precisa de 10 transações, o query deve configurar explicitamente`first: 10`no campo de transações.
219
219
220
220
### Use uma única query para pedir vários registros
221
221
222
-
By default, subgraphs have a singular entity for one record. For multiple records, use the plural entities and filter: `where: {id_in:[X,Y,Z]}`or`where: {volume_gt:100000}`
222
+
Por padrão, subgraphs têm uma entidade singular para um registro. Para múltiplos registros, use as entidades plurais e o filtro: `where: {id_in:[X,Y,Z]}`ou`where: {volume_gt:100000}`
223
223
224
-
Example of inefficient querying:
224
+
Um exemplo de query ineficaz:
225
225
226
226
```graphql
227
227
querySingleRecord {
@@ -238,7 +238,7 @@ query SingleRecord {
238
238
}
239
239
```
240
240
241
-
Example of optimized querying:
241
+
Um exemplo de query otimizado:
242
242
243
243
```graphql
244
244
queryManyRecords {
@@ -251,7 +251,7 @@ query ManyRecords {
251
251
252
252
### Combine múltiplas queries em um único pedido
253
253
254
-
Your application might require querying multiple types of data as follows:
254
+
O seu aplicativo pode exigir queries de múltiplos tipos de dados, como a seguir:
This approach will **improve the overall performance**by reducing the time spent on the network (saves you a round trip to the API) and will provide a **more concise implementation**.
307
+
Este método **melhorará o desempenho em geral**ao reduzir o tempo gasto na rede (porque poupa uma viagem ao redor da API) e fornecerá **implementações mais concisas**.
308
308
309
309
### Como Aproveitar Fragmentos GraphQL
310
310
311
-
A helpful feature to write GraphQL queries is GraphQL Fragment.
311
+
O GraphQL Fragment é uma ferramenta útil para a escrita de queries em GraphQL.
312
312
313
-
Looking at the following query, you will notice that some fields are repeated across multiple Selection-Sets (`{ ... }`):
313
+
No seguinte query, perceba que alguns campos são repetidos em vários Selection-Sets (`{ ... }`):
314
314
315
315
```graphql
316
316
query {
@@ -330,12 +330,12 @@ query {
330
330
}
331
331
```
332
332
333
-
Such repeated fields (`id`, `active`, `status`) bring many issues:
333
+
Estes campos repetidos (`id`, `active`, `status`) trazem muitos problemas:
334
334
335
-
-More extensive queries become harder to read.
336
-
-When using tools that generate TypeScript types based on queries (_more on that in the last section_), `newDelegate`and`oldDelegate`will result in two distinct inline interfaces.
335
+
-Queries mais extensos ficam difíceis de ler.
336
+
-Ao usar ferramentas que geram tipos TypeScript baseados em queries (_mais na última secção_), `newDelegate`e`oldDelegate`retornarão duas interfaces distintas em inline.
337
337
338
-
A refactored version of the query would be the following:
338
+
Fatorizado novamente, o query ficaria assim:
339
339
340
340
```graphql
341
341
query {
@@ -359,27 +359,27 @@ fragment DelegateItem on Transcoder {
359
359
}
360
360
```
361
361
362
-
Using GraphQL`fragment`will improve readability (especially at scale) and result in better TypeScript types generation.
362
+
Usar o`fragment`("fragmento") da GraphQL melhorará a legibilidade (especialmente em escala) e também melhorará a geração de tipos TypeScript.
363
363
364
-
When using the types generation tool, the above query will generate a proper`DelegateItemFragment`type (_see last "Tools" section_).
364
+
Ao usar a ferramenta de geração de tipos, o query acima gerará um tipo`DelegateItemFragment`apropriado (_veja a última secção "Ferramentas"_).
365
365
366
366
### O que fazer e o que não fazer em Fragments GraphQL
367
367
368
368
### A base do fragment deve ser um tipo
369
369
370
-
A Fragment cannot be based on a non-applicable type, in short, **on type not having fields**:
370
+
Um Fragment não pode ser baseado num tipo não aplicável; ou seja, **um tipo sem campos**:
371
371
372
372
```graphql
373
373
fragmentMyFragmentonBigInt {
374
374
# ...
375
375
}
376
376
```
377
377
378
-
`BigInt`is a**scalar** (native "plain" type) that cannot be used as a fragment's base.
378
+
O `BigInt`é um**escalar** (tipo "plano" nativo) que não pode ser usado como a base de um fragmento.
379
379
380
380
#### Como espalhar um Fragment
381
381
382
-
Fragments are defined on specific types and should be used accordingly in queries.
382
+
Fragmentos são definidos em tipos específicos e devem ser usados de acordo nos queries.
383
383
384
384
Exemplo:
385
385
@@ -402,20 +402,20 @@ fragment VoteItem on Vote {
402
402
}
403
403
```
404
404
405
-
`newDelegate`and`oldDelegate`are of type`Transcoder`.
405
+
`newDelegate`e`oldDelegate`são do tipo`Transcoder`.
406
406
407
-
It is not possible to spread a fragment of type `Vote`here.
407
+
Não é possível espalhar um fragmento do tipo `Vote`aqui.
408
408
409
409
#### Defina o Fragment como uma unidade de negócios atômica de dados
410
410
411
-
GraphQL `Fragment`s must be defined based on their usage.
411
+
`Fragment`s da GraphQL devem ser definidos com base no seu uso.
412
412
413
-
For most use-case, defining one fragment per type (in the case of repeated fields usage or type generation) is sufficient.
413
+
Para a maioria dos casos de uso, definir um fragmento por tipo (no caso do uso repetido de campos ou geração de tipos) já é o suficiente.
414
414
415
-
Here is a rule of thumb for using fragments:
415
+
Aqui estão algumas regras básicas para o uso de Fragmentos:
416
416
417
-
-When fields of the same type are repeated in a query, group them in a`Fragment`.
418
-
-When similar but different fields are repeated, create multiple fragments, for instance:
417
+
-Quando campos do mesmo tipo se repetem em um query, agrupe-os em um`Fragment`.
418
+
-Quando campos parecidos (mas não idênticos) se repetem, crie múltiplos fragmentos, por exemplo:
419
419
420
420
```graphql
421
421
# base fragment (mostly used in listing)
@@ -438,51 +438,51 @@ fragment VoteWithPoll on Vote {
438
438
439
439
---
440
440
441
-
## The Essential Tools
441
+
## Ferramentas Essenciais
442
442
443
443
### Exploradores do GraphQL baseados em web
444
444
445
-
Iterating over queries by running them in your application can be cumbersome. For this reason, don't hesitate to use [Graph Explorer](https://thegraph.com/explorer)to test your queries before adding them to your application. Graph Explorer will provide you a preconfigured GraphQL playground to test your queries.
445
+
Pode ser até chato executar queries no seu aplicativo para iterar sobre elas. Por isto, não hesite em usar o [Graph Explorer](https://thegraph.com/explorer)para testar os seus queries antes de adicioná-los. O Graph Explorer fornecerá um ambiente de testes GraphQL pré-configurado para testar os seus queries.
446
446
447
-
If you are looking for a more flexible way to debug/test your queries, other similar web-based tools are available such as[Altair](https://altairgraphql.dev/)and[GraphiQL](https://graphiql-online.com/graphiql).
447
+
Se procura uma maneira mais flexível de depurar/testar seus queries, há outras ferramentas semelhantes baseadas na web, como[Altair](https://altairgraphql.dev/)e[GraphiQL](https://graphiql-online.com/graphiql).
448
448
449
449
### GraphQL Linting
450
450
451
-
In order to keep up with the mentioned above best practices and syntactic rules, it is highly recommended to use the following workflow and IDE tools.
451
+
Para acompanhar as melhores práticas e regras sintáticas explicadas acima, vale muito a pena utilizar as ferramentas IDE e de fluxo de trabalho a seguir.
452
452
453
-
**GraphQL ESLint**
453
+
**ESLint — GraphQL**
454
454
455
-
[GraphQL ESLint](https://the-guild.dev/graphql/eslint/docs/getting-started)will help you stay on top of GraphQL best practices with zero effort.
455
+
O [ESLint da GraphQL](https://the-guild.dev/graphql/eslint/docs/getting-started)te ajudará a acompanhar as melhores práticas da GraphQL sem sofrimento.
456
456
457
-
[Setup the "operations-recommended"](https://the-guild.dev/graphql/eslint/docs/configs)config will enforce essential rules such as:
457
+
[Organize a configuração "operations-recommended"](https://the-guild.dev/graphql/eslint/docs/configs)para executar regras essenciais como:
458
458
459
-
-`@graphql-eslint/fields-on-correct-type`: is a field used on a proper type?
460
-
-`@graphql-eslint/no-unused variables`: should a given variable stay unused?
459
+
-`@graphql-eslint/fields-on-correct-type`: um campo está num tipo apropriado?
460
+
-`@graphql-eslint/no-unused variables`: uma variável usada deve ficar sem uso?
461
461
- e mais!
462
462
463
-
This will allow you to **catch errors without even testing queries**on the playground or running them in production!
463
+
Isto permitirá-lhe **detetar erros mesmo sem testar queries**no playground ou mesmo executá-los na produção!
464
464
465
465
### Plugins IDE
466
466
467
-
**VSCode and GraphQL**
467
+
**VSCode e GraphQL**
468
468
469
-
The [GraphQL VSCode extension](https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql)is an excellent addition to your development workflow to get:
469
+
A [extensão VSCode da GraphQL](https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql)é uma adição excelente ao seu fluxo de programação que permite:
470
470
471
-
-Syntax highlighting
472
-
-Autocomplete suggestions
473
-
-Validation against schema
474
-
- Snippets
475
-
-Go to definition for fragments and input types
471
+
-Destaque de sintaxe
472
+
-Sugestões de preenchimento automático
473
+
-Validação perante schema
474
+
- Snippets (blocos de código reutilizáveis)
475
+
-Definições de fragmentos e tipos de entrada
476
476
477
-
If you are using `graphql-eslint`, the [ESLint VSCode extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)is a must-have to visualize errors and warnings inlined in your code correctly.
477
+
Se utilizar o `graphql-eslint`, a [extensão VSCode para o ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)é essencial para visualizar corretamente erros e avisos embutidos no seu código.
478
478
479
-
**WebStorm/Intellij and GraphQL**
479
+
**WebStorm/Intellij e GraphQL**
480
480
481
-
The [JS GraphQL plugin](https://plugins.jetbrains.com/plugin/8097-graphql/)will significantly improve your experience while working with GraphQL by providing:
481
+
O [plugin JavaScript para a GraphQL](https://plugins.jetbrains.com/plugin/8097-graphql/)melhorará muito a sua experiência com a GraphQL com:
482
482
483
-
-Syntax highlighting
484
-
-Autocomplete suggestions
485
-
-Validation against schema
486
-
- Snippets
483
+
-Destaque de sintaxe
484
+
-Sugestões de preenchimento automático
485
+
-Validação perante schema
486
+
- Snippets (blocos de código reutilizáveis)
487
487
488
-
For more information on this topic, check out the [WebStorm article](https://blog.jetbrains.com/webstorm/2019/04/featured-plugin-js-graphql/) which showcases all the plugin's main features.
488
+
Para mais informações sobre este tópico, veja o [artigo do WebStorm](https://blog.jetbrains.com/webstorm/2019/04/featured-plugin-js-graphql/), que demonstra todas as funções principais do plugin.
0 commit comments