Amira  Ryan

Amira Ryan

1626328200

What is GraphQL Schema & GraphQL Resolver | Fundamentals of GraphQL

What is GraphQL Schema & GraphQL Resolver | Fundamentals of GraphQL | Tutorial -2 | Hindi | हिंदी

GraphQL Schema and GraphQL Resolvers
GraphQL Schema Definition Language
Apollo Server
GraphQL Server
Defining your own query
Defining your own mutation

Github Repo - https://github.com/AnkitDroidGit/GraphQL-Demo

Medium Blog - https://medium.com/@ankitdeveloper/apollo-server-express-graphql-api-using-node-js-with-typescript-e762afaccb8c

Full Playlist - https://www.youtube.com/playlist?list=PLt7lRnT2c5QTdzvHgKybuMankvw855qMW

Part 01 - https://youtu.be/mAFPj-leaMw
Part 02 - https://youtu.be/kdodfiHVn3s
Part 03 - https://youtu.be/UOV03_WQVJ0
Part 04 - https://youtu.be/Ar2JC20nq2w
Part 05 - https://youtu.be/PI-PZau3P7c

Other Interesting Videos and Video series application development :
------- Complete Guide on Flutter Development
https://youtube.com/playlist?list=PLt7lRnT2c5QS4N50fediyOPSrST_-Fh3g

------- Deep linking mobile applications
https://www.youtube.com/playlist?list=PLt7lRnT2c5QRW9ZxKi5hsi9e_AmxLHA77

------- React Hooks Playlist
https://www.youtube.com/playlist?list=PLt7lRnT2c5QRVIELOi2A0NRoY7JHAQdWB

------- Fundamentals of GraphQL in Hindi
ttps://www.youtube.com/playlist?list=PLt7lRnT2c5QTdzvHgKybuMankvw855qMW

Please share your suggestions and feedback with me in the comments below or on Twitter.

Twitter - https://twitter.com/KumarrAnkitt
Linkedin - https://www.linkedin.com/in/kumarankitkumar/
Facebook Group - https://fb.com/groups/tech.talks.group
Facebook Page - https://fb.com/tech.talks.fb.page
Telegram Group: https://t.me/joinchat/JBFH4RzD2WHsvJjrpBcWNQ


(0:00): Introduction
(0:40): What is in this video
(1:18): GraphQL Project setup with NPM
(3:44): Hello World Program
(4:30): Setting up Apollo Server
(7:38): Creating GraphQL Schema For Query
(8:45): Primitive Data Types of GraphQL SDL
(9:20): Creating GraphQL Resolver For Query
(11:29): Adding Schema to Apollo Server
(14:20): Testing GraphQL Query
(14:53): Creating GraphQL Schema For Mutation
(16:05): Creating GraphQL Resolver For Mutation
(18:22): Testing GraphQL Mutation
(20:05): Wrapping Up

#GraphQL #GraphQLQuery #GraphQLMutation #ApolloServer #GraphQLServer

#graphql #graphqlquery #graphqlserver

What is GEEK

Buddha Community

What is GraphQL Schema & GraphQL Resolver | Fundamentals of GraphQL
Brain  Crist

Brain Crist

1600347600

SCHEMAS in SQL Server -MS SQL Server – Zero to Hero Query Master

Introduction

This is part 3 of “MS SQL Server- Zero to Hero” and in this article, we will be discussing about the SCHEMAS in SQL SERVER. Before getting into this article, please consider to visit previous articles in this series from below,

A glimpse of previous articles
Part 1

In part one, we learned the basics of data, database, database management system, and types of DBMS and SQL.

Part 2
  • We learned to create a database and maintain it using SQL statements.
  • Best practice methods were also mentioned.

#sql server #benefits of schemas #create schema in sql #database schemas #how to create schema in sql server #schemas #schemas in sql server #sql server schemas #what is schema in sql server

Delbert  Ferry

Delbert Ferry

1622037600

GraphQL schema delegation

Schema stitching and delegation

Schema delegation is often used together with schema stitching. Schema stitching is a process of combining multiple GraphQL schemas together. It simplifies the creation of a gateway schema — especially when there are multiple services. Schema stitching automatically sets up delegation for root fields that already exist in the stitched-together schemas. New root fields (as well as any new non-root fields) require new resolvers.

#graphql #schema delegation #schema

Elm Graphql: Autogenerate Type-safe GraphQL Queries in Elm

dillonkearns/elm-graphql  

