Skip to content

Urth challenge intended for full stack developers (API Graphql)

License

Notifications You must be signed in to change notification settings

zeimbeekor/go-dapr-gql-service

Repository files navigation

GO-DAPR-QGL-SERVICE

Overview

GraphQL servers in golang

Pre-requisites

Quick start

Follow the steps below to use this service

  1. Copy dapr bindings spec files
$ cp ./dapr/bindings/components/jsonbinding.yaml $HOME/.dapr/components/jsonbinding.yaml
$ cp ./dapr/bindings/components/graphql.yaml $HOME/.dapr/components/graphql.yaml
  1. Run the API Graphql service alongside a Dapr sidecar
$ make run
  1. Prepare Data
$ curl --location --request POST 'http://localhost:7000/query' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"mutation {\n  createTodo {\n    id\n  }\n}","variables":{}}'

More help to get started gqlgen

Reporting Issues

If you think you've found a bug, or something isn't behaving the way you think it should, please raise an issue on GitHub.

Frequently asked questions

Models

type Post {
  id: Int!
  title: String!
  body: String!
  url: String!
  type: String!
  userId: Int!
  createdAt: String!
  comments: [Comment]
}
type Comment {
  id: Int!
  name: String!
  email: String!
  body: String!
  postId: Int!
  createdAt: String!
}
type Geo {
  lat: String!
  lng: String!
}
type Address {
  street: String!
  suite: String!
  city: String!
  zipcode: String!
  geo: Geo!
}
type Company {
  name: String!
  catchPhrase: String!
  bs: String!
}
type User {
  id: Int!
  name: String!
  username: String!
  email: String!
  photo: String!
  website: String!
  createdAt: String!
  address: Address!
  company: Company!
  posts: [Post]
}
type Todo {
  id: Int!
  title: String!
  completed: Boolean!
  user: User!
}

Querys

  • posts: [Post!]!
  • comments: [Comment!]!
  • todos: [Todo!]!
  • users: [User!]!
  • user(id: Int!): User!
  • post(id: Int!): Post!
  • comment(id: Int!): Comment!
  • getInfoByUserId(id: Int!): User!
  • getPostsByUserId(id: Int!, postType: String!): [Post!]!
  • getCommentsByPostId(id: Int!): [Comment!]!

Mutations

  • createTodo: [Todo!]!

Postman Collection

Examples: misc/urth.postman_collection.json

How to get all posts?

$ curl --location --request POST 'http://localhost:7000/query' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{\n  posts {\n    id\n    title\n    body\n    url\n    type\n    userId\n    createdAt\n  }\n}","variables":{}}'

How to get all comments?

$ curl --location --request POST 'http://localhost:7000/query' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{\n  comments {\n    id\n    name\n    email\n    body\n    postId\n    createdAt\n  }\n}","variables":{}}'

How to get all users?

$ curl --location --request POST 'http://localhost:7000/query' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{\n  users {\n    id\n    name\n    username\n    email\n    photo\n    website\n    address {\n      street\n      suite\n      city\n      zipcode\n      geo {\n        lat\n        lng\n      }\n    }\n    company {\n      name\n      catchPhrase\n      bs\n    }\n    createdAt\n  }\n}","variables":{}}'

Contributing

License

Check the LICENSE file for details

About

Urth challenge intended for full stack developers (API Graphql)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published