I have seen in some tutorials and documentations that write GraphQL query or mutation like bellow.
const String _getCustomersQuery = '''
query Customers(\$name: String) {
customers(name: \$name){
id
name
address
telNo
}
}
''';
In Dart language tour we can see there is a way to use "raw" strings.
So above query can be written without string escaping like this:
const String _getCustomersQuery = r'''
query Customers($name: String) {
customers(name: $name){
id
name
address
telNo
}
}
''';
Looks nice and you can just copy and paste from GraphQL playground or any other tool that you use.
Do you like to get more tips on using GraphQL with Flutter?
Top comments (0)