Skip to content

benitodev/persons-graphql

Repository files navigation

Persons GraphQl server (Apollo)

Understanding the Apollo server (Graphql server). To develop graphql app of persons and their login, besides that apollo has his partf of client and it's agnostic to any graphql client.

But in my case i used what is recommended by the house.

This Project is client/server. Here you can see how i manage Apollo client for react

Sample GraphQL Queries

Fragment

Fragment - PersonDetails

fragment PersonDetails on Person {
    id
    name
    phone
    address {
      street
      city
    }
  }
                

Queries and Mutations

Query - Get all persons

query {
  allPersons {
    ...personDetails
  }
}
                

Query - Get one person (find)

 query findPersonByName($nameToSearch: String!) {
    findPerson(name: $nameToSearch) {
      ...PersonDetails
    }
  }
                

Mutation - Create Person

mutation createPerson(
    $name: String!
    $street: String!
    $city: String!
    $phone: String
  ) {
    addPerson(name: $name, phone: $phone, city: $city, street: $street) {
      ...PersonDetails
    }
  }
                

Mutation - Edit person

mutation editNumber($name: String!, $phone: String!) {
    editNumber(name: $name, phone: $phone) {
      id
      name
      phone
      address {
        street
        city
      }
    }
  }
                

Mutation - Login

mutation login($username: String!, $password: String!) {
    login(username: $username, password: $password) {
      value
    }
  }
                

What is GraphQl?

GraphQL is a query language (QL) for your API. It provides a complete understandable description of the data in your API, therefore it's predictable and declarative. GraphQL isn't tied any specificc database or storage engine.

¿What is it for?

Designed APIs fast, flexible and developer-friendly. As and alternative to REST, graphql lets developers construct requests that pull data from multiple data sources in a single API call

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published