https://github.com/janit/ez-platform-graphql-slides
GraphQL APIs with eZ Platform, a Symfony CMS - slides
https://github.com/janit/ez-platform-graphql-slides
Last synced: about 2 months ago
JSON representation
GraphQL APIs with eZ Platform, a Symfony CMS - slides
- Host: GitHub
- URL: https://github.com/janit/ez-platform-graphql-slides
- Owner: janit
- Created: 2018-02-22T15:09:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-24T18:59:42.000Z (over 8 years ago)
- Last Synced: 2025-02-24T03:37:23.633Z (over 1 year ago)
- Language: JavaScript
- Size: 3.49 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# GraphQL APIs
with eZ Platform
Symfony CMS
eZ Meetup Oslo
February 22nd 2018 - Jani Tarvainen
---
## Agenda
- GraphQL introduction
- GraphQL with eZ Platform
- GraphQL caveats
- Headless site example using Next.js
---
# GraphQL introduction
--
## GraphQL introduction
- Under the GraphQL umbrella:
- A communications protocol
- A Query Language
- Server implementations
- Client implementations
- Timeline:
- Used at Facebook since 2012
- Public release in 2015
- Gaining momentum in 2017
- Notable adopters: GitHub, Pinterest, Neo4j,
Shopify, New York Times, Sky, Twitter, Yelp…
--
## GraphQL introduction
- An alternative to RESTful APIs
- GraphQL independent of protocol,
Not using on HTTP verbs (POST, GET…)
- REST is an architectural pattern
GraphQL is a specification
- GraphQL APIs are strongly typed
- Self-documenting
- You WILL need to write descriptions ;)
--
## GraphQL with PHP & Symfony
- Reference implementation in JavaScript
- Two mature PHP implementations:
- WebOnyx GraphQL library
- Youshido GraphQL library
- Both solid and feature complete
- Symfony integrations:
- OverBlog GraphQL Bundle
- Youshido GraphQL Bundle
- More: GraphQL, PHP and Symfony
--
## GraphQL client libraries
- You can use raw HTTP
- Libs provide
- Convenience
- Client side caching
- Security (Phear the dreaded GraphQL Injection)
- Notable browser / Node.js libraries
-
Relay Modern
- Apollo
- Urql
---
# GraphQL with
eZ Platform
--
## GraphQL for CMS
- CMS has a lot of complexity (content types, permissions, relations, content rendering…)
- A generic protocol, not CMS specific
- Queries are application specific
- Developer friendly for queries (reads)
- Colocation of queries and template 😱
--
## GraphQL and eZ Platform
- eZ Platform does not ship with GraphQL support
- That won't stop you:
- Use the eZ Platform GraphQL Bundle
- Integrate using a Symfony GraphQL bundle
- Roll your own GraphQL server (please don't!)
--
## eZ Platform GraphQL Bundle
- An experimental bundle from October 2016
- Not maintained, but it's mostly glue code ¯\\_(ツ)_/¯
- I forked it to run with eZ Platform v2
- Integrates the OverBlog GraphQL Bundle to repo
- A decent feature list:
- Query content, location and users
- Search content, list location children…
- GraphiQL shell
--
## A simple example query
- eZ Platform specific example
```
{
locationChildren(id: 2) {
content {
name
}
}
}
```
- Gets location children's name property for location 2
--
## Integrate using
a Symfony GraphQL bundle
- Install a generic GraphQL Bundle
- Both OverBlog and Youshido are solid
- OverBlog focusing on Symfony 4 + Flex now
- Similar functionality and lingo
- You will need to:
- Configure schema (with types)
- Create resolver (to resolve queries from content repo)
- Adding GraphQL API to your Symfony Flex app
--
## My recommendations
- For tinkering:
- Use the eZ Platform GraphQL Bundle
- It works great, but there might be issues
- You can extend it with your queries
- For production:
- Create your own GraphQL Bundle integration
- Exact control of what you expose
- A generic framework to expose QueryTypes?
--
## GraphQL Caveats
- You're exposing an generic for users to query
- Users may find things that they shouldn't
- Users could cause load by complex or deep queries
- HTTP caching not trivial
- Everything's a POST in most client libraries
- Even GETs can be very different
- Vulnerable to "GraphQL injections"
- Client libraries sanitize input
- It's just one tool - There's a time and place for it
---
# Headless site example using Next.js
--
- A sample decoupled site built with the
universal JavaScript framework Next.js:
- https://react.nu/
- https://github.com/janit/decoupled-cms-nextjs-graphql
- https://v1-11-hbgl5gq-oiiukjqgkij7e.eu.platform.sh/graphiql
- https://janit.iki.fi/cms-graphql-nextjs/
- https://www.youtube.com/watch?v=efoeIz9xTDs
---
# Thank you
- Questions?