GithubHelp home page GithubHelp logo

andrewjbateman / angular-graphql-data Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 3.57 MB

:clipboard: Angular app to display data from Rick and Morty API using GraphQL with Apollo.

Home Page: https://naughty-turing-cf7a1b.netlify.app/

TypeScript 69.50% JavaScript 2.69% HTML 7.89% SCSS 19.92%
api typescript html5 scss tutorial-code angular-cli graphql apollo-graphql scss-styles angular

angular-graphql-data's Introduction

⚑ Angular GraphQL Data

  • Angular app to display data from Rick and Morty API using GraphQL with Apollo.
  • Server Side Rendering (SSR) added.
  • Deployed to Netlify with a good (green) Lighthouse score.
  • Note: to open web links in a new window use: ctrl+click on link

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

πŸ“„ Table of contents

πŸ“š General info

  • GraphQL, a query language for APIs.
  • Angular HttpInterceptor used to intercept a HTTP request and show a spinner
  • Styling done using SCSS instead of Angular Material, Bootstrap, Tailwind etc.
  • Dummy robots.txt file added to fool lighthouse test for Search Engine Optimization (SEO)

πŸ“· Screenshots

Frontend screenshot

πŸ“Ά Technologies

πŸ’Ύ Setup

  • Install dependencies using npm i
  • Run ng serve for a non-SSR dev server. Frontend will open at http://localhost:4200/ - refreshes on code changes
  • Run npm run dev:ssr for an SSR dev server. Frontend will open at http://localhost:4200/ - refreshes on code changes
  • Run npm run lint to lint test entire codebase using ESLint.
  • Run npm run build to generate a build file without SSR
  • Run npm run build:ssr to generate a build file with SSR. Add defer to browser css file ref.
  • Run npm run serve:ssr to see on a dev server http://localhost:4000

πŸ”§ Testing

  • Run ng test to run Jasmine unit tests via Karma
  • Run ng e2e to execute the end-to-end tests via Protractor.

πŸ’» Code Examples

  • data.service.ts function to get API data using GraphQL & Apollo
  getCharactersByPage(pageNum: number): void {
    const QUERY_BY_PAGE = gql`{
      characters(page: ${pageNum}) {
        results {
          id
          name
          status
          species
          gender
          image
        }
      }
    }`;

    this.apollo.watchQuery<any>({
      query: QUERY_BY_PAGE
    }).valueChanges.pipe(
      take(1),
      pluck('data', 'characters'),
      withLatestFrom(this.characters$),
      tap(([apiResponse, characters]) => {
        this.parseCharactersData([...characters, ...apiResponse.results]);
      })
    ).subscribe();

  }

πŸ†’ Features - Frontend

  • Angular Universal used to generate static pages using Server Side Rendering (SSR) - to increase display speed and add Search Engine Optimisation (SEO). A normal Angular application executes in the browser, rendering pages in the DOM in response to user actions. Angular Universal executes on the server, generating static application pages that later get bootstrapped on the client. This means that the application generally renders more quickly, giving users a chance to view the application layout before it becomes fully interactive.

πŸ“‹ Status, Testing & To-Do List

  • Status: Working with SSR. Deployed to Netlify
  • Testing: n/a
  • To-Do: turn strict back on and sort type errors. Improve Lighthouse score.

πŸ‘ Inspiration/General Tools

πŸ“ License

  • N/A

βœ‰οΈ Contact

angular-graphql-data's People

Contributors

andrewjbateman avatar angular-cli avatar bampakoa avatar coddo avatar creadicted avatar danieloprado avatar danielsogl avatar eggachecat avatar flowfire avatar hervehobbes avatar jansivans avatar jialipassion avatar lazza avatar leo6104 avatar leomartindev avatar louich avatar maximegris avatar mo2menelzeiny avatar nakeawvichit avatar oliverlonghi avatar osmarcs avatar rm-code avatar sookcha avatar stalina avatar theoomoregbee avatar yannisgu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.