{
allTeams {
nodes {
name
slug
conferenceSlug
}
}
}
{
teams: allTeams(condition: {conferenceSlug: "afc"}, orderBy: NAME_ASC) {
nodes {
name
slug
}
}
}
query conferenceTeams($slug: String!) {
teams: allTeams(condition: {conferenceSlug: $slug}, orderBy: NAME_ASC) {
nodes {
...TeamDetails
divisionSlug
}
}
}
fragment TeamDetails on Team {
name
slug
}
{
currentSeason: seasonByYear(year: 2018) {
...SeasonDetails
}
tweets: allTweets {
nodes {
...TweetDetails
}
}
teams: allTeams {
nodes {
...TeamDetails
}
}
}
npx postgraphile -c <DATABASE_URL>
app/schema.py
from graphene_django.types import DjangoObjectType
from .models import Category
class CategoryType(DjangoObjectType):
class Meta:
model = Category
app/schema.py
class Query(object):
all_categories = graphene.List(CategoryType)
def resolve_all_categories(self, info, **kwargs):
return Category.objects.all()
project/schema.py
from graphene import ObjectType
from app.schema import Query as AppQuery
class Query(AppQuery, ObjectType):
pass
schema = graphene.Schema(query=Query)
project/settings.py
INSTALLED_APPS = [
...,
'graphene_django',
]
...
GRAPHENE = {
'SCHEMA': 'project.schema.schema',
}
project/urls.py
from graphene_django.views import GraphQLView
urlpatterns = [
url(r'^graphql', GraphQLView.as_view(graphiql=True)),
]
Interface
ObjectType
or DjangoObjectType
object
You can use Django REST Framework serializer for mutations in GraphQL
PrivateGraphQLView
- Use base64
, Luke
- But why…
graphql-core-next
will be the case