Giter Club home page Giter Club logo

graphql-interview-questions's Introduction

๐Ÿ–ฒ 25 Essential GraphQL interview questions and answers in 2021

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools. Follow along and check our list of 25 common GraphQl interview questions and answers and get ready for your next developer interview in 2021.



You can also find all 25 answers here ๐Ÿ‘‰๐Ÿผ https://devinterview.io/dev/graphql-interview-questions


๐Ÿ”น 1. What is GraphQL?

Answer:

GraphQL is a query language created by Facebook in 2012 which provides a common interface between the client and the server for data fetching and manipulations.

The client asks for various data from the GraphQL server via queries. The response format is described in the query and defined by the client instead of the server: they are called clientโ€specified queries.
The structure of the data is not hardcoded as in traditional REST APIs - this makes retrieving data from the server more efficient for the client.

Source:ย howtographql.comย  ย 


๐Ÿ”น 2. Is GraphQL a Database Technology?

Answer:

No. GraphQL is often confused with being a database technology. This is a misconception, GraphQL is a query language for APIs - not databases. In that sense itโ€™s database agnostic and can be used with any kind of database or even no database at all.

Source:ย howtographql.comย  ย 


๐Ÿ”น 3. What is an exclamation point in GraphQL?

Answer:

That means that the field is non-nullable. By default, all types in GraphQL are nullable. When non-null is applied to the type of a field, it means that if the server resolves that field to null, the response will fail validation.

Source:ย stackoverflow.comย  ย 


๐Ÿ”น 4. Is GraphQL only for React / Javascript Developers?

Answer:

No. GraphQL is an API technology so it can be used in any context where an API is required.

On the backend, a GraphQL server can be implemented in any programming language that can be used to build a web server. Next to Javascript, there are popular reference implementations for Ruby, Python, Scala, Java, Clojure, Go and .NET.

Since a GraphQL API is usually operated over HTTP, any client that can speak HTTP is able to query data from a GraphQL server.

Note: GraphQL is actually transport layer agnostic, so you could choose other protocols than HTTP to implement your server.

Source:ย howtographql.comย  ย 


๐Ÿ”น 5. What is difference between Mutation and Query?

Answer:

Technically any GraphQL query could be implemented to cause a data write. But there is a convention that any operations that cause writes should be sent explicitly via a mutation.

Besides the difference in the semantic, there is one important technical difference:

Query fields can be executed in parallel by the GraphQL engine while Mutation top-level fields MUST execute serially according to the spec.

Source:ย stackoverflow.comย  ย 


๐Ÿ”น 6. What is GraphQL schema?

Answer:

Every GraphQL server has two core parts that determine how it works: a schema and resolve functions.

The schema is a model of the data that can be fetched through the GraphQL server. It defines what queries clients are allowed to make, what types of data can be fetched from the server, and what the relationships between these types are.

Consider:

type Author {
  id: Int
  name: String
  posts: [Post]
}
type Post {
  id: Int
  title: String
  text: String
  author: Author
}
type Query {
  getAuthor(id: Int): Author
  getPostsByTitle(titleContains: String): [Post]
}
schema {
  query: Query
}
Source:ย dev-blog.apollodata.comย  ย 


๐Ÿ”น 7. Where is GraphQL useful?

Answer:

GraphQL helps where your client needs a flexible response format to avoid extra queries and/or massive data transformation with the overhead of keeping them in sync.

Using a GraphQL server makes it very easy for a client side developer to change the response format without any change on the backend.

With GraphQL, you can describe the required data in a more natural way. It can speed up development, because in application structures like top-down rendering in React, the required data is more similar to your component structure.

Source:ย blog.risingstack.comย  ย 


๐Ÿ”น 8. How to do Error Handling?

Answer:

A successful GraphQL query is supposed to return a JSON object with a root field called "data". If the request fails or partially fails (e.g. because the user requesting the data doesnโ€™t have the right access permissions), a second root field called "errors" is added to the response:

    {
      "data": { ... },
      "errors": [ ... ]
    }
Source:ย howtographql.comย  ย 


๐Ÿ”น 9. How to query all the GraphQL type fields without writing a long query?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 10. List the key concepts of the GraphQL query language

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 11. How to do Server-side Caching?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 12. How to do Authentication and Authorization?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 13. What kind of operations could GraphQL schema have?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 14. Does GraphQL Support Offline Usage?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 15. Explain the main difference between REST and GraphQL

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 16. Whether do you find GraphQL the right fit for designing microservice architecture?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 17. How to implement a set of GraphQL mutations in single transaction?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 18. Are there any disadvantages to GraphQL?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 19. Can you make a GraphQL type both an input and output type?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 20. How do you prevent nested attack on GraphQL server?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 21. What is AST in GraphQL?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 22. Is it possible to use inheritance with GraphQL input types?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 23. How to respond with different status code in GraphQL?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 24. What the criteria set is for deciding when to use GraphQL vs. HATEOAS?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


๐Ÿ”น 25. How would you model recursive data structures in GraphQL?

๐Ÿ‘‰๐Ÿผ Check all 25 answers


graphql-interview-questions's People

Contributors

devinterview-io avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.