<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: TrackMyStories</title>
    <description>The latest articles on DEV Community by TrackMyStories (@trackmystories).</description>
    <link>https://dev.to/trackmystories</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F113482%2F89ef09f6-0f97-44a0-be20-be5304433e2c.png</url>
      <title>DEV Community: TrackMyStories</title>
      <link>https://dev.to/trackmystories</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/trackmystories"/>
    <language>en</language>
    <item>
      <title>How to GeoJSON with Apollo GraphQL Server</title>
      <dc:creator>TrackMyStories</dc:creator>
      <pubDate>Tue, 20 Apr 2021 14:51:37 +0000</pubDate>
      <link>https://dev.to/trackmystories/how-to-geojson-with-apollo-graphql-server-27ij</link>
      <guid>https://dev.to/trackmystories/how-to-geojson-with-apollo-graphql-server-27ij</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwvng5w284koxl18a6w88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwvng5w284koxl18a6w88.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article explains in a few simple steps how to work with GeoJSON using an Apollo GraphQL server, The primary focus is to understand the fetching of numeric properties within an array.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;coordinates : [55.708, -21.244]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;For this example I have utilised &lt;a href="https://eonet.sci.gsfc.nasa.gov/" rel="noopener noreferrer"&gt;NASA API's : The Earth Observatory Natural Event Tracker (EONET)&lt;/a&gt;, which is a repository of metadata about natural events.&lt;/p&gt;

