cancel
Showing results for 
Search instead for 
Did you mean: 

What is the difference between "Money" and "Money!" in graphql schema?

SOLVED

What is the difference between "Money" and "Money!" in graphql schema?

If we look at the vendor file in vendor/magento/module-catalog-graph-ql/etc/schema.graphqls which is defining the ProductInterface attributes.

 

Some objects had been defined as a "Money" and some are "Money!", so what is the difference?

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: What is the difference between "Money" and "Money!" in graphql schema?

Have a look at the graphql documentation: https://graphql.org/learn/schema/#object-types-and-fields

It says for the type String:

  • String is one of the built-in scalar types - these are types that resolve to a single scalar object, and can't have sub-selections in the query. We'll go over scalar types more later.
  • String! means that the field is non-nullable, meaning that the GraphQL service promises to always give you a value when you query this field. In the type language, we'll represent those with an exclamation mark.

So "Money" means that the object is nullable and "Money!" means it's not, that's it.

View solution in original post

2 REPLIES 2

Re: What is the difference between "Money" and "Money!" in graphql schema?

Have a look at the graphql documentation: https://graphql.org/learn/schema/#object-types-and-fields

It says for the type String:

  • String is one of the built-in scalar types - these are types that resolve to a single scalar object, and can't have sub-selections in the query. We'll go over scalar types more later.
  • String! means that the field is non-nullable, meaning that the GraphQL service promises to always give you a value when you query this field. In the type language, we'll represent those with an exclamation mark.

So "Money" means that the object is nullable and "Money!" means it's not, that's it.

Re: What is the difference between "Money" and "Money!" in graphql schema?

I am glad I have found the solution. I also want to know this.