Ruby

Summarized using AI

GraphQL

Robert Mosolgo • May 25, 2018 • Sofia, Bulgaria

In this presentation, Robert Mosolgo, a Ruby developer at GitHub, discusses GraphQL, an API system designed to optimize data retrieval for clients. Robert starts by sharing his personal interests in sewing and upholstery, drawing a parallel between craftsmanship in sewing and programming, emphasizing the importance of detail and precision. He then transitions into explaining the core concepts of GraphQL.

Key Points Discussed:
- Introduction to GraphQL: An efficient API framework that allows clients to request only the necessary data from servers, reducing issues of over-fetching and under-fetching.
- Query Language Basics: GraphQL utilizes a query language that enables users to specify the exact data structure they need. For instance, a query might fetch the first five users and their associated repositories.
- Runtime Execution: The process of executing a GraphQL query begins with building a JSON response based on the client's request, utilizing resolver functions to access complex data.
- Schema Definition: GraphQL uses a schema that defines the types and related fields in an application, ensuring data consistency and validation upon requests.
- Documentation and Interactivity: Tools like GraphiQL provide a graphical interface for visualizing the schema and querying capabilities, enhancing the development experience.
- Design Mistakes: Robert reflects on common pitfalls encountered when implementing GraphQL in Ruby. He highlights issues with using anonymous functions in resolver functions and emphasizes the need for clear standard practices and methodologies to ensure maintainability and efficiency.

Significant Examples:
- Robert illustrates the mechanics of GraphQL querying with relatable examples, such as a request for repository names along with programming languages used.
- He discusses how his personal journey in sewing connects with his approach to programming, highlighting the values of craftsmanship between both fields.

Conclusion and Takeaways:
- Developers are encouraged to familiarize themselves with GraphQL’s documentation and adhere to best practices for effective design.
- The session underscores the significance of clarity in design paradigms and the importance of understanding existing coding workflows when transitioning to GraphQL.

Overall, Robert emphasizes that through engaged practices and structured methodologies, developers can successfully navigate and innovate within GraphQL development.

GraphQL
Robert Mosolgo • May 25, 2018 • Sofia, Bulgaria

Robert is a Ruby developer at GitHub, focused on the GraphQL API. In his free time, he likes spending time with his family, reading about programming language design, and doing upholstery projects.

Balkan Ruby 2018

