►
From YouTube: Creating A GraphQL Backend
Description
Continuing with our coverage on GraphQL, Brandon gets into the code of the graphql-dotnet SDK and shows us how to create a GraphQL endpoint.
Learn more: https://codetraveler.io/DotNetGraphQL
[00:51] - GraphQL SDK options for .NET
[02:20] - Adding a GraphQL query
[10:18] - Follow up resources
GraphQL for .NET
https://github.com/graphql-dotnet/graphql-dotnet
Hot Chocolate: A GraphQL Server for .NET
https://hotchocolate.io/
ASP.NET Core docs
https://docs.microsoft.com/aspnet/core/?view=aspnetcore-3.1&WT.mc_id=dotnet-c9-cephilli
#AspNet #Dotnet #GraphQL #WebDev
A
A
Hello
and
welcome
to
another
episode
of
on
dotnet.
My
name
is
jeremy
licinus
and
today
we're
continuing
our
graph
QL
series.
If
you
haven't
seen
the
introduction,
go
check
that
out,
because
today
we're
taking
what
we
learned
and
looking
at
how
you
stand
up
a
graph,
QL
endpoint
I'm
here
with
Brandon
Minich
again
Brandon
welcome
back
thanks
for
having
me
Jeremy.
It's
almost
like
you've
been
here
all
so
tell
us
a
little
bit
about.
We
talked
about
graph
QL,
but
now
I
want
to
use
it.
B
So
you
could
start
from
scratch.
Graph
QL
is
a
open
source
framework.
It's
was
created
by
Facebook,
but
it's
now
actually
owned
by
the
graph
QL
foundation
similar
to
the
dotnet
foundation.
But
what
I
recommend
is
a
couple
popular
SDKs
to
help
us
get
started
and
the
two
most
popular
ones
right
now,
our
graph
QL
net
and
hot
chocolate.
Okay.
A
B
Graph
QL
dotnet-
it
definitely
is
the
most
popular
it
has
millions
of
downloads
on
nougat,
and
a
lot
of
that
is
because
it
was
the
first
graph
QL
library
for
us
dotnet
developers,
but
there's
a
rising
star,
exciting
new
library
called
hot
chocolate
that
is
quickly
gaining
traction.
So
for
today's
demo,
we'll
use
graph
QL
net
but
highly
recommend
hot
chocolate
to
anybody,
who's
looking
to
get
started
and
learn
more
as
well
and.
A
B
B
Know
choose
the
one
that
makes
the
most
sense
to
you
and
the
one
you're
most
familiar
with
and
most
accessible
with
cool,
so
yeah,
let's
jump
right
into
it.
Let's,
let's
write
some
code,
so
I
have
here
a
graph
QL
library.
This
is
all
done
in
dotnet
core
three
and
because
it's
all
in
net
I
also
have
code
from
my
mobile
app
in
here,
which
will
show
off
in
our
next
section
where
we
learn
how
to
consume
this
API
from
our
mobile
app.
Okay,.
A
B
For
now,
let's
go
ahead
and
run
this
API
just
to
show
what
it's
doing
right
now
so
right
now
it's
running
here
on
my
local
host
and
just
like
we
learned
in
the
last
episode
we
get
graphical
for
free,
so
I
didn't
write
any
code.
This
just
appears
when
I
clicked
run
and
also
like
we
learned
in
the
last
episode.
We
get
self-documenting
code,
so
graph
graphical
automatically
combs
through
my
graph
QL
backend
and
exposes
all
the
types
that
are
available
for
us
to
query.
B
So
what
we're
creating
today
is
a
favorite
dogs,
app
I'm,
a
dog
lover,
and
you
know
it's
always
nice
to
us
to
be
able
to
have
a
look
at
your
favorite
dog
on
a
mobile,
app
and
so
right.
Now
what
we
have
in
our
graph,
QL
back-end,
we're
able
to
query
for
one
dog,
so
I
can
use
what
we
learned
in
the
last
episode
and
we
can
type
in
a
specific
dog,
so
we'll
type
in
my
dog's
name
Kirby
and
then
for
that
dog.
B
Is
not
so
this
is.
That
was
something
that
tripped
me
up
at
first,
because
I'm
used
to
just
querying
a
REST
API
I'm
used
to
saying
hit
this
get
rest
API
and
give
me
all
the
data,
and
so
the
first
thing
I
would
try.
I
would
do
something
like
this,
where
I
would
say,
give
me
everything
about
Kirby,
but
no
yeah.
B
Okay,
but
now
that
we
passed
those
in
well,
we
can
get
that
information
back
about
Kirby
so
sure.
So
this
is
great,
but
one
of
the
benefits
of
graph
QL
is
we
don't
want
to
make
multiple
round
trips?
We
only
need
to
make
one
round
trip
with
our
graph
QL
endpoint
and
the
way
I've
designed
our
import
right
now.
It
can't
return
a
list
of
dogs.
So,
okay,
let's
go
ahead
and
jump
into
the
code
and
add
that
it
sounds
like
a
plan
so
exploring
our
our
code.
Here
we
have
this.
B
We
have
this
images
query.
So
this
is
what
appears
when
we
click
on
query.
So
right
now
we
see
one
field
that
we
can
pass
in
a
string
for
the
dog's
name
and
it
returns
a
dog
object
and
looking
at
the
code,
we
see
all
the
same
information,
but
this
is
how
we
can
generate
that
for
our
endpoint.
So
we
tell
it
that
we
want
to
expose
a
field
and
for
graac
ul
we
create
a
graph
type
for
our
model.
B
So
one
cool
thing
about
this
is:
if
I
go
to
this
declaration,
we're
using
my
dog
images
model.
The
dog
images
model-
this
is
my
C
sharp
object,
just
properties,
getters
setters,
nothing,
fancy
just
breed
birthday
coat
color,
but
for
a
graph
QL
we
can
actually
specify
which
fields
we
want
to
expose
and
which
ones
we
don't
so
things
like.
Maybe
we
don't
want
to
share
the
birthday
so
if
I
wanted
to
I
could
comment
this
out
and
when
we
rerun
our
graph
QL
API
and
jump
back
into
that
documentation
Explorer.
B
A
B
Cool
yeah,
and
so
so
that's
how
we
are
exposing
those
fields,
and
we
were
saying
we
want
to
also
be
able
to
query
for
all
the
dogs.
So
what
we'll
generate
here
we'll
say:
we'll
have
another
field
underneath
this
query,
and
this
will
actually
be
a
list
list
graph
type
and
the
type
of
that
will
be
the
dog
images
graph
type,
and
then
we
just
have
to
give
it
a
little
bit
of
information.
So
this
is
what
we'll
call
it
so
for
the
other
one.
We
called
it
dog
because
it
just
returns.
B
It's
gonna
look
a
little
different
because
the
previous
one
had
to
have
an
argument
where
we
passed
in
the
dog's
name
right,
because
we
were
only
returning
one
dog,
so
we
had
to
tell
the
user
wit
or
ask
the
user,
which
dog
for
this
we're
not
gonna,
require
a
specific
parameter,
specific
query
argument,
so
we'll
just
jump
down
straight
to
what's
called
the
resolver
and
there
we
go,
and
so
the
resolver
just
tells
the
graph
QL
endpoint
how
to
get
the
data.
So.
B
Maybe
this
data
is
in
a
database
and
we
could
point
this
to
our
our
sequel
database.
Maybe
we're
building
a
graph,
ul
API
in
front
of
an
existing
suite
of
REST
API
s.
We
could
actually
point
this
to
existing
REST
API
s
nice.
So
in
this
case
we'll
point
it
to
my
my
dog
images
data
and
we'll
just
tell
it
to
get
all
of
the
dog
images
and
we're
getting
yelled
at
no.
No.
Here,
let's
go
ahead
and
stop
rid
of
this.
B
See
what
I
did
okay
I
forgot
to
tell
it,
because
we
need
to
pass
in
a
context.
It
just
so
happens,
I'm
not
using
the
the
current
context
here.
This
is
just
basically
some
dummy
data
that
were
returning
back.
Ok,
so
now,
let's
run
it
and
when
we
run
this
again
we'll
see
in
our
documentation,
Explorer
will
see
the
original
dog
query,
but
now
here's
the
new
one
we
just
created.
So
what
we're
able
to
do
now
is
create
that
query
where
we
can
request
all
the
dogs,
but
again
just
like
we
said
earlier.
B
B
A
It
sounds
like
you
have
full
control
over
what
you're
returning
it
doesn't
matter
if
it's
XYZ
database,
but
you
have
an
API
that
you
basically
say
when
I
ask
for
this.
This
is
how
you
get
it
and
then
once
you
do
that
the
client
is
off
to
the
races.
So
it's
not
like,
because
I've
heard
some
people
say
we're
passing
control
to
the
client
and
they
could
just
write
any
query
and
that's
not
a
good
thing,
but
you've
got
control
over
what's
being
passed.
Then
exactly.
B
Yeah,
just
like
with
any
API,
will
restrict
or
expose
only
the
data
we
want
so
right.
We
don't
have
to
share
any
PII
like
birth
dates
or
passwords,
or
anything
look
crazy
like
that,
because
nobody
needs
to
see
that
very
good
all
right.
So,
if
you're
wondering
where
to
find
this
code,
it
is
all
available
on
github
and
what
we've
done
today,
we've
put
together
this
webpage.