# 8.1.5 Probando nuestros servicios con Postman

Al igual que los servicios REST podemos probar los servicios graphQL con Postman.

Se pueden probar los servicios con el método get o  post.

#### Probando los servicios GET con POSTMAN

Para probar con el método GET agregamos como parámetro la palabra **query**, seguido de los campos en formato json. En este ejemplo voy a traer de la tabla **caducidades**, los **campos** van separados por un espacio, en este caso voy a obtener los datos del **id** y el **productoId**

```graphql
http://localhost:5000/graphql?query={caducidades{id productoId}}
```

![](/files/-Lf31qUhEeDS6nURCbp-)

Así es un poco confuso es mas fácil por POST. En postman selecciona GraphQL y copia lo siguiente

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

Como resultado obtenemos el id de la caducidad, la fecha, el id, clave y nombre del producto, el id y nombre comercial del cliente

![](/files/fNDAyf3ZlujM3uUacrL5)

#### Probando el servicio agregar

Para el método **agregar**, la operación es **mutation**, el método en este caso es **addCaducidad**  (asi lo definimos en la mutación en .net), y después agregamos los **campos** que deseamos obtener, en este caso el **id** y la **fecha**

```graphql
mutation
{
    addCaducidad(caducidad:
    {
        id:2,
        cantidad:2,
        productoId:3,
        clienteId:3,
        fecha: "2020-03-04"
    })
    {
        id
        fecha
    }
}
```

![](/files/Qo24T9xLrhentVSH7ywv)

#### Probando el servicio Update

Para probar el servicio update es parecido, con un parámetro adicional, **id** para actualizar el registro

```graphql
mutation
{
    updateCaducidad(caducidad:
    {
        id:2,
        productoId:3,
        clienteId:3,
        cantidad:5,
        fecha: "2020-03-05"
    },
    id:2)
    {
        id
        cantidad
        fecha
    }
}
```

![](/files/3WxyHmzu8vnt9mfjvGVz)

#### Probando el servicio borrar

Mandamos llamar a la función definida en .net para borrar, en este ejemplo **deleteCaducidad** enviando el **id** que deseamos borrar

```graphql
mutation
{
    deleteCaducidad(id:2)
}
```

![](/files/-M_huByFb8gnt6CQ8PJC)

Para practicar puedes agregar mas servicios y probar por ejemplo ordenamientos o filtros.

####


---

# 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/6.3.6-probando-nuestros-servicios.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.