Why use this package over the other available Elm GraphQL packages? This is the only one that generates type-safe code for your entire schema. Check out this blog post, Type-Safe & Composable GraphQL in Elm, to learn more about the motivation for this library. (It's also the only type-safe library with Elm 0.18 or 0.19 support, see this discourse thread).

I built this package because I wanted to have something that:

  1. Gives you type-safe GraphQL queries (if it compiles, it's valid according to the schema),
  2. Creates decoders for you in a seamless and failsafe way, and
  3. Eliminates GraphQL features in favor of Elm language constructs where possible for a simpler UX (for example, GraphQL variables & fragments should just be Elm functions, constants, lets).

See an example in action on Ellie. See more end-to-end example code in the examples/ folder.

Overview

dillonkearns/elm-graphql is an Elm package and accompanying command-line code generator that creates type-safe Elm code for your GraphQL endpoint. You don't write any decoders for your API with dillonkearns/elm-graphql, instead you simply select which fields you would like, similar to a standard GraphQL query but in Elm. For example, this GraphQL query

query {
  human(id: "1001") {
    name
    homePlanet
  }
}

would look like this in dillonkearns/elm-graphql (the code in this example that is prefixed with StarWars is auto-generated)

import Graphql.Operation exposing (RootQuery)
import Graphql.SelectionSet as SelectionSet exposing (SelectionSet)
import StarWars.Object
import StarWars.Object.Human as Human
import StarWars.Query as Query
import StarWars.Scalar exposing (Id(..))


query : SelectionSet (Maybe HumanData) RootQuery
query =
    Query.human { id = Id "1001" } humanSelection


type alias HumanData =
    { name : String
    , homePlanet : Maybe String
    }


humanSelection : SelectionSet HumanData StarWars.Object.Human
humanSelection =
    SelectionSet.map2 HumanData
        Human.name
        Human.homePlanet

GraphQL and Elm are a perfect match because GraphQL is used to enforce the types that your API takes as inputs and outputs, much like Elm's type system does within Elm. elm-graphql simply bridges this gap by making your Elm code aware of your GraphQL server's schema. If you are new to GraphQL, graphql.org/learn/ is an excellent way to learn the basics.

After following the installation instructions to install the @dillonkearns/elm-graphql NPM package and the proper Elm packages (see the Setup section for details). Once you've installed everything, running the elm-graphql code generation tool is as simple as this:

npx elm-graphql https://elm-graphql.herokuapp.com --base StarWars --output examples/src

If headers are required, such as a Bearer Token, the --header flag can be supplied.

npx elm-graphql https://elm-graphql.herokuapp.com --base StarWars --output examples/src --header 'headerKey: header value'

Learning Resources

There is a thorough tutorial in the SelectionSet docs. SelectionSets are the core concept in this library, so I recommend reading through the whole page (it's not very long!).

The examples/ folder is another great place to start.

If you want to learn more GraphQL basics, this is a great tutorial, and a short read: graphql.org/learn/

My Elm Conf 2018 talk goes into the philosophy behind dillonkearns/elm-graphql

Types Without Borders Elm Conf Talk

(Skip to 13:06 to go straight to the dillonkearns/elm-graphql demo).

If you're wondering why code is generated a certain way, you're likely to find an answer in the Frequently Asked Questions (FAQ).

There's a very helpful group of people in the #graphql channel in the Elm Slack. Don't hesitate to ask any questions about getting started, best practices, or just general GraphQL in there!

Setup

dillonkearns/elm-graphql generates Elm code that allows you to build up type-safe GraphQL requests. Here are the steps to setup dillonkearns/elm-graphql.

Add the dillonkearns/elm-graphql elm package as a dependency in your elm.json. You will also need to make sure that elm/json is a dependency of your project since the generated code has lots of JSON decoders in it.

elm install dillonkearns/elm-graphql
elm install elm/json

Install the @dillonkearns/elm-graphql command line tool through npm. This is what you will use to generate Elm code for your API. It is recommended that you save the @dillonkearns/elm-graphql command line tool as a dev dependency so that everyone on your project is using the same version.

npm install --save-dev @dillonkearns/elm-graphql
# you can now run it locally using `npx elm-graphql`,
# or by calling it through an npm script as in this project's package.json

Run the @dillonkearns/elm-graphql command line tool installed above to generate your code. If you used the --save-dev method above, you can simply create a script in your package.json like the following:

{
  "name": "star-wars-elm-graphql-project",
  "version": "1.0.0",
  "scripts": {
    "api": "elm-graphql https://elm-graphql.herokuapp.com/api --base StarWars"
  }

With the above in your package.json, running npm run api will generate dillonkearns/elm-graphql code for you to call in ./src/StarWars/. You can now use the generated code as in this Ellie example or in the examples folder.

Subscriptions Support

You can do real-time APIs using GraphQL Subscriptions and dillonkearns/elm-graphql. Just wire in the framework-specific JavaScript code for opening the WebSocket connection through a port. Here's a live demo and its source code. The demo server is running Elixir/Absinthe.

Contributors

Thank you Mario Martinez (martimatix) for all your feedback, the elm-format PR, and for the incredible logo design!

Thank you Mike Stock (mikeastock) for setting up Travis CI!

Thanks for the reserved words pull request @madsflensted!

A huge thanks to @xtian for doing the vast majority of the 0.19 upgrade work! :tada:

Thank you Josh Adams (@knewter) for the code example for Subscriptions with Elixir/Absinthe wired up through Elm ports!

Thank you Romario for adding OptionalArgument.map!

Thank you Aaron White for your pull request to improve the performance and stability of the elm-format step! 🎉

Roadmap

All core features are supported. That is, you can build any query or mutation with your dillonkearns/elm-graphql-generated code, and it is guaranteed to be valid according to your server's schema.

dillonkearns/elm-graphql will generate code for you to generate subscriptions and decode the responses, but it doesn't deal with the low-level details for how to send them over web sockets. To do that, you will need to use custom code or a package that knows how to communicate over websockets (or whichever protocol) to setup a subscription with your particular framework. See this discussion for why those details are not handled by this library directly.

I would love to hear feedback if you are using GraphQL Subscriptions. In particular, I'd love to see live code examples to drive any improvements to the Subscriptions design. Please ping me on Slack, drop a message in the #graphql channel, or open up a Github issue to discuss!

I would like to investigate generating helpers to make pagination simpler for Connections (based on the Relay Cursor Connections Specification). If you have ideas on this chime in on this thread.

See the full roadmap on Trello.


Author: dillonkearns
Source Code: https://github.com/dillonkearns/elm-graphql
License: View license

#graphql 

Amira  Ryan

Amira Ryan

1626328200

What is GraphQL Schema & GraphQL Resolver | Fundamentals of GraphQL

What is GraphQL Schema & GraphQL Resolver | Fundamentals of GraphQL | Tutorial -2 | Hindi | हिंदी

GraphQL Schema and GraphQL Resolvers
GraphQL Schema Definition Language
Apollo Server
GraphQL Server
Defining your own query
Defining your own mutation

Github Repo - https://github.com/AnkitDroidGit/GraphQL-Demo

Medium Blog - https://medium.com/@ankitdeveloper/apollo-server-express-graphql-api-using-node-js-with-typescript-e762afaccb8c

Full Playlist - https://www.youtube.com/playlist?list=PLt7lRnT2c5QTdzvHgKybuMankvw855qMW

Part 01 - https://youtu.be/mAFPj-leaMw
Part 02 - https://youtu.be/kdodfiHVn3s
Part 03 - https://youtu.be/UOV03_WQVJ0
Part 04 - https://youtu.be/Ar2JC20nq2w
Part 05 - https://youtu.be/PI-PZau3P7c

Other Interesting Videos and Video series application development :
------- Complete Guide on Flutter Development
https://youtube.com/playlist?list=PLt7lRnT2c5QS4N50fediyOPSrST_-Fh3g

------- Deep linking mobile applications
https://www.youtube.com/playlist?list=PLt7lRnT2c5QRW9ZxKi5hsi9e_AmxLHA77

------- React Hooks Playlist
https://www.youtube.com/playlist?list=PLt7lRnT2c5QRVIELOi2A0NRoY7JHAQdWB

------- Fundamentals of GraphQL in Hindi
ttps://www.youtube.com/playlist?list=PLt7lRnT2c5QTdzvHgKybuMankvw855qMW

Please share your suggestions and feedback with me in the comments below or on Twitter.

Twitter - https://twitter.com/KumarrAnkitt
Linkedin - https://www.linkedin.com/in/kumarankitkumar/
Facebook Group - https://fb.com/groups/tech.talks.group
Facebook Page - https://fb.com/tech.talks.fb.page
Telegram Group: https://t.me/joinchat/JBFH4RzD2WHsvJjrpBcWNQ


(0:00): Introduction
(0:40): What is in this video
(1:18): GraphQL Project setup with NPM
(3:44): Hello World Program
(4:30): Setting up Apollo Server
(7:38): Creating GraphQL Schema For Query
(8:45): Primitive Data Types of GraphQL SDL
(9:20): Creating GraphQL Resolver For Query
(11:29): Adding Schema to Apollo Server
(14:20): Testing GraphQL Query
(14:53): Creating GraphQL Schema For Mutation
(16:05): Creating GraphQL Resolver For Mutation
(18:22): Testing GraphQL Mutation
(20:05): Wrapping Up

#GraphQL #GraphQLQuery #GraphQLMutation #ApolloServer #GraphQLServer

#graphql #graphqlquery #graphqlserver

Jamie  Graham

Jamie Graham

1645039140

TypeGraphQL: Create GraphQL Schema and Resolvers with TypeScript

TypeGraphQL

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!

Introduction

TypeGraphQL makes developing GraphQL APIs an enjoyable process, i.e. by defining the schema using only classes and a bit of decorator magic.

So, to create types like object type or input type, we use a kind of DTO classes. For example, to declare Recipe type we simply create a class and annotate it with decorators:

@ObjectType()
class Recipe {
  @Field(type => ID)
  id: string;

  @Field()
  title: string;

  @Field(type => [Rate])
  ratings: Rate[];

  @Field({ nullable: true })
  averageRating?: number;
}

And we get the corresponding part of the schema in SDL:

type Recipe {
  id: ID!
  title: String!
  ratings: [Rate!]!
  averageRating: Float
}

Then we can create queries, mutations and field resolvers. For this purpose we use controller-like classes that are called "resolvers" by convention. We can also use awesome features like dependency injection and auth guards:

@Resolver(Recipe)
class RecipeResolver {
  // dependency injection
  constructor(private recipeService: RecipeService) {}

  @Query(returns => [Recipe])
  recipes() {
    return this.recipeService.findAll();
  }

  @Mutation()
  @Authorized(Roles.Admin) // auth guard
  removeRecipe(@Arg("id") id: string): boolean {
    return this.recipeService.removeById(id);
  }

  @FieldResolver()
  averageRating(@Root() recipe: Recipe) {
    return recipe.ratings.reduce((a, b) => a + b, 0) / recipe.ratings.length;
  }
}

And in this simple way we get this part of the schema in SDL:

type Query {
  recipes: [Recipe!]!
}

type Mutation {
  removeRecipe(id: String!): Boolean!
}

Motivation

We all know that GraphQL is great and solves many problems we have with REST APIs, like overfetching and underfetching. But developing a GraphQL API in Node.js with TypeScript is sometimes a bit of a pain. Why? Let's take a look at the steps we usually have to take.

First, we create all the GraphQL types in schema.gql using SDL. Then we create our data models using ORM classes, which represent our db entities. Then we start to write resolvers for our queries, mutations and fields, but this forces us to first create TS interfaces for all arguments, inputs, and even object types.

Only then can we actually implement the resolvers using weird generic signatures and manually performing common tasks, like validation, authorization and loading dependencies:

export const getRecipesResolver: GraphQLFieldResolver<void, Context, GetRecipesArgs> = async (
  _,
  args,
  ctx,
) => {
  // common tasks repeatable for almost every resolver
  const repository = TypeORM.getRepository(Recipe);
  const auth = Container.get(AuthService);
  await joi.validate(getRecipesSchema, args);
  if (!auth.check(ctx.user)) {
    throw new NotAuthorizedError();
  }

  // our business logic, e.g.:
  return repository.find({ skip: args.offset, take: args.limit });
};

The biggest problem is redundancy in our codebase, which makes it difficult to keep things in sync. To add a new field to our entity, we have to jump through all the files - modify an entity class, the schema, as well as the interface. The same goes for inputs or arguments. It's easy to forget to update one piece or make a mistake with a single type. Also, what if we've made a typo in field name? The rename feature (F2) won't work correctly.

Tools like GraphQL Code Generator or graphqlgen only solve the first part - they generate the corresponding interfaces (and resolvers skeletons) for our GraphQL schema but they don't fix the schema <--> models redundancy and developer experience (F2 rename won't work, you have to remember about the codegen watch task in background, etc.), as well as common tasks like validation, authorization, etc.

TypeGraphQL comes to address these issues, based on experience from a few years of developing GraphQL APIs in TypeScript. The main idea is to have only one source of truth by defining the schema using classes and some help from decorators. Additional features like dependency injection, validation and auth guards help with common tasks that normally we would have to handle ourselves.

Documentation

The documentation, installation guide, detailed description of the API and all of its features is available on the website.

Getting started

A full getting started guide with a simple walkthrough (tutorial) can be found at getting started docs.

Video tutorial

If you prefer video tutorials, you can watch Ben Awad's TypeGraphQL video series on YouTube.

Examples

You can also check the examples folder in this repository for more examples of usage: simple fields resolvers, DI Container support, TypeORM integration, automatic validation, etc.

The Tests folder might also give you some tips how to get various things done.

The future

The currently released version is a stable 1.0.0 release. It is well tested (95% coverage, 428 test cases) and has most of the planned features already implemented. Plenty of companies and independent developers are using it in production with success.

However, there are also plans for a lot more features like better TypeORM, Prisma and dataloader integration, custom decorators and metadata annotations support - the full list of ideas is available on the GitHub repo. You can also keep track of development's progress on project board.

If you have any interesting feature requests, feel free to open an issue on GitHub so we can discuss that!

Support

TypeGraphQL is an MIT-licensed open source project. This framework is a result of the tremendous amount of work - sleepless nights, busy evenings and weekends.

It doesn't have a large company that sits behind - its ongoing development is possible only thanks to the support by the community.

Download Details:
Author: 
Source Code: 
License:

#graphql #typescript #schema #TypeGraphQL