# 8.1.3 Configurando y probando graphQL

Una vez que tenemos el query lo vamos a agregar en la clase Startup.cs en el método ConfigureServices agregamos Graph (GraphQLServer), agregamos nuestra clase Query (AddQueryType\<Query>) y agregamos las opciones que utilizaremos en este caso AddProjections(), AddFiltering() y AddSorting()

{% code title="Startup.cs" %}

```csharp
public void ConfigureServices(IServiceCollection services)
{
   //Código
   services.AddGraphQLServer()
           .AddQueryType<Query>().AddProjections()
           .AddFiltering().AddSorting()
```

{% endcode %}

En el método configure agregamos la ruta para acceder a grapQL en la parte de app.UseEndpoints

{% code title="Startup.cs" %}

```csharp
public void Configure(IApplicationBuilder app,
                     IWebHostEnvironment env, 
                     ILogger<Startup> logger)
{    
    //Código
    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllers();
        endpoints.MapGraphQL("/graphql");
    });
```

{% endcode %}

Ya viene configurado con una opción para consultar tus servicios llamado [Banana Cake Pop](https://chillicream.com/docs/bananacakepop). El cual puedes acceder desde <http://localhost:5000/grapqhl\\>
\
Da clic en Browse Schema para ver la definición del esquema y probar

&#x20;![](/files/hlnqZSnH1W1Ctve0sjaB)

Puedes configurar mas opciones como la autenticación. Da clic en Apply

![](/files/VBcUmIIEFh1TkXQepicH)

Da  clic en el tab **Operations** y Agrega lo siguiente para traer algunos campos de la tabla caducidad

```graphql
query TestQuery {
  caducidad(order: { fecha: ASC }) {
    id
    fecha
    producto {
      nombre
    }
    cliente {
      id
      nombreComercial
      razonSocial
    }
  }
}
```

![](/files/4vzmMDHmM6k3q7BLDDLV)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://abi.gitbook.io/net-core/6.3-agregar-graphql/8.1.3-configurando-y-probando-graphql.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
