Git Product home page Git Product logo

graphql-demo's Introduction

GraphQL for Microsoft Graph (DEMO)

Call to action

We are looking for feedback from developers interested in integrating with Microsoft Graph via GraphQL. To share your thoughts and scenarios, please leave a comment on UserVoice.

About

This is a demo that enables basic, read-only querying of the Microsoft Graph API using GraphQL query syntax. GraphQL enables clients to request exactly the resources and properties that they need instead of making REST requests for each resource and consolidating the responses. To create a GraphQL service, this demo translates the Microsoft Graph OData $metadata document to a GraphQL schema and generates the necessary resolvers. Please note we are providing this demo code for evaluation as-is.

Animation of sample request

Live demo

Try the Microsoft Graph GraphQL Demo here

Installation

  1. Clone the repo
  2. Install dependencies (npm install)
  3. Generate schema description and resolver code using npm run build
  4. Navigate to the App Registration Portal, set up a new web app
  5. Configure App Id and redirect URIs in the AppConfiguration of build/index.html
  6. Run npm start and go to localhost:1337

Sample requests

Fetch recent emails

{
  me {
    displayName
    officeLocation
    skills
    messages {
      subject
      isRead
      from {
        emailAddress {
          address
        }
      }
    }
  }
}

Fetch groups and members

{
  groups {
    displayName
    description
    members {
      id
    }
  }
}

Fetch files from OneDrive

{
  me {
    drives {
      quota {
        used
        remaining
      }
      root {
        children {
          name
          size
          lastModifiedDateTime
          webUrl
        }
      }
    }
  }
}

How it works

  • src/setup.js reads in a well-formed $metadata CSDL, parses it and builds up a GraphQL schema
  • src/setup.js code generates resolvers that naively issues requests to the Graph service when the previous (parent) resolver doesn't have the data at hand

Limitations/to-dos

  • Translate OData inheritance relationships
  • Support pagination
  • Implement mutations
  • Enable passing arguments (like searching by name or filtering by id)
  • Add heuristics for $expand to reduce number of service calls made

Copyright

Copyright (c) 2017 Microsoft Corporation.

graphql-demo's People

Contributors

dpim avatar keyur32 avatar

Watchers

James Cloos 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.