&lt;p&gt;In addition you can find the example &lt;a href="https://github.com/trackmystories/NASA-EONET-GRAPHQL-SERVER" rel="noopener noreferrer"&gt;linked here on github here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In order to work with GeoJSON using Apollo's graphQL server we have to make use of custom scalars, because the servers backend needs to know how to interact with a data structure which includes an array example as such "[55.708, -21.244]."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ npm install graphql-type-json&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The following dependency defines a custom scalar object. The GraphQLJSON object is an instance of the GraphQLScalarType which can be used to define the custom scalar JSON , this will allow our server to validate our coordinates e.g. "[55.708, -21.244]."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the schema.js file define the custom scalar type and link it to the coordinates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {gql} = require('apollo-server');
const typeDefs = gql`
  scalar JSON  // custom scalar
type Event {
    id: ID!
    cursor: ID!
    title: String
    description: String
    link: String
    closed: String
    categories: [Categories]
    sources: [Sources]
    geometry: [Geometry]
  }
type Categories {
    id: ID!
    title: String
  }
type Sources {
    id: String
    url: String
  }
type Geometry {
    magnitudeValue: String
    magnitudeUnit: String
    date: String
    type: String
    coordinates: [JSON] // coordinates 
  }
type Query {
    events: [Event!]!
  }
`;
module.exports = typeDefs;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the index.js file import GraphQLJSON and add to the server constructor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {ApolloServer} = require('apollo-server');
const typeDefs = require('./src/schema');
const resolvers = require('./src/resolvers');
const EventsAPI = require('./src/datasources/events');
const GraphQLJSON = require('graphql-type-json');
const server = new ApolloServer({
  typeDefs,
  resolvers,
  JSON: GraphQLJSON,
  dataSources: () =&amp;gt; ({
    eventsAPI: new EventsAPI(),
  }),
});
server.listen().then(({url}) =&amp;gt; {
  console.log(`🚀 Server ready at ${url}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example uses apollo-datasource-rest and passes the api to the resolvers:&lt;/p&gt;

&lt;p&gt;events.js creates and exports = EventsAPI;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {RESTDataSource} = require('apollo-datasource-rest');
class EventsAPI extends RESTDataSource {
  constructor() {
    super();
    this.baseURL = 'https://eonet.sci.gsfc.nasa.gov/api/v3/';
  }
async queryAllEvents() {
    const response = await this.get('events');
    return response.events;
  }
async getAllEvents() {
    const response = await this.queryAllEvents();
    return Array.isArray(response)
      ? response.map(item =&amp;gt; this.eventReducer(item))
      : [];
  }
eventReducer(item) {
    return {
      id: item.id,
      title: item.title,
      description: item.description,
      link: item.link,
      closed: item.closed,
      categories: item.categories.map(i =&amp;gt; ({
        id: i.id,
        title: i.title,
      })),
      sources: item.sources.map(i =&amp;gt; ({
        id: i.id,
        url: i.url,
      })),
      geometry: item.geometry.map(i =&amp;gt; ({
        magnitudeValue: i.magnitudeValue,
        magnitudeUnit: i.magnitudeUnit,
        date: i.date,
        type: i.type,
        coordinates: i.coordinates,
      })),
    };
  }
}
module.exports = EventsAPI;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and is passed to the resolvers like such:&lt;/p&gt;

&lt;p&gt;resolvers.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  Query: {
    events: (_, __, {dataSources}) =&amp;gt; dataSources.eventsAPI.getAllEvents(),
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run the following query in the graphQL playground:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Write your query or mutation here

query Query {
 events {
      geometry {
        date
        type
        coordinates
      }
    }  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq6ulde1rzohuqp6jb5xi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq6ulde1rzohuqp6jb5xi.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the output will be as such.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To conclude:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can find the code for &lt;a href="https://github.com/trackmystories/NASA-EONET-GRAPHQL-SERVER" rel="noopener noreferrer"&gt;this example here on github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To get a deeper understanding, please refer to the &lt;a href="https://www.apollographql.com/docs/apollo-server/schema/custom-scalars/" rel="noopener noreferrer"&gt;Apollo federation documentation on custom scalars here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>graphql</category>
    </item>
    <item>
      <title>React Native Android : FAILURE: Build failed with an exception. MAC OS</title>
      <dc:creator>TrackMyStories</dc:creator>
      <pubDate>Mon, 19 Apr 2021 16:29:01 +0000</pubDate>
      <link>https://dev.to/trackmystories/react-native-android-failure-build-failed-with-an-exception-mac-os-koc</link>
      <guid>https://dev.to/trackmystories/react-native-android-failure-build-failed-with-an-exception-mac-os-koc</guid>
      <description>&lt;p&gt;This is an issue with how Gradle is automating the build and the current version of the JDK installed on your machine, follow these steps to fix it, the react native documentation states you need adoptopenjdk8, however you may have other conflicting JDK versions in the same directory.&lt;/p&gt;

&lt;p&gt;Firstly: Recreate this error&lt;/p&gt;

&lt;p&gt;In order to recreate this Error install a newer version of JAVA Development Kit for example JDK 16, or more than one JDK's on your mac.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.oracle.com/java/technologies/javase-jdk16-downloads.html" rel="noopener noreferrer"&gt;https://www.oracle.com/java/technologies/javase-jdk16-downloads.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you run npx react-native run-android, You'll get the following build fail:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw2r6ejyi8jmq9qi0oe3e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw2r6ejyi8jmq9qi0oe3e.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your build may be failing because :&lt;/p&gt;

&lt;p&gt;• More than one JDK's are installed.&lt;/p&gt;

&lt;p&gt;• Incompatible JDK is installed.&lt;/p&gt;

&lt;p&gt;• Or no JDK is installed.&lt;/p&gt;

&lt;p&gt;This is an issue with how Gradle is automating the build and the current version of the JDK installed on your machine, the react native documentation states we need adoptopenjdk8, however you may have other conflicting JDK versions in the same directory.&lt;/p&gt;

&lt;p&gt;So to fix this issue follow these steps:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Step One:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open up your terminal and navigate to /Library/Java/JavaVirtualMachines by typing the following command:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd /Library/Java/JavaVirtualMachines&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;after you have done that type "ls" to see what files are included and take note of the versions, incase you have one or multiple JDK files present like such:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsj37pahlktcupytqpdrg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsj37pahlktcupytqpdrg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;delete them with the following command line :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgslu4lhnsdqvn3vhvs2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgslu4lhnsdqvn3vhvs2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;the only dependency you need is adoptopenjdk-8.jdk as mentioned in the react native docs.&lt;/p&gt;

&lt;p&gt;however delete that as-well and reinstall it after you have completed these steps.&lt;/p&gt;

&lt;p&gt;After you have done so you can check if the files still exist by typing "ls" if the files are deleted.&lt;/p&gt;

&lt;p&gt;Then run the following commands to insure all other links, plugins and files are deleted as-well from your Library:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwe09yyk9sg9dic7pgl3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwe09yyk9sg9dic7pgl3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step Two:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once all JDK's have been removed reinstall the correct JDK as mention in the react-native documentations.&lt;/p&gt;

&lt;p&gt;Open up a new terminal&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactnative.dev/docs/_getting-started-macos-android" rel="noopener noreferrer"&gt;https://reactnative.dev/docs/_getting-started-macos-android&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fsdb9gnbz5oc3bnc54u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fsdb9gnbz5oc3bnc54u.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This may say adoptopenjdk-8.jdk is already installed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj7ak5ak98d72l5uiwt11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj7ak5ak98d72l5uiwt11.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;regardless, go ahead and reinstall it with:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fut753wc8dn7xll5r7bao.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fut753wc8dn7xll5r7bao.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once installation is complete, you should see the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbaolloni0zi7cjbxq8ds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbaolloni0zi7cjbxq8ds.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point the error should be resolved and your build should work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;To Conclude&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is important to note that this is a build error, since react native uses Gradle to build automations, the conflicting of multiple jdk versions can cause your build to fail.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgfavp48cxgqg7dkw0dvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgfavp48cxgqg7dkw0dvi.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;please refer to the following documentation to get a better understanding on Gradle compilation.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://docs.gradle.org/current/userguide/userguide.html" rel="noopener noreferrer"&gt;https://docs.gradle.org/current/userguide/userguide.html&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>adoptopenjdk8</category>
    </item>
    <item>
      <title>Array.isArray(response) returns null ? Apollo GraphQL</title>
      <dc:creator>TrackMyStories</dc:creator>
      <pubDate>Sat, 20 Feb 2021 20:20:03 +0000</pubDate>
      <link>https://dev.to/trackmystories/array-isarray-response-returns-null-apollo-graphql-26gh</link>
      <guid>https://dev.to/trackmystories/array-isarray-response-returns-null-apollo-graphql-26gh</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mtoE7b62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6e66w2oqnxxg6cjgjh9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mtoE7b62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6e66w2oqnxxg6cjgjh9.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hi There!, (If you are challenged with the above function in graphQl’s documentation with your own data structure this article will give some clarity).&lt;/p&gt;

&lt;p&gt;I can only imagine how mind bending it can be to include a boolean value in another boolean value in-order to handle a simple nested Array whose initial value is not an Array. Therefor this article will give clarity to any developer challenged by the dataSources part of Apollo GraphQL documentations.&lt;/p&gt;

&lt;p&gt;disclaimer:&lt;/p&gt;

&lt;p&gt;It expresses my opinion on where Apollo GraphQL went wrong in CONTEXT OF A TUTORIAL and why and how to better understand it.&lt;/p&gt;

&lt;p&gt;Array.isArray(response) ? true : or false : ‘apollo-datasource-rest’.&lt;/p&gt;

&lt;p&gt;I’ve been trying to do things by the book the way Apollo states in its docs. when working with ‘apollo-datasource-rest’, there are some aspects of their code that I feel is not helpful and even counter-productive in context of a tutorial.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async getAllLaunches() {
const response = await this.get(‘launches’);
return Array.isArray(response)
? response.map(launch =&amp;gt; this.launchReducer(launch))
: [];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Speaking for myself, What has been my pain points in the grander understanding of things with relation to this function:&lt;/p&gt;

&lt;p&gt;• is the use of brackets : [] as a boolean value, to use brackets in this context, seems to be more aesthetic in terms of how it looks on source code in relevance to data fetching, rather than an informative debugger when an error is thrown.&lt;/p&gt;

&lt;p&gt;• In fact the entire statement’s target which is either true or false does not return the reason as to why an error may occur when the value is false for example : a nested array fetch error may say: “response.map(item =&amp;gt; is not a function”. However the current referenced function will log an empty array “ :[ ]” or if you change the value of the bracket to “false” it simply returns null when an error occurs, this can be misleading because the real reason for the error is missing. As a developer reading this code in context to data fetching and seeing an empty “: [ ]” can mean a host of speculations.&lt;/p&gt;

&lt;p&gt;In this respect Array.isArray(response) ? true : or false can be cumbersome when the data endpoint is not an array for example “ “a” : [ ];” .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“a”: [
0: {},
1: {},
]//the end point to this is not array.as oppose to[
0: {},
1: {},
]//the end point to this is an array.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Array.isArray simply checks if the value is an array or not, if it is it returns true if it isn’t it returns false.&lt;/p&gt;

&lt;p&gt;so the function above returns the query if it is true however if it is false simple returns and ambiguous “:[ ]” empty array.&lt;/p&gt;

&lt;p&gt;so if the empty array value is logged instead of an error how do you know what the root of the problem is?&lt;/p&gt;

&lt;p&gt;In order to debug the following, I had to explicitly pass the same target value in both of the boolean fixes, true : false statements as such:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return Array.isArray(response)
? response.map(launch =&amp;gt; this.launchReducer(launch))
: response.map(launch =&amp;gt; this.launchReducer(launch));// Which returns the reason of the error:// “response.map(item =&amp;gt; is not a function” is the error message.// as oppose to an empty array “: [];”.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to solve this problem I simply modified the above code to deal with my data structure by prefixing a boolean operator to Array.isArray, changing it to !Array.isArray in order to retrieve data the nested Array:&lt;/p&gt;

&lt;p&gt;the logic behind the prefix is simple the “a : [ ];” is not an array return true and render the data please.&lt;/p&gt;

&lt;p&gt;the updated function looks like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async getAllLaunches() {
const response = await this.get(‘launches’);
return !Array.isArray(response)
? response.a.map(launch =&amp;gt; this.launchReducer(launch))
: [];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It seems that Array.isArray(true or false) can be overtly complex especially when a fetch call of this nature is made because of the definition of 2 boolean operators inside of the statement. Therefore having an error message which returns an empty array “: [];” or a false; statement can be difficult to debug when the reasoning is not logged.&lt;/p&gt;

</description>
      <category>graphql</category>
    </item>
    <item>
      <title>React Native: Simple responsive Images for all screen sizes with flex.</title>
      <dc:creator>TrackMyStories</dc:creator>
      <pubDate>Sat, 20 Feb 2021 20:13:17 +0000</pubDate>
      <link>https://dev.to/trackmystories/react-native-simple-responsive-images-for-all-screen-sizes-with-flex-2860</link>
      <guid>https://dev.to/trackmystories/react-native-simple-responsive-images-for-all-screen-sizes-with-flex-2860</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqcuvgu4lmihleqt4xc0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqcuvgu4lmihleqt4xc0d.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Smartphones come in different shapes and sizes, therefore it is paramount our content responds accordingly.&lt;/p&gt;

&lt;p&gt;Images can be problematic when delivering our design across different screens. A one size fits all strategy would not work in today's diverse smartphone landscape and would likely result in a user experience nightmare.&lt;/p&gt;

&lt;p&gt;The Flexbox module is based on the Cartesian coordinate system, which is distances over two lines running perpendicular, famously known as the&lt;br&gt;
X-axis and Y-axis, with the Cartesian system in mind our container can be calculated with the main axis which runs horizontal, and the cross-axis which runs vertically as illustrated in the image above.&lt;/p&gt;

&lt;p&gt;Consider your container as the X-Axis and Y-Axis that holds the Image.&lt;/p&gt;

&lt;p&gt;Consider your container as the X-Axis and Y-Axis that holds the Image.&lt;/p&gt;

&lt;p&gt;for example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;View style={styles.container}&amp;gt; // X &amp;amp; Y axis.
&amp;lt;Image /&amp;gt; // value or items{% raw %}`
&amp;lt;/View&amp;gt;
```

The container value has a height and width as per your requirements.

for example:


```
container : {width: 180, height: 200}
```


In order to ensure images inside the container adapt to change, we can use percentages to ensure the size is always on par with the height and width of the container.

Therefore, to make the images responsive we can simply set the value of height and width to 100% and resize mode to cover.

```
&amp;lt;View style={{
    width: 180,
    height: 200,
    aspectRatio: 1 * 1.4,

    }}&amp;gt;
    &amp;lt;Image
    source={{uri : item.image.url}}

    style={{

    resizeMode: ‘cover’,
    width: ‘100%’,
    height: ‘100%’

    }}
    /&amp;gt;
&amp;lt;/View&amp;gt;
```


By setting the Image’s height and width to 100% and resize mode to cover, the image will proportionately occupy a 100% of the container's real estate inside of the X and Y-Axis or the container. It will uniformly scale the image whilst maintaining it’s aspect ratio proportionate to the dimensions of the container.

To conclude, the application of geometry can be an effective resource in scalability. The simple notion of a box and the compatibility of its contents is a good way to think about how responsiveness works in our applications. It is important to note that the container’s style has precedence over the image’s style similar to a waterfall effect, that is how the container’s value dictates how high or wide the image can stretch in the UI.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>reactnative</category>
    </item>
    <item>
      <title>Javascript: The four rules of {this}.</title>
      <dc:creator>TrackMyStories</dc:creator>
      <pubDate>Sat, 20 Feb 2021 19:54:37 +0000</pubDate>
      <link>https://dev.to/trackmystories/javascript-the-four-rules-of-this-42g0</link>
      <guid>https://dev.to/trackmystories/javascript-the-four-rules-of-this-42g0</guid>
      <description>&lt;p&gt;&lt;em&gt;Firstly, this article is written with reference to a chapter from Kyle Simpson's great book You Don't Know JS: this &amp;amp; Object Prototypes. It is an incredible resource for anyone looking to build a deeper understanding of Javascript.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;What rules determine the order of precedence where this points to when a function is executed?&lt;/p&gt;

&lt;p&gt;There are four rules that determine the order of precedence on where this points to during function execution:&lt;/p&gt;

&lt;p&gt;• Default Binding&lt;br&gt;
• Implicit Binding&lt;br&gt;
• Explicit Binding&lt;br&gt;
• Hard Binding&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Default Binding :&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function js(){&lt;br&gt;
 console.log(this.binding);&lt;br&gt;
}&lt;br&gt;
var binding = 'default binding';&lt;br&gt;
js(); // default binding&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Breaking down our snippet above and understanding how our call-site determines where this points to when function js(){...} is executed, firstly, function js(){…} is our call-stack which holds console.log(this.binding); and the call-site for our function is js(); which is located on the last line of the snippet which is the point from which the function is called. furthermore, our variable var binding = 'default binding'; is declared in the global scope.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Implicit Binding:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function properties(){&lt;br&gt;
 console.log(this.binding);&lt;br&gt;
}&lt;br&gt;
var object = {&lt;br&gt;
 binding: 'implicit binding',&lt;br&gt;
 properties: properties&lt;br&gt;
};&lt;br&gt;
object.properties(); // implicit binding&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;If you've worked with apollo resolvers or the react context API this second rule will give some deeper clarity on how they work through javascript.&lt;/p&gt;

&lt;p&gt;breaking down the above snippet, our call-stack is &lt;code&gt;function properties(){...}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;which holds our this.binding binding, our call-site is object.properties();.&lt;/p&gt;

&lt;p&gt;however, what differentiates this rule to the default binding is in the manner in which our call-site is declared.&lt;br&gt;
The implicit rule can be determined if our call-site has a context object, &lt;code&gt;function properties(){...};&lt;/code&gt; is declared in the same fashion as our default binding from our first example, however, our call-site references object when calling a function, object.properties();.&lt;/p&gt;

&lt;p&gt;At the point at which &lt;code&gt;properties();&lt;/code&gt; is called it is prefixed with &lt;code&gt;var object = {...}&lt;/code&gt;, which contains the value on execution.&lt;/p&gt;

&lt;p&gt;reference: As Kyle Simpson states in his book You Don't Know JS: this &amp;amp; Object Prototypes :&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"When there is a context object for a function reference, the implicit binding rule says that it's object which should be used for the function call's this binding."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"With implicit binding as we just saw, we had to mutate the object in question to include a reference on itself to the function, and use this property function reference to &lt;code&gt;indirectly(implicitly)&lt;/code&gt; bind this to the object."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Explicit Binding:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function properties(){&lt;br&gt;
 console.log(this.binding);&lt;br&gt;
}&lt;br&gt;
var object = {&lt;br&gt;
 binding : 'explicit binding'&lt;br&gt;
};&lt;br&gt;
properties.call(object); //explicit binding&lt;br&gt;
or&lt;br&gt;
properties.apply(object); //explicit binding&lt;br&gt;
// call or apply produce the same result.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Instead of including an implicit function reference inside &lt;code&gt;var object = {...}&lt;/code&gt; and prefixing it to the call-site, we can explicitly call the function with a built-in utility &lt;code&gt;call()&lt;/code&gt; and &lt;code&gt;apply()&lt;/code&gt;, the function &lt;code&gt;properties(){...}&lt;/code&gt; is the call-stack, however, our call-site uses the built-in utility to execute the function explicitly. It is important to note that &lt;code&gt;call()&lt;/code&gt; and &lt;code&gt;apply()&lt;/code&gt; result in the same outcome unless additional parameters are passed to them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Hard Binding:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function properties(){&lt;br&gt;
 console.log(this.binding);&lt;br&gt;
}&lt;br&gt;
var object = {&lt;br&gt;
 binding: 'hard binding'&lt;br&gt;
};&lt;br&gt;
var hardBindedPropertiesToObject = function(){&lt;br&gt;
 properties.call(object);&lt;br&gt;
}&lt;br&gt;
hardBindedPropertiesToObject(); // hard binding&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;With respect to the hard binding snippet above, we create a function &lt;code&gt;var hardBindedPropertiesToObject= function(){//call(object)}&lt;/code&gt; which calls the call-stack with &lt;code&gt;var object = {...}&lt;/code&gt; which points towards this.&lt;/p&gt;

&lt;p&gt;reference: As Kyle Simpson states in his book You Don't Know JS: this &amp;amp; Object Prototypes :&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"This binding is both explicit and strong, so we call it hard binding."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Another thing to note is that the hard binding pattern has its own built-in utility &lt;code&gt;Function.prototype.bind()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;consider:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const module = {&lt;br&gt;
 x: 42,&lt;br&gt;
 getX: function() {&lt;br&gt;
 return this.x;&lt;br&gt;
 }&lt;br&gt;
};&lt;br&gt;
const unboundGetX = module.getX;&lt;br&gt;
console.log(unboundGetX()); // The function gets invoked at the global scope&lt;br&gt;
// expected output: undefined&lt;br&gt;
const boundGetX = unboundGetX.bind(module);&lt;br&gt;
console.log(boundGetX());&lt;br&gt;
// expected output: 42&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind"&gt;source MDN developer.mozilla.org states:&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To conclude, here are the 4 rules of this , I would highly recommend reading the you dont know js book series by Kyle Simpson. &lt;a href="https://github.com/trackmystories/You-Dont-Know-JS"&gt;His books&lt;/a&gt; cover all the aspects of javascript that can enable any developer to gain proficiency in the language.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>“HTTP Error: 400, Default service account: appspot.gserviceaccount.com (Email’s from Google’s support team included)</title>
      <dc:creator>TrackMyStories</dc:creator>
      <pubDate>Sat, 20 Feb 2021 19:36:20 +0000</pubDate>
      <link>https://dev.to/trackmystories/http-error-400-default-service-account-appspot-gserviceaccount-com-email-s-from-google-s-support-team-included-3280</link>
      <guid>https://dev.to/trackmystories/http-error-400-default-service-account-appspot-gserviceaccount-com-email-s-from-google-s-support-team-included-3280</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CiyW_P1v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mutm4xowplw6d5xzsiye.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CiyW_P1v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mutm4xowplw6d5xzsiye.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Header When deploying firebase cloud functions are you getting the following error?
&lt;/h6&gt;

&lt;p&gt;&lt;em&gt;"HTTP Error: 400, Default service account&lt;code&gt;'&amp;lt;project_id&amp;gt;@appspot.gserviceaccount.com'&lt;/code&gt; doesn't exist. Please recreate this account (for example by disabling and enabling the Cloud Functions API), or specify a different account."&lt;/em&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Header Or are you unable to see the functions on your dashboard after deployment?
&lt;/h6&gt;

&lt;p&gt;Here is a more simplified response: &lt;a href="https://stackoverflow.com/questions/54912513/error-on-google-function-deploy-service-account-doesnt-exist/63283785#63283785"&gt;Stack Overflow&lt;/a&gt; &lt;br&gt;
This article should offer some clarity.&lt;/p&gt;

&lt;p&gt;I was recently struggling with this issue and eventually solved it after raising the matter with Google's support teams (Google's response below).&lt;/p&gt;

&lt;p&gt;My apollo express graphql server was working fine locally but whenever I tried to deploy it using firebase cloud functions it would print an error.&lt;/p&gt;

&lt;p&gt;So here are my learnings and how this issue was ultimately resolved.&lt;/p&gt;
&lt;h6&gt;
  
  
  Header How to debug this error
&lt;/h6&gt;

&lt;p&gt;• Navigate to your google cloud console permissions page and search through the list for @appspot.gserviceaccount.com it should look like this image below 👇🏼.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_C6fmu4q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8qcoz9wlc34n5djmi8p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_C6fmu4q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8qcoz9wlc34n5djmi8p.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is important to note that @appspot.gserviceaccount.com is the App Engine default service account. It acts as a security feature &lt;em&gt;" intended to represent a non-human user that needs to authenticate and be authorized to access data in Google APIs."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To get an idea of where things are going wrong, use this command line.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;firebase deploy - -only functions - -debug&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;If '@appspot.gserviceaccount.com' is missing, then you won't be able to deploy anything(SEE EMAILS WITH GOOGLE BELOW), if it isn't, check and see if it's enabled, try disabling it and enabling it again.&lt;/p&gt;

&lt;p&gt;@appspot.gserviceaccount.com is pre-installed by default, regardless of a paid account or not. Try and recall if at any time you may have deleted it after or before deployment.&lt;br&gt;
Now if for any reason you deleted the service account over a period of more than 30 days than you can not retrieve it, and you must create a new firebase project. However, if it is within 30 days you can undelete it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Here is my conversation with Google's support team, they were extremely helpful.&lt;/code&gt;&lt;/p&gt;
&lt;h6&gt;
  
  
  Header RESPONSE FROM GOOGLE'S Support team Email #1:
&lt;/h6&gt;

&lt;p&gt;&lt;em&gt;"Hello Ali&lt;br&gt;
I am checking the logs of your project, unfortunately the service account was deleted on May, there is no chance to recover it nor recreate it&lt;br&gt;
The only workaround available is to create a new project and deploy the service desired there. I know this could not be the best option for you nevertheless it is the way this works by design.&lt;br&gt;
Do not hesitate to write back if you have more questions.&lt;br&gt;
Cheers,"&lt;/em&gt;&lt;/p&gt;
&lt;h6&gt;
  
  
  Header RESPONSE FROM GOOGLE'S Support team Email #2:
&lt;/h6&gt;

&lt;p&gt;&lt;em&gt;"Hello Ali&lt;br&gt;
I am glad to read that you have been able to deploy your functions successfully, unfortunately that service account cannot be recovered after 30 days of being deleted and that is the only solution. If you have other questions, please let us know by contacting us again through our support channel.&lt;br&gt;
Cheers,"&lt;/em&gt;&lt;/p&gt;
&lt;h6&gt;
  
  
  Header lastly, the command line:
&lt;/h6&gt;



&lt;p&gt;&lt;code&gt;firebase deploy - -only functions - -debug&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Is helpful, Although it won't help if there is no service account linked to the App Engine, it'll just highlight the obvious:&lt;/p&gt;

&lt;p&gt;This was the error that was only resolvable by creating a new project.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"HTTP Error: 400, Default service account '@appspot.gserviceaccount.com' doesn't exist. Please recreate this account (for example by disabling and enabling the Cloud Functions API), or specify a different account."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I hope this helps.&lt;/p&gt;

</description>
      <category>firebase</category>
    </item>
  </channel>
</rss>
