GO and GraphQL Flashcards
(49 cards)
What is Go (Golang)?
An open-source programming language designed for simplicity, concurrency, and performance.
What is the purpose of goroutines in Go?
To allow lightweight concurrent execution of functions.
What is a channel in Go?
A mechanism to communicate between goroutines and synchronize their execution.
How does Go manage memory?
Go uses a garbage collector to automatically manage memory allocation and deallocation.
What is the use of defer in Go?
To schedule a function call to run after the function completes, often used for cleanup.
What are Go interfaces?
A type that specifies method signatures. Types implicitly implement interfaces by defining those methods.
What is the zero value in Go?
The default value a variable has when declared without explicit initialization.
What is a struct in Go?
A composite type that groups variables (fields) under one name.
What is a Go module?
A collection of related Go packages with versioning, defined in a go.mod
file.
What is the go.mod file?
Defines the module’s path and its dependency versions.
What is GraphQL?
A query language for APIs that allows clients to request exactly the data they need.
What is a GraphQL schema?
A contract that defines types, queries, mutations, and subscriptions for a GraphQL API.
What are resolvers in GraphQL?
Functions that return data for specific fields in a GraphQL schema.
What is a query in GraphQL?
A read operation that requests data from the server.
What is a mutation in GraphQL?
A write operation used to modify server-side data.
What is a subscription in GraphQL?
Allows clients to receive real-time updates from the server.
What is introspection in GraphQL?
The ability for clients to query the schema itself for available types and fields.
What is a scalar type in GraphQL?
Basic data types such as Int, Float, String, Boolean, and ID.
What is a custom scalar in GraphQL?
User-defined scalar types used to represent complex values like DateTime.
What is a fragment in GraphQL?
Reusable selection sets that can be used across multiple queries.
What is gqlgen?
A Go library for building GraphQL servers with type-safe resolvers generated from schemas.
How does gqlgen generate code?
It uses a schema-first approach to generate Go code from .graphql schema files.
Where do gqlgen resolvers live?
In the resolver.go
file under the graph
package by default.
How do you define schema in gqlgen?
Using .graphql files with type, query, and mutation definitions.