“REST Vs GraphQL” is it a correect comparison?

I saw in many sites that compare REST with GraphQL. after investigating this concern (actually my concern) that, “is it a correct comparison?”, I being more confused. Since the REST has a different definition against GraphQL, this question busies my mind that, why we’ll be able to compare two different concepts together.

actually, it seems to me that the comparison is something like this:

IDE Vs Compiler !??! or BMW x6 Vs ISO 18541-5 (Road vehicles)

from wiki:

Rest definition:

Representational State Transfer (REST) is a software architectural style that defines a set of constraints to be used for creating Web services.

GraphQl definition:

GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.

please brighten my mind with your answers. thanks

Drupal GraphQL query not returning data

I have 5 different content types and I’ve added content / nodes. I’m using graphQL to fetch the data, however in 1 of the content types the data is not being returned. This is the latest content type I’ve added, so I can query data from all 4 other content types and get the data I expect without any problems using fragments.

My query for the new content type is simple:

{   nodeQuery {     entities {       ...on NodeGlobalContent {         title         body {           value         }       }     }   } } 

The empty result is:

{   "data": {     "nodeQuery": {       "entities": [         {},         {},         {},         {},         {},         {},         {},         {},         {},         {}       ]     }   } } 

If I query the node by ID, I get the data:

query {   nodeById(id: "20") {     entityLabel     entityBundle   } } 
{   "data": {     "nodeById": {       "entityLabel": "test",       "entityBundle": "global_content"     }   } } 

Any idea why I can’t retrieve the data using a fragment?

View GraphQL queries in browser network developer tools [on hold]

We recently migrated our API to graphql, and it’s been working very well for us. However I did come across one inconvenience during development that I couldn’t find any information on. When using the browser developer tools to inspect network requests, all our requests which used to have specifically named endpoints like inventory?id=1234 are now just listed as graphql.

I understand why this is the case, but was hoping for a way to include some of the POST information in the list of requests. It is cumbersome to click through a dozen POSTs to try to find the one I am looking for.

It seems likely that different browsers may have different methods of approaching this. Maybe a plugin that extends the developer tools? I mention graphql since that’s the context of my question, although I suppose this problem isn’t graphql specific

In browser developer tools, is there a way to add content from each POST request to the row?

Graphql: change a related field without mutating the original one

I have this schema:

type Game {   id: ID! @id   status: Boolean @default(value: false)   time: DateTime!   location: String!   stadium: String!   teams: [Team!]! @relation(name: "BothTeams") } type Team {   id: ID! @id   name: String!   abbrName: String!   teamLogo: String!   score: Int @default(value: 0)   games: [Game!]! @relation(name: "BothTeams") } 

the Game type is gonna return typically two teams and each team is gonna have a score field.

so if i want to update a game later, specifically the score field,

i would have to change the score of every game with that changed team.

So, is there a way to change the score of a specific game, without mutating the original score.

Format data to fit GraphQL schema

I am using DynamoDB as my database. Since it’s a NoSQL database, I store data in a certain way that doesn’t fit the way I want to receive the data from GraphQL.

This is how my data is stored in the database so I can easily find them by their key.

App: {    activities: [      key: {        activityData      }    ]  } 

And this is what the data organized in my schema would look like.

App: {    activities: [     key: key,     ...activityData   ] } 

Is there a way to easily achieve this. Keep in mind that I reuse this multiple times.

GraphQl query based on a specific value of a field

I want to be able to retrieve the latest release from GitHub for a specific repo using their GraphQl API. To do that, I need to get the latest release where isDraft and isPrerelease are false. I have managed to get the first part, but cant figure out how to do the “where” part of the query.

Here is the basic query I have gotten (https://developer.github.com/v4/explorer/):

{   repository(owner: "paolosalvatori", name: "ServiceBusExplorer") {     releases(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) {       nodes {         name         tagName         resourcePath         isDraft         isPrerelease       }     }   } } 

Which returns:

{   "data": {     "repository": {       "releases": {         "nodes": [           {             "name": "3.0.4",             "tagName": "3.0.4",             "resourcePath": "/paolosalvatori/ServiceBusExplorer/releases/tag/3.0.4",             "isDraft": false,             "isPrerelease": false           }         ]       }     }   } } 

I cant seem to find a way to do this. Part of the reason is that I am new to GraphQl (first time trying to do a query) and I am not sure how to frame my question.

Can one only “query” based on those types that support arguments (like repository and releases below)? Seems like there should be a way to specify a filter on the field values.

Repository: https://developer.github.com/v4/object/repository/

Releases: https://developer.github.com/v4/object/releaseconnection/

Node: https://developer.github.com/v4/object/release/

Dados não mapeados schema graphql

Gostaria de tirar uma dúvida em relação ao GraphQL.

Possuo uma API que recebe determinados dados do usuário, por exemplo: Nome, email, endereço e etc… e além destes dados já pré definidos, é possível salvar dados adicionais, que não são definidos. Me surgiu a seguinte dúvida:

Como eu defino o tipo desses dados, pois não consegui encontrar na documentação um tipo “objeto”.

Por exemplo:

    type Query {     user: User }  type User {     id: ID!,     name: String,     email: String,     extra: Object //este seria um objeto customizado } 

Alguém sabe como posso resolver?