juffalow / express-graphql-example Goto Github PK
View Code? Open in Web Editor NEWExample project how to use Express and GraphQL
Home Page: https://graphql.juffalow.com/graphql
License: MIT License
Example project how to use Express and GraphQL
Home Page: https://graphql.juffalow.com/graphql
License: MIT License
Allow user to add authors and quotes.
Ran the test case:
mutation {
createAuthor(author: {
name: "Kent",
last_name: "Beck"
}) {
id
}
}
Got the following error. The record actually was created in the database.
{
"errors": [
{
"message": "Cannot read property 'forEach' of undefined",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createAuthor"
]
}
],
"data": {
"createAuthor": null
}
}
How I can do delete and update data with the mutation? And why query doesnt result data but can insert to the database? Sorry for bad english
Hey, Thanks a lot for the wonderful project.
But I have some reservations, hope you could address them.
query{
authors{
name
last_name
quotes{
id
quote
}
}
}
Query like above will have performance issues, since numerous requests are made to the Database.
Example:
Executing (default): SELECT [id], [name], [last_name] FROM [author] AS [author];
Executing (default): SELECT [id], [name], [last_name] FROM [author] AS [author];
Executing (default): SELECT [id], [name], [last_name] FROM [author] AS [author];
Executing (default): SELECT [id], [name], [last_name] FROM [author] AS [author];
Executing (default): SELECT [id], [author_id], [quote] FROM [quote] AS [quote] WHERE [quote].[author_id] = 1;
Executing (default): SELECT [id], [author_id], [quote] FROM [quote] AS [quote] WHERE [quote].[author_id] = 2;
Executing (default): SELECT [id], [author_id], [quote] FROM [quote] AS [quote] WHERE [quote].[author_id] = 3;
Executing (default): SELECT [id], [author_id], [quote] FROM [quote] AS [quote] WHERE [quote].[author_id] = 4;
Executing (default): SELECT [id], [author_id], [quote] FROM [quote] AS [quote] WHERE [quote].[author_id] = 5;
Executing (default): SELECT [id], [author_id], [quote] FROM [quote] AS [quote] WHERE [quote].[author_id] = 6;
So, rather than querying DB once, n+1 requests are made.
One to retrieve all the users and n to retrieve quotes for each of the author.
Do you have any recommendations how to improve that and minimize the number of SQL round-trips?
What to change:
Tried
{
authors(filter: {name: "Bill"}) {
id
last_name
name
}
}
Got the error:
{
"errors": [
{
"message": "Invalid value { name: 'Bill' }",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"authors"
]
}
],
"data": {
"authors": null
}
}
Thanks for help with this very good example application.
Add basic auth functionality. Any user can read the data - query authors and quotes but only logged in user can add new author / use mutations.
Because of #13 now it always loads everything from the database, even if it is not requested. This can be optimized also.
Enable pagination in authors and quotes query
It should have at least some tests.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.