Coder Social home page Coder Social logo

christh / umbraco-graphql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from umbraco-community/umbraco-graphql

0.0 0.0 0.0 216 KB

An experimental implementation of GraphQL for Umbraco using GraphQL for .NET.

License: MIT License

Batchfile 0.39% C# 76.85% HTML 7.17% JavaScript 13.65% CSS 0.47% Pascal 0.32% F# 1.15%

umbraco-graphql's Introduction

GraphQL for Umbraco

NuGet release

What is this

An experimental implementation of GraphQL for Umbraco using GraphQL for .NET.

If you're interested in getting GraphQL into Umbraco Core please join the discussion on Our and on the issue tracker.

Please note this should not be used in production, since there are no security and all you data will be publicly available.

How does it work

An Owin middleware exposes Umbraco Published Content as a GraphQL endpoint.

GraphQL types are dynamically generated for all Umbraco document types (content and media), with all the properties as fields. They all implement an interface PublishedContent which implements the generic Umbraco properties as fields.

Installation

The preferred way to install GraphQL for Umbraco is through NuGet

Option 1: NuGet

GraphQL for Umbraco is available as a NuGet package.

To install run the following command in the Package Manager Console

PM> Install-Package Our.Umbraco.GraphQL

Option 2: From source

Clone the repository and run the Website (F5 in Visual Studio), install Umbraco with the starter kit and start exploring the API using GraphiQL by opening /umbraco/graphiql.

Urls

Url Description
/umbraco/graphiql GraphiQL interface
/umbraco/graphql GraphQL endpoint
/umbraco/graphql/schema The generated schema

Querying

Query examples based on The Starter Kit

{
  content {
    byType {
      People(id: "1116") {
        pageTitle
        _contentData {
          children {
            items {
              ... on Person {
                _contentData {
                  name
                }
                department
                photo {
                  _contentData {
                    url
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

We can also do some simple filtering and sorting, (Inspired by the Grahpcool filtering) like geting all children of people that starts with the letter J

{
  content {
    byType {
      People(id: "1116") {
        pageTitle
        _contentData {
          peopleStartsWithJ: children(filter: {name_starts_with: "J"}, orderBy: name_ASC) {
            items {
              ... on Person {
                _contentData {
                  name
                }
                department
                photo {
                  _contentData {
                    url
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

And even query for multiple types at the same time

{
  content {
    byType {
      People(id: "1116") {
        pageTitle
        _contentData {
          peopleStartsWithJ: children(filter: {name_starts_with: "J"}, orderBy: name_ASC) {
            items {
              ...SimplePerson
            }
          }
        }
      }
      Products(id: "1107") {
        pageTitle
        defaultCurrency
        featuredProducts {
          ...SimpleProduct
        }
        _contentData {
          children {
            items {
              ...SimpleProduct
            }
          }
        }
      }
    }
  }
}

fragment SimplePerson on Person {
  _contentData {
    name
  }
  department
  photo {
    _contentData {
      url
    }
  }
}

fragment SimpleProduct on Product {
  _contentData {
    name
  }
  price
  sku
  photos {
    _contentData {
      url
    }
  }
}

umbraco-graphql's People

Contributors

jackpenney avatar peteduncanson avatar rasmusjp 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.