00:00:14.740 Hi everyone, thanks! My name is Robert Mosolgo, and today I'm going to talk to you about GraphQL. Before we dive into that, I wanted to introduce myself and share a bit about my recent projects.
00:00:21.439 One of my hobbies is sewing, which might be an unusual pastime for a programmer, but it's genuinely growing on me. I love working with my sewing machine. It's a mechanical device, and when you work with it, you can appreciate all the different buttons and sliders. You can feel the fabric flowing through it.
00:00:35.860 Here are some of my recent projects. Above the window, you can see the curtains I made, which required lining up the pattern. Much like programming languages, sewing requires attention to details and precision. One of my favorite tools is a ruffler attachment, which helps make ruffles in fabric. Every time the machine operates, it creates beautiful folds in the fabric, and I find it fascinating how mechanics work.
00:00:56.930 Here's a chair I got from Craigslist. The fabric was quite hideous, and it had a peculiar smell. I decided to disassemble it and reassemble it after cleaning. While peeling back the layers, I discovered different materials including polyester padding and horse hair. It was quite an experience uncovering the history behind the chair.
00:01:13.650 I appreciate the personal aspect of these sewing projects and how they connect with the craftsmanship of the past. Yesterday, I walked around the city center, visiting beautiful churches and historical ruins. They remind me of how intertwined history and craftsmanship are, whether in sewing or architecture.
00:01:29.990 Now, regarding my sewing machine, I like to use my grandmother's old machine. It’s a connection to her that I cherish. Wrongly I think about all the time I had to learn and appreciate the mechanics behind every stitch. Sharing a machine with someone like that makes the experience even more meaningful.
00:01:54.990 That’s a bit about myself, and now let’s transition to the topic at hand—GraphQL. I am one of the maintainers of GraphQL Ruby, and I’ll be discussing design mistakes we encounter in these systems.
00:02:00.620 First, I will introduce what GraphQL is. GraphQL is an API system that provides an efficient way for clients to request data from a server. Whether it’s a website or a mobile app, GraphQL allows those clients to pull the information they need from different data sources.
00:02:18.859 In GraphQL, when a client sends a request for some data, it uses a query language that enables precise data fetching. The server processes this request, executes the query, and responds with a structured result that the client can easily use. Understanding both parts—query language and runtime—gives us insight into the GraphQL ecosystem.
00:02:44.169 Let’s start with the query language. For example, if you want to find the first five users, you can request their login usernames and repositories. With GraphQL, you can make precise requests, similar to the SELECT statement in SQL. The curly braces you use in GraphQL represent the structure of the data you want to retrieve.
00:03:06.450 After sending a request, if the resulting object has nested fields, you can ask for those, too. This flexibility allows clients to specify exactly what data they need, which minimizes over-fetching and under-fetching.
00:03:34.570 From a runtime perspective, when executing a GraphQL query, we start building our JSON response from the main selection and move through the fields present in the request. Each field corresponds to a key in the returned data, and for more complex fields, you’ll invoke 'resolver functions' that define how to fetch that data from your application.
00:04:02.330 As an example, when querying a repository, you might ask for the repository name along with the programming languages it uses. Each field you request will invoke the associated resolver function, returning the data needed in the structured response.
00:04:25.670 GraphQL also has a schema that defines all the types and fields available in your application. This type system is significant as it checks and validates the requests, ensuring that anything returned from a field is according to expectation. For instance, a repository field might always return a string, whereas the languages field returns a list of objects.
00:04:57.630 The querying also reveals relationships between data. This understanding opens up opportunities for developers to experiment with their application's approach to feeding data and redefining their APIs for efficiency. As we create applications, understanding the schema allows us to maintain clean connections to the data.
00:05:34.750 Lastly, the documentation aspect of GraphQL enables developers to have immediate insight into the possibilities of querying. The graphical interface (GraphiQL) is a powerful tool that lets you visualize the schema, providing valuable documentation and interactivity.
00:06:12.210 Going back to design mistakes, it’s crucial to learn from our early endeavors with GraphQL in Ruby. When integrating concepts from GraphQL, some mistakes can arise due to the differences in paradigms between Ruby and GraphQL’s operational methodologies.
00:06:44.830 For instance, I initially explored how to use anonymous functions in Ruby within our resolver functions. This approach was not only unfamiliar but raised issues such as debugging complexity and performance. Furthermore, the idea of making everything seamless through vague resolutions sometimes hinders code clarity.
00:07:26.310 Moreover, the way I scripted interactions according to GraphQL specifications sometimes backfired. I realized that relying too heavily on extensive scripts could lead to less flexibility in our system as we work towards building efficient and effective APIs.
00:08:05.500 Throughout my journey with designing a Ruby implementation of GraphQL, I recognized the importance of agreeing on standard practices early on. As we addressed issues actively, we could build a more robust framework fostering collaboration and easier maintenance.
00:08:45.650 Indeed, I have learned that thinking of design paradigms as integral components of our work can yield better results. Transitioning Ruby paradigms into GraphQL development has helped foster an organized approach while addressing various dilemmas.
00:09:26.460 As I wrap up, I'd highly recommend exploring GraphQL’s documentation, as it provides foundational support for any developer looking to implement these concepts. Furthermore, it’s crucial to use best practices, as understanding connectivity and code behavior makes for an efficient design.
00:10:00.540 In conclusion, while pursuing the design of systems based on GraphQL principles, always emphasize clarity and familiarity with Ruby’s workflows. An engaged approach, alongside structured methodologies, makes it easier for developers to experiment and innovate.
00:10:35.580 Thank you for your time. If you have any questions, feel free to reach out, and I’m happy to discuss more on these topics. I also brought some stickers with the GraphQL logo. So if you come up to me, even if you just want to chat, feel free! Thanks again!
Explore all talks recorded at Balkan Ruby 2018
+8