Skip to content

formonkey/angular-class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run application

Enter in client and run:

npm i && ng server

And enter in http://localhost:4200

Server REST

Enter in server/rest and run:

npm i && npm run server

Resources http://localhost:9001/posts http://localhost:9001/comments http://localhost:9001/profile

Home http://localhost:9001/

Server GraphQL

Enter in server/grapql and run:

npm i && npm run server

And enter in http://localhost:9002

GraphQL Usage

Here is how you can use the queries and mutations generated for your data, using Post as an example:

Query / Mutation Result
// get a single entity, by id
{
  Post(id: 1) {
    id
    title
    views
    user_id
  }
}
            
{
  "data": {
    "Post": {
        "id": 1,
        "title": "Lorem Ipsum",
        "views": 254,
        "user_id": 123
    } 
  }
}
            
// include many-to-one relationships
{
  Post(id: 1) {
    title
    User {
        name
    }
  }
}
            
{
  "data": {
    "Post": {
        "title": "Lorem Ipsum",
        "User": {
            "name": "John Doe"
        }
    } 
  }
}
            
// include one-to-many relationships
{
  Post(id: 1) {
    title
    Comments {
        body
    }
  }
}
            
{
  "data": {
    "Post": {
        "title": "Lorem Ipsum",
        "Comments": [
            { "body": "Consectetur adipiscing elit" },
            { "body": "Nam molestie pellentesque dui" },
        ]
    } 
  }
}
            
// get a list of entities for a type
{
  allPosts {
    title
    views
  }
}
            
{
  "data": {
    "allPosts": [
      { "title": "Lorem Ipsum", views: 254 },
      { "title": "Sic Dolor amet", views: 65 }
    ]
  }
}
            
// paginate the results
{
  allPosts(page: 0, perPage: 1) {
    title
    views
  }
}
            
{
  "data": {
    "allPosts": [
      { "title": "Lorem Ipsum", views: 254 },
    ]
  }
}
            
// sort the results by field
{
  allPosts(sortField: "title", sortOrder: "desc") {
    title
    views
  }
}
            
{
  "data": {
    "allPosts": [
      { "title": "Sic Dolor amet", views: 65 }
      { "title": "Lorem Ipsum", views: 254 },
    ]
  }
}
            
// filter the results using the full-text filter
{
  allPosts( filter: { q: "lorem" }) {
    title
    views
  }
}
            
{
  "data": {
    "allPosts": [
      { "title": "Lorem Ipsum", views: 254 },
    ]
  }
}
            
// filter the result using any of the entity fields
{
  allPosts( filter: { views: 254 }) {
    title
    views
  }
}
            
{
  "data": {
    "allPosts": [
      { "title": "Lorem Ipsum", views: 254 },
    ]
  }
}
            
// number fields get range filters
// -lt, _lte, -gt, and _gte
{
  allPosts( filter: { views_gte: 200 }) {
    title
    views
  }
}
            
{
  "data": {
    "allPosts": [
      { "title": "Lorem Ipsum", views: 254 },
    ]
  }
}
            

About

Angular v7 class

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published