0% found this document useful (0 votes)
13 views12 pages

Introduction to GraphQL Basics

GraphQL is a query language for APIs that allows clients to request specific data using a defined type system. It involves defining types and fields for data, which are validated and executed against a schema when queries are received. The document also outlines scalar types, object types, and the structure for query and mutation types in GraphQL.

Uploaded by

wxflyinghigh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views12 pages

Introduction to GraphQL Basics

GraphQL is a query language for APIs that allows clients to request specific data using a defined type system. It involves defining types and fields for data, which are validated and executed against a schema when queries are received. The document also outlines scalar types, object types, and the structure for query and mutation types in GraphQL.

Uploaded by

wxflyinghigh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Introduction to

GraphQL
• GraphQL is a query language for APIs and a
runtime for executing those queries by using
a type system you define for your data. It
allows clients to request exactly the data
they need and nothing more.
• After a GraphQL service is running (typically
at a URL on a web service), it can receive
GraphQL queries to validate and execute.
The service first checks a query to ensure it
only refers to the types and fields defined,
and then runs the provided functions to
produce a result.

• So First Step : Define our Types and Fields


Type System -
describes what data
can be queried

• Every GraphQL service defines a


set of types which completely
describe the set of possible data
you can query on that service.
Then, when queries come in,
they are validated and executed
against that schema.
Scalar Types - Basic
type
• Int: A signed 32‐bit integer.
• Float: A signed double-precision
floating-point value.
• String: A UTF‐8 character sequence.
• Boolean: true or false.
• ID: The ID scalar type represents a
unique identifier, often used to
refetch an object or as the key for a
cache. The ID type is serialized in the
same way as a String; however,
defining it as an ID signifies that it is
not intended to be human‐readable.
Custom
Scalar
Types –
example
Date
Object types and fields
type Character {
name: String!
appearsIn: [Episode!]!
}

define:
Character & Episode are GraphQL Object Type
String : one of the built-in scalar types - these are types that resolve to a single
scalar object, and can’t have sub-selections in the query.

! : non-nullable
Query Type - Read
• Define What & How to read data
• No definition means no read

type Book { type Query {


id: ID! books: [Book]
title: String! bookById(id: ID!): Book
author: String! booksByAuthor(author: String, genre: String):
genre: String [Book]
publishedYear: Int }
}
Mutation Type – Create Update
Delete
type Mutation {
createUser(name: String!, email: String!): User
updateUser(id: ID!, name: String, email: String): User
deleteUser(id: ID!): User
}
SpringBoot + GraphQL

You might also like