0Pricing
GraphQL APIs with Spring Boot · درس

تصميم أول مخطط GraphQL لك

تعلّم تحديد أنواع المخطط وحقوله الأساسية، وافهم Schema Definition Language (SDL).

تصميم أول مخطط GraphQL لك درس مجاني في GraphQL APIs with Spring Boot على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في GraphQL APIs with Spring Boot، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة GraphQL APIs with Spring Boot 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

What's a GraphQL Schema?

A GraphQL schema is the blueprint of your API: it defines what data clients can ask for and how it’s structured. It’s the core of every GraphQL service.

Meet SDL: Schema Language

You write schemas in the Schema Definition Language (SDL) — a simple, readable syntax for declaring object types, their fields, and how they relate.

Building Blocks: Object Types

The core building block is the object type, declared with the type keyword. Like a class, it represents a kind of object you can fetch.

type User {
  # Fields will go here
}

Adding Fields with Scalar Types

Fields hold data via built-in scalar types: String, Int, Float, Boolean, and ID for unique identifiers.

type User {
  id: ID
  name: String
  age: Int
  isActive: Boolean
  rating: Float
}

Essential Data: Non-Null Fields

Add ! after a type to make a field non-null — it must always have a value. Query it and the server must return one or it errors.

type Product {
  id: ID!
  name: String!
  price: Float!
  description: String
}

Collections: Lists in GraphQL

Wrap a type in [] for a list. Stack the ! too: [String!]! means a non-null list of non-null strings.

type Book {
  id: ID!
  title: String!
  pages: Int
}

type Author {
  id: ID!
  name: String!
  books: [Book] # A list of books, can be empty or null
  tags: [String!]! # A list of non-null strings, and the list itself is non-null
}

Entry Point: The Query Type

Every schema needs the root Query type — it defines all the entry points for clients to read data. Queries always start here.

type Query {
  # Query fields will go here
}

Defining Query Fields

Fields on Query are the data you can fetch, and they take arguments to filter — like book(id: ID!): Book to grab one book by id.

type Author {
  id: ID!
  name: String!
}

type Book {
  id: ID!
  title: String!
}

type Query {
  allAuthors: [Author!]!
  bookById(id: ID!): Book
}

Your First Complete Schema

Here it all comes together: Author and Book types, a Query entry point, and a Book.author field that links the two. Relationships!

type Author {
  id: ID!
  name: String!
  books: [Book!]! # An author has a list of non-null books
}

type Book {
  id: ID!
  title: String!
  pages: Int
  author: Author # A book has one author
}

type Query {
  allBooks: [Book!]!
  book(id: ID!): Book
  allAuthors: [Author!]!
  author(id: ID!): Author
}

Schema Check-up

What does ! mean, and where does Query fit? Prove it.

Schema Design Recap

You designed a real schema: object types with the type keyword, scalar fields, ! for non-null, [] for lists, and Query as the read entry point.

الأسئلة الشائعة

هل درس «تصميم أول مخطط GraphQL لك» مجاني؟

نعم — نص درس «تصميم أول مخطط GraphQL لك» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة GraphQL APIs with Spring Boot، انتقل إلى CoddyKit PRO. تتضمن دورة GraphQL APIs with Spring Boot 4 دروس في المجموع.

ماذا ستتعلم في «تصميم أول مخطط GraphQL لك»؟

تعلّم تحديد أنواع المخطط وحقوله الأساسية، وافهم Schema Definition Language (SDL). تتمرن على GraphQL APIs with Spring Boot مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ GraphQL APIs with Spring Boot؟

لا تُشترط خبرة سابقة. GraphQL APIs with Spring Boot على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «تصميم أول مخطط GraphQL لك»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس GraphQL APIs with Spring Boot هذا؟

نعم. كل درس في GraphQL APIs with Spring Boot يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. ما المقصود بـ GraphQL؟
  2. إعداد Spring Boot لـ GraphQL
  3. تصميم أول مخطط GraphQL لك
  4. GraphQL أم REST: اختيار النهج المناسب
← العودة إلى GraphQL APIs with Spring Boot