Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mbrsagor/graphql
JavaScript GraphSql
https://github.com/mbrsagor/graphql
graphsql javascript
Last synced: 1 day ago
JSON representation
JavaScript GraphSql
- Host: GitHub
- URL: https://github.com/mbrsagor/graphql
- Owner: mbrsagor
- Created: 2018-05-19T21:58:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-28T16:16:20.000Z (10 months ago)
- Last Synced: 2024-01-28T17:35:32.845Z (10 months ago)
- Topics: graphsql, javascript
- Language: JavaScript
- Homepage:
- Size: 39.5 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphql
> JavaScript Graphql Repo.###### What is Graphql?
This is my simple `GraphQL` web-app which has very quite and simple example of graphql user management system. Be like `Query` and `Mutation` basic operations.##### Download the repository and run the `Backend` application in your local machine:
please follow the below instructions:```bash
git clone https://github.com/mbrsagor/graphql.git
cd graphql/server
yarn install
yarn dev
```
Runs the app in the development mode.\
Open [http://localhost:4000](http://localhost:4000) to view it in the browser.##### Run the `Frontend` part:
```bash
cd client
yarn install
yarn start
```
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.###### For the `Query` response body:
```javascript
query {
users {
id
name
age
}
}
```
###### For the `Mutation` (create/post) response body:
```javascript
mutation {
createUser(id: 6, name: "Mamun-khan", email: "[email protected]", age: 29) {
id
name
age
}
}
```#### Example of GraphQL if you want to create new one backend:
> Basically if you want to setup newly I recommend you please follow the below instructions:
```bash
yarn init
yarn add --dev graphpack
```
Then add the code for you project `package.json` file.
```json
"scripts": {
"dev": "graphpack",
"build": "graphpack build"
}
```
N:B: Then continue to the following steps which possesses my project `src` directory.```bash
npm install graphql
```
Then:
```javascript
var { graphql, buildSchema } = require('graphql');var schema = buildSchema(`
type Query {
sagor: String
}
`);var root = { sagor: () => 'Hello Sagor!' };
graphql(schema, '{ sagor }', root).then((response) => {
console.log(response);
});
```> Frontend
```javascript
import {
graphql,
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
} from 'graphql';var schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
fields: {
hello: {
type: GraphQLString,
resolve() {
return 'world';
},
},
},
}),
});
```