<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by taeseong park on Medium]]></title>
        <description><![CDATA[Stories by taeseong park on Medium]]></description>
        <link>https://medium.com/@parkopp?source=rss-4ffa7246a983------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*buztbCpBRoWaXkq8e2wGtw.jpeg</url>
            <title>Stories by taeseong park on Medium</title>
            <link>https://medium.com/@parkopp?source=rss-4ffa7246a983------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 23:18:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@parkopp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mac 유저를 위한 PostgreSQL 설치 및 유저,데이터베이스 설정하기]]></title>
            <link>https://medium.com/@parkopp/mac-%EC%9C%A0%EC%A0%80%EB%A5%BC-%EC%9C%84%ED%95%9C-postgresql-%EC%84%A4%EC%B9%98-%EB%B0%8F-%EC%9C%A0%EC%A0%80-%EB%8D%B0%EC%9D%B4%ED%84%B0%EB%B2%A0%EC%9D%B4%EC%8A%A4-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0-67f5b6e6753d?source=rss-4ffa7246a983------2</link>
            <guid isPermaLink="false">https://medium.com/p/67f5b6e6753d</guid>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[taeseong park]]></dc:creator>
            <pubDate>Sun, 12 Jul 2020 16:34:08 GMT</pubDate>
            <atom:updated>2024-06-21T11:37:25.385Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*bj_f-UHk116gmxHE5KU6VA.png" /></figure><p>내가 PostgresSQL을 나의 맥북에 처음 세팅을 하게 되면서 겪었던 경험들을 여기에 공유 해 보려고 한다. 나같은 입문자들에게 도움이 되었으면..ㅎ</p><h3>EDB를 통한 설치 및 삭제</h3><p>PostgreSQL을 <a href="https://www.enterprisedb.com/downloads/postgres-postgresql-downloads">EDB 페이지</a>를 통해 Installer를 다운받고 설치를 했었다.</p><p>설치 후 postgre(psql) command도 유효하지 않았고, <strong><em>/Library/PostgreSQL/12/bin</em></strong> 경로에 있길래 거기에 직접 들어가서 접속 시도를 해 보았다.</p><p>그런데 로그인을 하려는데 자꾸 비밀번호가 안 맞는지 접속이 안 되었다.. 내가 패키지로 설치할 때 설정한 비밀번호로 분명 입력했는데…</p><pre><strong>/Library/PostgreSQL/12/bin$</strong> ./psql -U postgre</pre><pre>Password for user postgre: <br>psql: error: could not connect to server: FATAL:  password authentication failed for user &quot;postgre&quot;</pre><p>그래서 EDB로 설치한 PostgreSQL을 지우기로 했다. 아래 글이 많은 도움이 되었다.</p><p><a href="https://stackoverflow.com/a/51611627/8026431">stackoverflow.com: PosgreSQL 완벽히 지우는 방법</a></p><h3>brew를 통한 설치 및 세팅</h3><h4>설치</h4><pre>$ brew install postgresql</pre><h4>서비스 시작</h4><pre>$ brew services start postgresql</pre><p><a href="https://www.codementor.io/@engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb">이 포스팅</a> 에서는, 컴퓨터 재부팅 때마다 서비스를 켜 주는 커맨드가 소개되고 있는데,</p><pre>$ pg_ctl -D /usr/local/var/postgres start &amp;&amp; brew services start postgresql</pre><p>이 커맨드를 안 실행하고 한번 재부팅 해 보았는데 postgres 서비스가 잘 살아있는 것 같다.</p><h3>psql 접속 및 데이터베이스 생성</h3><pre>$ psql postgres<br>postgres=# CREATE DATABASE &lt;databaseName&gt;;</pre><h3>사용자 생성</h3><blockquote><em>Postgres doesn’t actually directly manage users or groups, like most standard permission models do. Instead, it directly manages what it calls roles. (</em><a href="https://www.codementor.io/@engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb"><em>reference 문서</em></a><em>)</em></blockquote><p>Role을 새로 생성하고, 거기에 권한을 부여하는 방식으로 진행한다.</p><ul><li><a href="https://www.postgresql.org/docs/12/sql-createrole.html">PostgreSQL Documentation: Create Role</a></li></ul><pre>postgres=# CREATE ROLE test WITH LOGIN PASSWORD &#39;test!&#39;;<br>CREATE ROLE</pre><h4><strong>현존하는 Role 확인하기</strong></h4><p>SELECT rolname FROM pg_roles;</p><h4><strong>권한 부여하기</strong></h4><pre>postgres=# ALTER ROLE test CREATEDB;</pre><h4><strong>지원되는 다른 option모음</strong></h4><ul><li>SUPERUSER | NOSUPERUSER | CREATEDB | NOCREATEDB | CREATEROLE | NOCREATEROLE | INHERIT | NOINHERIT | LOGIN | NOLOGIN | REPLICATION | NOREPLICATION | BYPASSRLS | NOBYPASSRLS, …</li></ul><h3>사용자 권한 확인하기</h3><h4>사용자 리스트 보기</h4><pre>$ psql postgres<br>postgres=# \du<br>                                   List of roles<br> Role name |                         Attributes                         | Member of <br>-----------+------------------------------------------------------------+-----------<br> geoseong  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}<br> test      | Create DB                                                  | {}</pre><h4>추가한 사용자로 접속하기</h4><pre>$ psql postgres -U test<br>psql (12.3)<br>Type &quot;help&quot; for help.</pre><pre>postgres=&gt;</pre><ul><li>보면 postgres=# 가 아니라 postgres=&gt; 로 바뀐 것을 확인 할 수 있다.</li><li># 는 superuser 라는 뜻이고, &gt; 는 superuser가 아니라는 것이다</li></ul><h3>데이터베이스 추가하기</h3><pre>postgres=&gt; CREATE DATABASE test;<br>CREATE DATABASE</pre><h4>특정 유저에게 DB의 모든 권한 부여하기</h4><ul><li><a href="https://www.postgresql.org/docs/12/sql-grant.html">PostgreSQL Documentation: GRANT</a></li></ul><p><strong>부여 가능한 권한 모음</strong></p><ul><li>SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER | CREATE | CONNECT | TEMPORARY | EXECUTE | USAGE</li><li>ALL PRIVILEGES: 위에 열거된 모든 권한 포함</li></ul><blockquote><em>GRANT ALL PRIVILEGES ON DATABASE [database] TO [role(user)];</em></blockquote><pre>postgres=&gt; GRANT ALL PRIVILEGES ON DATABASE test TO test;<br>GRANT<br>postgres=&gt; \connect test<br>You are now connected to database &quot;test&quot; as user &quot;test&quot;.</pre><h3>데이터베이스 관련 리스트 보는 커맨드</h3><h4>데이터베이스 리스트 보기</h4><pre>postgres=&gt; \list</pre><h4>테이블 리스트 보기</h4><pre>postgres=&gt; \dt</pre><h4>특정 database로 연결하기</h4><pre>postgres=&gt; \connect test &lt;- &#39;test&#39; DB로 연결</pre><h3>스키마<strong> </strong>생성</h3><p>MySQL을 사용하던 내 입장에서는 보통 Database 안에 Table을 곧바로 만드는 개념이 익숙한데, PostgreSQL에서는 Database -&gt; Schema -&gt; Table 개념이어서 생소했다.</p><pre>$ psql postgres -U test</pre><pre>postgres=&gt; <strong>\connect test</strong><br>You are now connected to database &quot;test&quot; as user &quot;test&quot;.</pre><pre>test=&gt; CREATE SCHEMA test;<br>CREATE SCHEMA</pre><p>주의점은 권한이 있는 database로 connect를 하고 스키마를 만들어야 한다. 그렇지 않으면 <strong>Permission denied</strong>를 내뱉을 것이다.</p><h4>스키마 목록 확인 커맨드</h4><p><strong>\dn</strong></p><pre>test=&gt; <strong>\dn</strong></pre><pre>List of schemas</pre><pre>Name  |  Owner<br>--------+----------<br>public | [superuser]<br>test   | test<br>(2 rows)</pre><p>끝.. 내용 보강되었으면 하는 점이나 고칠 것 댓글로 의견 남겨 주신다면 환영합니다 ㅎ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67f5b6e6753d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Amplify API Library로 외부 graphql API 호출 해 보기]]></title>
            <link>https://medium.com/@parkopp/amplify-api-library%EB%A1%9C-%EC%99%B8%EB%B6%80-graphql-api-%ED%98%B8%EC%B6%9C-%ED%95%B4-%EB%B3%B4%EA%B8%B0-8ca5930d511f?source=rss-4ffa7246a983------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ca5930d511f</guid>
            <category><![CDATA[github-api]]></category>
            <category><![CDATA[github-graphql]]></category>
            <category><![CDATA[amplify]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[taeseong park]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 17:48:54 GMT</pubDate>
            <atom:updated>2020-06-17T07:05:53.929Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*I17IgX7E2veMMX1GAukeig.png" /><figcaption>AWS Amplify calls GraphQL API v4</figcaption></figure><p>스타트업에서 일하는 개발 잡부(ㅋ)로써 백엔드와 프론트엔드 중 어느 하나에 집중하기 힘든 현실에 자주 마주하게 된다.</p><p>AWS를 써서 백엔드를 구축하려고 할 때 가장 먼저 간단하고 어렵지 않게 접할 수 있었던 것이 <a href="https://www.serverless.com/"><strong>serverless framework</strong></a>였고,</p><p>프론트엔드에서 회원관리 모듈과 AWS-SDK를 사용하는 점에 있어서 구현하기 귀찮은 감정을 느꼈을 때 눈에 들어온 것이 <a href="https://docs.amplify.aws/cli"><strong>Amplify CLI</strong></a>와 <a href="https://docs.amplify.aws/lib/q/platform/js"><strong>Amplify Framework</strong></a> 이다.</p><p>최근에 Amplify의 문서가 이전보단 산뜻(?)하게 새단장을 하면서 가독성이 조금 좋아졌고, 어렵지 않게 따라 할 수 있었던 Amplify로 외부 graphql API 통신을 하는 방법을 기록해 보려 한다.</p><p>사실 다른 개발자가 구현해 놓으신 graphql API 시도 시 잘 되지 않아 내가 잘못 구현하고 있나? 해서 github explorer의 graphql API를 통신해 보려 시도 했는데 잘 되어서, 생각보다 어렵지 않아서 공유 겸 기록하려고 하는 것이다 ㅋ</p><h3>Amplify Project 세팅하기</h3><p>Amplify를 처음 접하는 여러분들을 위해서 먼저 <a href="https://docs.amplify.aws/start/getting-started/installation/q/integration/js"><strong>Amplify Tutorial</strong></a> 문서를 공유한다.</p><p>Amplify 프로젝트를 만들고 코딩하는 것은 Nader Dabit님의 친절한 튜토리얼을 공유하겠다. 이 영상에서 amplify add api까지는 따라하지 않아도 된다.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgQf8jIuimlw%3Fstart%3D133%26feature%3Doembed%26start%3D133&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgQf8jIuimlw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FgQf8jIuimlw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f973ebc65b8e33f458e51b7fee69cb7c/href">https://medium.com/media/f973ebc65b8e33f458e51b7fee69cb7c/href</a></iframe><h3>Amplify로 외부 graphql API 호출 세팅하기</h3><p>Amplify에서는 graphql API를 호출하는 방법은 AppSync GraphQL API 를 호출하는 법과 non-AppSync GraphQL Server 를 호출하는 법을 설명하고 있는데, 나는 github graphql api를 호출할 것이므로…</p><p><a href="https://docs.amplify.aws/lib/graphqlapi/create-or-re-use-existing-backend/q/platform/js#using-a-non-appsync-graphql-server"><strong>Using a non-AppSync GraphQL Server</strong></a><strong> </strong>에 나와 있는대로 코드를 넣으면 된다.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dblackboard%26wt%3Dnone%26l%3Djavascript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D1x%26wm%3Dfalse%26code%3Dimport%252520Amplify%25252C%252520%25257B%252520API%252520%25257D%252520from%252520%2527aws-amplify%2527%25253B%25250Aimport%252520awsconfig%252520from%252520%2527.%25252Faws-exports%2527%25253B%25250A%25250A%25252F%25252F%252520Considering%252520you%252520have%252520an%252520existing%252520aws-exports.js%252520configuration%252520file%252520%25250AAmplify.configure%28awsconfig%29%25253B%25250A%25250A%25252F%25252F%252520Configure%252520a%252520custom%252520GraphQL%252520endpoint%25250AAmplify.configure%28%25257B%25250A%252520%252520API%25253A%252520%25257B%25250A%252520%252520%252520%252520graphql_endpoint%25253A%252520%2527https%25253A%25252F%25252Fapi.github.com%25252Fgraphql%2527%25252C%25250A%252520%252520%252520%252520graphql_headers%25253A%252520async%252520%28%29%252520%25253D%25253E%252520%28%25257B%25250A%252520%252520%252520%252520%252520%252520%2527Authorization%2527%25253A%252520%2527Bearer%252520%25257Bgithub%2525EC%252597%252590%2525EC%252584%25259C%252520%2525EB%2525B0%25259B%2525EC%252595%252584%2525EC%252595%2525BC%252520%2525ED%252595%2525A0%252520personal%252520access%252520token%25257D%2527%25250A%252520%252520%252520%252520%25257D%29%25250A%252520%252520%25257D%25250A%25257D%29%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dblackboard%26wt%3Dnone%26l%3Djavascript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D1x%26wm%3Dfalse%26code%3Dimport%25252520Amplify%2525252C%25252520%2525257B%25252520API%25252520%2525257D%25252520from%25252520%27aws-amplify%27%2525253B%2525250Aimport%25252520awsconfig%25252520from%25252520%27.%2525252Faws-exports%27%2525253B%2525250A%2525250A%2525252F%2525252F%25252520Considering%25252520you%25252520have%25252520an%25252520existing%25252520aws-exports.js%25252520configuration%25252520file%25252520%2525250AAmplify.configure%28awsconfig%29%2525253B%2525250A%2525250A%2525252F%2525252F%25252520Configure%25252520a%25252520custom%25252520GraphQL%25252520endpoint%2525250AAmplify.configure%28%2525257B%2525250A%25252520%25252520API%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520graphql_endpoint%2525253A%25252520%27https%2525253A%2525252F%2525252Fapi.github.com%2525252Fgraphql%27%2525252C%2525250A%25252520%25252520%25252520%25252520graphql_headers%2525253A%25252520async%25252520%28%29%25252520%2525253D%2525253E%25252520%28%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%27Authorization%27%2525253A%25252520%27Bearer%25252520%2525257Bgithub%252525EC%25252597%25252590%252525EC%25252584%2525259C%25252520%252525EB%252525B0%2525259B%252525EC%25252595%25252584%252525EC%25252595%252525BC%25252520%252525ED%25252595%252525A0%25252520personal%25252520access%25252520token%2525257D%27%2525250A%25252520%25252520%25252520%25252520%2525257D%29%2525250A%25252520%25252520%2525257D%2525250A%2525257D%29%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e03340f1cdf2556280fa6670f3940d2f/href">https://medium.com/media/e03340f1cdf2556280fa6670f3940d2f/href</a></iframe><p>github graphql API를 코드로 호출하려면 Authorization 헤더에 넣을 OAuth token이 필요하다. 이제 OAuth token을 어떻게 얻는 지 알아보자.</p><h3>Github personal access token 얻기</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SphsCMGsi8RdHgVTrGlUSw.png" /><figcaption>Github GraphQL API</figcaption></figure><p>github은 API explorer 를 통해서 github에 있는 자료들을 graphql을 이용하여 쿼리 할 수 있게 해주고 있다.</p><p>위의 쿼리를 직접 나의 코드에서 쿼리를 하고 싶을 때 OAuth token을 얻는 방법에 대해서는 아래 문서에 나와 있다.</p><p><a href="https://developer.github.com/v4/guides/forming-calls/#authenticating-with-graphql"><strong>GitHub Developer: Authenticating with GraphQL</strong></a></p><p>이 문서를 읽어보면 github access token을 얻는 방법을 먼저 설명해 주고 있는데, <a href="https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line">help.github.com 페이지</a>에 잘 나와 있다.</p><p>간단한 스텝을 요약하자면 이렇다.</p><blockquote>github 우측상단 내 프로필 클릭 -&gt; Settings -&gt; Developer settings -&gt; Personal access tokens -&gt; “Generate new token” 버튼 클릭 -&gt; Token description 입력 -&gt; scope체크 후 “Generate token” 클릭 -&gt; 발행된 token 복사</blockquote><p>따라하다보면 7번째 단계에서 scopes에서 체크를 이것저것 해라 라고 하고 있는데, 나는 간단한 쿼리만 할 것이므로 user에만 체크하고 token을 생성했다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*CXT9pls7WXdDCWdki8x8yA.png" /><figcaption>user에만 scope를 체크했다</figcaption></figure><p>이렇게 발행된 token은 복사해서 내 Amplify 프로젝트의 graphql_queries의 Authorization의 값(<strong><em>{github에서 받아야 할 personal access token}</em></strong> 이라 해 놓은 부분) 에다가 집어넣도록 한다</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dblackboard%26wt%3Dnone%26l%3Djavascript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D1x%26wm%3Dfalse%26code%3Dimport%252520Amplify%25252C%252520%25257B%252520API%252520%25257D%252520from%252520%2527aws-amplify%2527%25253B%25250Aimport%252520awsconfig%252520from%252520%2527.%25252Faws-exports%2527%25253B%25250A%25250A%25252F%25252F%252520Considering%252520you%252520have%252520an%252520existing%252520aws-exports.js%252520configuration%252520file%252520%25250AAmplify.configure%28awsconfig%29%25253B%25250A%25250A%25252F%25252F%252520Configure%252520a%252520custom%252520GraphQL%252520endpoint%25250AAmplify.configure%28%25257B%25250A%252520%252520API%25253A%252520%25257B%25250A%252520%252520%252520%252520graphql_endpoint%25253A%252520%2527https%25253A%25252F%25252Fapi.github.com%25252Fgraphql%2527%25252C%25250A%252520%252520%252520%252520graphql_headers%25253A%252520async%252520%28%29%252520%25253D%25253E%252520%28%25257B%25250A%252520%252520%252520%252520%252520%252520%2527Authorization%2527%25253A%252520%2527Bearer%252520%25257Bgithub%2525EC%252597%252590%2525EC%252584%25259C%252520%2525EB%2525B0%25259B%2525EC%252595%252584%2525EC%252595%2525BC%252520%2525ED%252595%2525A0%252520personal%252520access%252520token%25257D%2527%25250A%252520%252520%252520%252520%25257D%29%25250A%252520%252520%25257D%25250A%25257D%29%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dblackboard%26wt%3Dnone%26l%3Djavascript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D1x%26wm%3Dfalse%26code%3Dimport%25252520Amplify%2525252C%25252520%2525257B%25252520API%25252520%2525257D%25252520from%25252520%27aws-amplify%27%2525253B%2525250Aimport%25252520awsconfig%25252520from%25252520%27.%2525252Faws-exports%27%2525253B%2525250A%2525250A%2525252F%2525252F%25252520Considering%25252520you%25252520have%25252520an%25252520existing%25252520aws-exports.js%25252520configuration%25252520file%25252520%2525250AAmplify.configure%28awsconfig%29%2525253B%2525250A%2525250A%2525252F%2525252F%25252520Configure%25252520a%25252520custom%25252520GraphQL%25252520endpoint%2525250AAmplify.configure%28%2525257B%2525250A%25252520%25252520API%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520graphql_endpoint%2525253A%25252520%27https%2525253A%2525252F%2525252Fapi.github.com%2525252Fgraphql%27%2525252C%2525250A%25252520%25252520%25252520%25252520graphql_headers%2525253A%25252520async%25252520%28%29%25252520%2525253D%2525253E%25252520%28%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%27Authorization%27%2525253A%25252520%27Bearer%25252520%2525257Bgithub%252525EC%25252597%25252590%252525EC%25252584%2525259C%25252520%252525EB%252525B0%2525259B%252525EC%25252595%25252584%252525EC%25252595%252525BC%25252520%252525ED%25252595%252525A0%25252520personal%25252520access%25252520token%2525257D%27%2525250A%25252520%25252520%25252520%25252520%2525257D%29%2525250A%25252520%25252520%2525257D%2525250A%2525257D%29%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e03340f1cdf2556280fa6670f3940d2f/href">https://medium.com/media/e03340f1cdf2556280fa6670f3940d2f/href</a></iframe><p>GraphQL API호출해서 결과 받기</p><p>이제 코딩해서 결과를 받아보자</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dblackboard%26wt%3Dnone%26l%3Djavascript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D1x%26wm%3Dfalse%26code%3Dimport%252520%25257B%252520API%25252C%252520graphqlOperation%252520%25257D%252520from%252520%2527aws-amplify%2527%25253B%25250Aimport%252520%25257B%252520useEffect%252520%25257D%252520from%252520%2527react%2527%25253B%25250A%25250Aconst%252520github%252520%25253D%252520%252560%25250A%252520%252520query%252520%25257B%252520%25250A%252520%252520%252520%252520viewer%252520%25257B%252520%25250A%252520%252520%252520%252520%252520%252520login%25250A%252520%252520%252520%252520%25257D%25250A%252520%252520%25257D%25250A%252560%25250Aconst%252520Page%252520%25253D%252520%28%29%252520%25253D%25253E%252520%25257B%25250A%252520%252520useEffect%28%28%29%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520const%252520qry%252520%25253D%252520async%252520%28%29%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%25252F%25252F%252520Simple%252520query%25250A%252520%252520%252520%252520%252520%252520const%252520allTodos%252520%25253D%252520await%252520API.graphql%28graphqlOperation%28github%29%29%25253B%25250A%252520%252520%252520%252520%252520%252520return%252520allTodos%25250A%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520qry%28%29.then%28allTodos%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520console.log%28%2527graphq%21%21%2527%25252C%252520allTodos%29%25253B%25250A%252520%252520%252520%252520%25257D%29%25250A%252520%252520%25257D%25252C%252520%25255B%25255D%29%25250A%252520%252520%25250A%252520%252520return%252520%28%25250A%252520%252520%252520%252520%25253Cdiv%25253Ehahaha%25253C%25252Fdiv%25253E%25250A%252520%252520%29%25250A%25257D%25253B%25250A%25250Aexport%252520default%252520Page%25253B%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dblackboard%26wt%3Dnone%26l%3Djavascript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D1x%26wm%3Dfalse%26code%3Dimport%25252520%2525257B%25252520API%2525252C%25252520graphqlOperation%25252520%2525257D%25252520from%25252520%27aws-amplify%27%2525253B%2525250Aimport%25252520%2525257B%25252520useEffect%25252520%2525257D%25252520from%25252520%27react%27%2525253B%2525250A%2525250Aconst%25252520github%25252520%2525253D%25252520%25252560%2525250A%25252520%25252520query%25252520%2525257B%25252520%2525250A%25252520%25252520%25252520%25252520viewer%25252520%2525257B%25252520%2525250A%25252520%25252520%25252520%25252520%25252520%25252520login%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%2525257D%2525250A%25252560%2525250Aconst%25252520Page%25252520%2525253D%25252520%28%29%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520useEffect%28%28%29%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520const%25252520qry%25252520%2525253D%25252520async%25252520%28%29%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525252F%2525252F%25252520Simple%25252520query%2525250A%25252520%25252520%25252520%25252520%25252520%25252520const%25252520allTodos%25252520%2525253D%25252520await%25252520API.graphql%28graphqlOperation%28github%29%29%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520return%25252520allTodos%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520qry%28%29.then%28allTodos%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520console.log%28%27graphq%21%21%27%2525252C%25252520allTodos%29%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%29%2525250A%25252520%25252520%2525257D%2525252C%25252520%2525255B%2525255D%29%2525250A%25252520%25252520%2525250A%25252520%25252520return%25252520%28%2525250A%25252520%25252520%25252520%25252520%2525253Cdiv%2525253Ehahaha%2525253C%2525252Fdiv%2525253E%2525250A%25252520%25252520%29%2525250A%2525257D%2525253B%2525250A%2525250Aexport%25252520default%25252520Page%2525253B%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c5a318bb9c19342000093d2790ba658/href">https://medium.com/media/4c5a318bb9c19342000093d2790ba658/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*ScbEEZQw8aVIrS1U1lbCCg.png" /></figure><p>만약 Cognito를 붙여서 Cognito Authorizer가 붙은 API Gateway에 요청을 하고 싶다면 아래 방법을 쓰면 된다.</p><pre>Amplify.configure({<br>  API: {<br>    graphql_endpoint: url,<br>    graphql_headers: async () =&gt; ({<br>     <strong> Authorization: (await Auth.currentSession()).getIdToken().getJwtToken(),</strong><br>    }),<br>  },<br>});</pre><p>끝. 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ca5930d511f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[hackatalk-mobile React-Native 프로젝트에 graphql relay-style cursor pagination 적용하기]]></title>
            <link>https://medium.com/crossplatformkorea/hackatalk-mobile-react-native-%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8%EC%97%90-graphql-relay-style-cursor-pagination-%EC%A0%81%EC%9A%A9%ED%95%98%EA%B8%B0-72c62e011c5e?source=rss-4ffa7246a983------2</link>
            <guid isPermaLink="false">https://medium.com/p/72c62e011c5e</guid>
            <category><![CDATA[dooboolab]]></category>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[hackatalk-mobile]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[react-native-seoul]]></category>
            <dc:creator><![CDATA[taeseong park]]></dc:creator>
            <pubDate>Sun, 19 Apr 2020 15:19:59 GMT</pubDate>
            <atom:updated>2020-04-23T02:14:27.628Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pagination in hackatalk-mobile</h3><p><a href="https://github.com/dooboolab/hackatalk-mobile"><strong>hackatalk-mobile</strong></a> 프로젝트에서 현재 구현된 Apollo Client를 이용한 graphql relay-style cursor pagination 에 대하여 공유를 드리고자 합니다.</p><p>현재 <strong>SearchUser</strong> 화면에 구현이 되어 있고, 백엔드 프로젝트인 <a href="https://github.com/dooboolab/hackatalk-server"><strong>hackatalk-server</strong></a>에서 추가 Pagination에 대한 API가 구현되는대로 Pagination이 필요한 다른 곳에도 도입을 할 예정입니다.</p><h3>페이지네이션(pagination)</h3><h4>offset-based pagination</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*dfEQm3r7tGqeziBzvUtmHA.png" /></figure><p>페이지네이션 하면 일단 예전부터 사용되어 왔던 1페이지부터 10페이지 버튼이 하단에 있는 게시판이 떠오릅니다.</p><p>이 방식은 보통 offset 기반의 페이지네이션(offset-based pagination)기법을 사용하고 있습니다.</p><p>offset은 보통 몇 번째 페이지인 지 지정하는 위치 값이 되겠죠, 그러면 백엔드에서 쿼리할 때는 아래 단계를 거치게 될 겁니다.</p><ol><li>게시판 테이블 값을 전부 스캔한다</li><li>offset값 이후의 데이터를 잘라낸다</li><li>잘라낸 데이터 중 맨 앞에서부터 한 페이지 당 표시 할 게시물 갯수만큼 잘라서 리턴한다</li></ol><p>1번 과정이 있다는 것은 대용량 데이터 처리 시에 매우 느린 퍼포먼스가 나오게 될 것입니다. 하지만 이러한 이슈에 관련해서는 오래된 이슈이기 때문에 인덱스 처리를 하는 등의 성능 최적화 작업을 해서 기존에 쓰던 곳에서는 잘 사용을 하고 있을 겁니다.</p><h4>cursor-based pagination</h4><p>그치만 SNS에서 주로 쓰이는 infinite scroll pagination등의 방식을 적용하게 되었을 때 offset-based pagination을 쓰게 되면 아래와 같은 문제가 나올 수 있습니다.</p><ul><li>페이지 로드 후 아이템이 새로 추가된 시점에 다음 페이지로 넘어갔을 때 이전 페이지의 일부 데이터가 또 조회됨</li></ul><p>cursor-based pagination에서 이야기 하고 있는 <strong>cursor</strong>란 데이터를 가리키고 있는 포인터라고 생각하면 쉬울 것 같습니다.</p><p>실시간으로 휙휙 변화는 데이터들 목록을 불러올 때, cursor값을 기준으로 삼아 cursor 다음의 데이터를 가져오는 쿼리를 날림으로써 기존 offset-based pagination이 갖고 있던 중복 데이터를 쿼리하지 않을 수 있게 됩니다.</p><p>그래서 백엔드에서 cursor를 정할 때에는 DB의 unique하고, 순서가 있는 컬럼을 하나 골라서 구현을 해야 합니다.</p><p>그래서 저희 <strong>hackatalk-mobile</strong>에서는 infinite scroll pagination을 구현하고 있기 때문에 <strong>cursor-based pagination</strong>을 구현하기로 합니다.</p><h3>Apollo Client 채택 이유</h3><p>React에 GraphQL을 사용하게 해 주는 라이브러리로써 Apollo와 Relay라는 두 가지의 라이브러리가 존재합니다.</p><p>hackatalk-mobile 프로젝트에서는 Apollo Client를 채택 중인데, 이유는 아래와 같습니다.</p><h4>엄격한 스키마 규율 준수를 위한 오버엔지니어링 회피</h4><p>Relay에서는 스키마 규율이 엄격해서 쿼리문에는 끝에 <strong>{Module}Query,</strong> Mutation에는 <strong>{Module}Mutation</strong> 등의 네이밍 규칙을 꼭 지켜야 합니다.</p><p>프론트에서 백엔드의 graphql 쿼리 스키마 구조와 똑같이 맞추기 위해 schema.graphql파일을 따로 만들어서 관리를 해야 할 수 있습니다.</p><p>그렇지 않으면 Relay 컴파일러에서 에러를 유발할 수 있다고 합니다. 자칫 오버엔지니어링이 발생 될 수가 있다는 것이겠죠.</p><p>그치만 Apollo client는 이러한 스키마 네이밍 규율에 대해서 관대하고, 프론트에서 schema.graphql을 따로 만들어서 스키마 구조를 맞춰야 하는 강제성도 없습니다. 그리고 커뮤니티 규모가 Relay보다 훨씬 큽니다. 이것이 저희가 Apollo client를 택한 이유입니다.</p><p>그리고 Apollo와 Relay를 비교한 좋은 포스팅을 발견 해서 한번 공유 해 드리겠습니다</p><p><a href="https://link.medium.com/ohm7RKraF5">Apollo and Relay Side by Side</a></p><h3>Relay Style Cursor Pagination 의 이해</h3><h4>Relay-style cursor pagination을 택한 이유</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*gziDWACBtcXx6meLmpsEgg.png" /><figcaption>Apollo cursor pagination &amp; Relay cursor pagination 스키마 비교</figcaption></figure><p>Apollo cursor pagination은 스키마 구조는 간단하고 직관적입니다.</p><p>그렇지만 결과값 중 맨 처음 전 데이터가 있는지와 맨 끝 이후의 데이터가 있는 지에 대한 확인이 불가하다는 점, cursor 기준으로 이전 데이터를 가져오는 argument가 없다는 점이 눈에 띕니다.</p><p>이렇듯 Relay-style cursor pagination은 페이징 처리에 대하여 전후 방향, 그리고 페이지 내용의 맨 끝과 맨 마지막의 상태를 알 수 있는 <strong>pageInfo</strong> 타입이 들어간 <strong>Connection model</strong>의 개념이 잘 녹아 들어 있습니다.</p><p>GraphQL 공식 페이지인 <a href="https://graphql.org/learn/pagination/#pagination-and-edges">graphql.org의 pagination</a> 페이지는 위에서 서술한 페이지네이션에서 발생할 수 있는 종합적인 상황을 고려한 <strong>Connection model design</strong>을 서술하고 있는데, 이것이 Relay-style cursor pagination이 구현된 모델과 거의 같다고 볼 수 있습니다.</p><p><a href="https://developer.github.com/v4/explorer/">GitHub Developer API Explorer</a> 에서 또한 pagination 을 Relay-style cursor pagination으로 되어 있는 것을 확인 할 수 있습니다.</p><h4>Relay-style cursor pagination 사용 예</h4><p>아래 GraphQL 쿼리문은 relay-style cursor pagination의 예입니다.</p><pre>query {<br>  products(first: 10, after: &quot;cursor&quot;) {<br>    edges {<br>      cursor<br>      node {<br>        id<br>        name<br>      }<br>    }<br>    pageInfo {<br>      hasNextPage<br>    }<br>  }<br>}</pre><p>10개의 데이터를 얻기 위한 쿼리문인데요, “<strong>first</strong>”인수를 사용하여 수행됩니다. offset-based pagination의 “<strong>limit</strong>”과 유사하다고 보시면 됩니다.</p><p>페이징 처리는 “<strong>after</strong>”인수를 사용하여 수행되며, 결과는 “<strong>cursor</strong>” 다음에 있을 것으로 예상되는 “<strong>cursor</strong>”를 전달합니다.</p><p>또한 cursor pagination에는 총 페이지 수 개념이 없기 때문에 더 많은 결과가 있는지 클라이언트에게 알려주는 <strong>pageInfo</strong> type이 있으며, “<strong>hasNextPage</strong>”를 요청해서 확인 할 수가 있습니다.</p><p>Relay-style cursor pagination에 대한 더 자세한 내용은 graphql-seoul 미디움 채널에 포스팅 한 바가 있으니 관심 있으신 분들은 한번 열람 해 보시면 좋겠습니다.</p><p><a href="https://medium.com/graphql-seoul/graphql-pagination-%EA%B5%AC%ED%98%84%ED%95%98%EA%B8%B0-relays-cursor-based-connection-pattern-72ab0daceed4">GraphQL Pagination 구현하기: Relay’s Cursor Based Connection Pattern</a></p><p>또한 Apollo Blog에는 facebook 엔지니어가 기고한 포스팅이 있는데, 여기서는 graphql cursor pagination 에서 자주 나오는 개념인 Connection에 대하여 탄생배경부터 그림과 함께 네이밍 규칙에 대하여 설명하고 있는데, 같이 참고 하시면 좋을 것 같습니다.</p><p><a href="https://www.apollographql.com/blog/explaining-graphql-connections-c48b7c3d6976">Explaining GraphQL Connections</a></p><h3>Apollo Client 사용하기</h3><h4>세팅하기</h4><p>React-Native 프로젝트에 Apollo client 세팅을 해 주는 방법에 대해서는 이전에 이미 react-native-seoul 미디움 채널에 상세하게 포스팅이 되어 있으니 읽어 보시길 권장드립니다.</p><ul><li><a href="https://medium.com/react-native-seoul/react-native-%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98%EC%97%90-apollo-client-%ED%86%B5%ED%95%A9%ED%95%98%EA%B8%B0-1-48f449111332">react-native 어플리케이션에 Apollo client 통합하기 #1</a></li><li><a href="https://medium.com/react-native-seoul/react-native-%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98%EC%97%90-apollo-client-%ED%86%B5%ED%95%A9%ED%95%98%EA%B8%B0-2-f5c116377d0d">react-native 어플리케이션에 Apollo client 통합하기 #2</a></li></ul><h4>Graphql 쿼리하기</h4><p><a href="https://www.apollographql.com/docs/react/api/react-hooks">@apollo/react-hooks</a> 라이브러리에 있는 <a href="https://www.apollographql.com/docs/react/api/react-hooks/#usequery">useQuery</a>를 이용하여 쿼리를 합니다.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dmaterial%26wt%3Dnone%26l%3Dapplication%252Ftypescript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%252520%25257B%252520useQuery%252520%25257D%252520from%252520%2527%252540apollo%25252Freact-hooks%2527%25253B%25250Aimport%252520%25257B%25250A%252520%252520QUERY_FRIENDS%25252C%25250A%252520%252520QUERY_USERS%25252C%25250A%252520%252520QueryUsersInput%25252C%25250A%25257D%252520from%252520%2527..%25252F..%25252Fgraphql%25252Fqueries%2527%25253B%25250A%25250Ainterface%252520QueryUsersData%252520%25257B%25250A%252520%252520users%25253A%252520%25257B%25250A%252520%252520%252520%252520__typename%25253A%252520string%25253B%25250A%252520%252520%252520%252520totalCount%25253A%252520number%25253B%25250A%252520%252520%252520%252520edges%25253A%252520UserEdges%25255B%25255D%25253B%25250A%252520%252520%252520%252520pageInfo%25253A%252520%25257B%25250A%252520%252520%252520%252520%252520%252520startCursor%25253A%252520string%25253B%25250A%252520%252520%252520%252520%252520%252520endCursor%25253A%252520string%25253B%25250A%252520%252520%252520%252520%252520%252520hasNextPage%25253A%252520boolean%25253B%25250A%252520%252520%252520%252520%252520%252520hasPreviousPage%25253A%252520boolean%25253B%25250A%252520%252520%252520%252520%25257D%25253B%25250A%252520%252520%25257D%25253B%25250A%25257D%25250A%25250A%25252F%25252F%252520...%25250A%25250Aconst%252520Screen%252520%25253D%252520%28%29%25253A%252520React.ReactElement%252520%25253D%25253E%252520%25257B%25250A%252520%252520%25252F%25252F%252520...%25250A%252520%252520const%252520%25257B%25250A%252520%252520%252520%252520loading%25252C%25250A%252520%252520%252520%252520data%25252C%25250A%252520%252520%252520%252520error%25252C%25250A%252520%252520%252520%252520refetch%25252C%25250A%252520%252520%252520%252520fetchMore%25252C%25250A%252520%252520%25257D%252520%25253D%252520useQuery%25253CQueryUsersData%25252C%252520QueryUsersInput%25253E%28QUERY_USERS%25252C%252520%25257B%25250A%252520%252520%252520%252520fetchPolicy%25253A%252520%2527network-only%2527%25252C%25250A%252520%252520%252520%252520variables%25253A%252520%25257B%25250A%252520%252520%252520%252520%252520%252520first%25253A%252520PAGE_CNT%25252C%25250A%252520%252520%252520%252520%252520%252520filter%25253A%252520true%25252C%25250A%252520%252520%252520%252520%252520%252520user%25253A%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520email%25253A%252520debouncedText%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520name%25253A%252520debouncedText%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520nickname%25253A%252520debouncedText%25252C%25250A%252520%252520%252520%252520%252520%252520%25257D%25252C%25250A%252520%252520%252520%252520%25257D%25252C%25250A%252520%252520%25257D%29%25253B%25250A%252520%252520%25250A%252520%252520return%252520%28%25250A%252520%252520%252520%252520%25252F%25252F%252520...%25250A%252520%252520%29%25250A%25257D%25250A%25250A%25252F%25252F%252520...%25250A%25250Aexport%252520default%252520Screen%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dmaterial%26wt%3Dnone%26l%3Dapplication%25252Ftypescript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%25252520%2525257B%25252520useQuery%25252520%2525257D%25252520from%25252520%27%25252540apollo%2525252Freact-hooks%27%2525253B%2525250Aimport%25252520%2525257B%2525250A%25252520%25252520QUERY_FRIENDS%2525252C%2525250A%25252520%25252520QUERY_USERS%2525252C%2525250A%25252520%25252520QueryUsersInput%2525252C%2525250A%2525257D%25252520from%25252520%27..%2525252F..%2525252Fgraphql%2525252Fqueries%27%2525253B%2525250A%2525250Ainterface%25252520QueryUsersData%25252520%2525257B%2525250A%25252520%25252520users%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520__typename%2525253A%25252520string%2525253B%2525250A%25252520%25252520%25252520%25252520totalCount%2525253A%25252520number%2525253B%2525250A%25252520%25252520%25252520%25252520edges%2525253A%25252520UserEdges%2525255B%2525255D%2525253B%2525250A%25252520%25252520%25252520%25252520pageInfo%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520startCursor%2525253A%25252520string%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520endCursor%2525253A%25252520string%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520hasNextPage%2525253A%25252520boolean%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520hasPreviousPage%2525253A%25252520boolean%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%2525253B%2525250A%25252520%25252520%2525257D%2525253B%2525250A%2525257D%2525250A%2525250A%2525252F%2525252F%25252520...%2525250A%2525250Aconst%25252520Screen%25252520%2525253D%25252520%28%29%2525253A%25252520React.ReactElement%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%2525252F%2525252F%25252520...%2525250A%25252520%25252520const%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520loading%2525252C%2525250A%25252520%25252520%25252520%25252520data%2525252C%2525250A%25252520%25252520%25252520%25252520error%2525252C%2525250A%25252520%25252520%25252520%25252520refetch%2525252C%2525250A%25252520%25252520%25252520%25252520fetchMore%2525252C%2525250A%25252520%25252520%2525257D%25252520%2525253D%25252520useQuery%2525253CQueryUsersData%2525252C%25252520QueryUsersInput%2525253E%28QUERY_USERS%2525252C%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520fetchPolicy%2525253A%25252520%27network-only%27%2525252C%2525250A%25252520%25252520%25252520%25252520variables%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520first%2525253A%25252520PAGE_CNT%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520filter%2525253A%25252520true%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520user%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520email%2525253A%25252520debouncedText%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520name%2525253A%25252520debouncedText%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520nickname%2525253A%25252520debouncedText%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525252C%2525250A%25252520%25252520%25252520%25252520%2525257D%2525252C%2525250A%25252520%25252520%2525257D%29%2525253B%2525250A%25252520%25252520%2525250A%25252520%25252520return%25252520%28%2525250A%25252520%25252520%25252520%25252520%2525252F%2525252F%25252520...%2525250A%25252520%25252520%29%2525250A%2525257D%2525250A%2525250A%2525252F%2525252F%25252520...%2525250A%2525250Aexport%25252520default%25252520Screen%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5b88ec62401a328c3f40e5d87c18e3e/href">https://medium.com/media/a5b88ec62401a328c3f40e5d87c18e3e/href</a></iframe><p>실제 구현 코드는 아래 링크에서 확인하실 수 있습니다.</p><p><a href="https://github.com/dooboolab/hackatalk-mobile/blob/master/src/components/screen/SearchUser.tsx#L81-L101">dooboolab/hackatalk-mobile</a></p><p><strong>useQuery</strong>에 대한 Apollo API 문서를 보시면 더 다양한 option, result 속성 들을 확인 하실 수 있습니다.</p><p><a href="https://www.apollographql.com/docs/react/api/react-hooks/#usequery">@apollo/react-hooks</a></p><h4>fetchMore 활용하기</h4><p>앞선 쿼리에서 받아온 데이터의 마지막까지 다 열람하고 그 다음 데이터를 받기 위해 사용하게 될 메소드가 바로 fetchMore 입니다. 즉 pagination을 가능케 해 주는 메소드죠.</p><p>fetchMore 메소드에 들어갈 파라미터 타입과 리턴 타입은 아래와 같습니다.</p><pre>({ <strong>query</strong>?: DocumentNode, <strong>variables</strong>?: TVariables, <strong>updateQuery</strong>: Function }) =&gt; Promise&lt;ApolloQueryResult&gt;</pre><p>저희는 여기서 커서 기반의 argument를 넣는 <strong>variables</strong>, 새로운 결과값을 apollo client에 업데이트 시켜주는 <strong>updateQuery</strong> 를 활용하여 다음 데이터를 받고자 하는 pagination쿼리를 업데이트 시켜 주었습니다.</p><p><strong>참고 url -&gt; Apollo Docs: relay-style cursor pagination (fetchMore 사용 예제 포함)</strong></p><p><a href="https://www.apollographql.com/docs/react/data/pagination/#relay-style-cursor-pagination">Pagination</a></p><h4>FlatList를 이용한 Scroll Pagination 구현하기</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dmaterial%26wt%3Dnone%26l%3Dapplication%252Ftypescript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%252520%25257B%252520Animated%25252C%252520FlatList%252520%25257D%252520from%252520%2527react-native%2527%25253B%25250A%25250Aconst%252520AnimatedFlatList%252520%25253D%252520Animated.createAnimatedComponent%28FlatList%29%25253B%25250A%25250Aconst%252520StyledAnimatedFlatList%252520%25253D%252520styled%28AnimatedFlatList%29%252560%25250A%252520%252520width%25253A%252520100%252525%25253B%25250A%252520%252520height%25253A%252520100%252525%25253B%25250A%252560%25253B%25250A%25250Aconst%252520Screen%252520%25253D%252520%28%29%25253A%252520React.ReactElement%252520%25253D%25253E%252520%25257B%25250A%25250A%252520%252520const%252520scrollY%252520%25253D%252520new%252520Animated.Value%280%29%25253B%25250A%25250A%252520%252520const%252520renderUsers%252520%25253D%252520%28%29%25253A%252520React.ReactElement%252520%25253D%25253E%252520%25257B%25250A%252509%25252F%25252F%252520blahblah%25250A%252520%252520%252520%252520return%252520%28%25250A%252520%252520%252520%252520%252520%252520%25253CStyledAnimatedFlatList%25250A%252520%252520%252520%252520%252520%252520%252520%252520testID%25253D%252522animated-flatlist%252522%25250A%252520%252520%252520%252520%252520%252520%252520%252520style%25253D%25257B%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520transform%25253A%252520%25255B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520translateY%25253A%252520scrollY.interpolate%28%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520inputRange%25253A%252520%25255B0%25252C%25252050%25252C%252520100%25255D%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520outputRange%25253A%252520%25255B0%25252C%25252025%25252C%2525200%25255D%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%29%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25255D%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520contentContainerStyle%25253D%25257BgetContentContainerStyle%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520keyExtractor%25253D%25257B%28item%25253A%252520object%25252C%252520index%25253A%252520number%29%25253A%252520string%252520%25253D%25253E%252520index.toString%28%29%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520data%25253D%25257Busers%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520renderItem%25253D%25257BrenderItem%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520ListEmptyComponent%25253D%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25253CEmptyListItem%25253E%25257BgetString%28%2527NO_CONTENT%2527%29%25257D%25253C%25252FEmptyListItem%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520onEndReachedThreshold%25253D%25257B0.1%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520onEndReached%25253D%25257BonEndReached%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520scrollEventThrottle%25253D%25257B500%25257D%25250A%252520%252520%252520%252520%252520%252520%25252F%25253E%25250A%252520%252520%252520%252520%29%25253B%25250A%252520%252520%25257D%25250A%252520%252520%25250A%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dmaterial%26wt%3Dnone%26l%3Dapplication%25252Ftypescript%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%25252520%2525257B%25252520Animated%2525252C%25252520FlatList%25252520%2525257D%25252520from%25252520%27react-native%27%2525253B%2525250A%2525250Aconst%25252520AnimatedFlatList%25252520%2525253D%25252520Animated.createAnimatedComponent%28FlatList%29%2525253B%2525250A%2525250Aconst%25252520StyledAnimatedFlatList%25252520%2525253D%25252520styled%28AnimatedFlatList%29%25252560%2525250A%25252520%25252520width%2525253A%25252520100%25252525%2525253B%2525250A%25252520%25252520height%2525253A%25252520100%25252525%2525253B%2525250A%25252560%2525253B%2525250A%2525250Aconst%25252520Screen%25252520%2525253D%25252520%28%29%2525253A%25252520React.ReactElement%25252520%2525253D%2525253E%25252520%2525257B%2525250A%2525250A%25252520%25252520const%25252520scrollY%25252520%2525253D%25252520new%25252520Animated.Value%280%29%2525253B%2525250A%2525250A%25252520%25252520const%25252520renderUsers%25252520%2525253D%25252520%28%29%2525253A%25252520React.ReactElement%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252509%2525252F%2525252F%25252520blahblah%2525250A%25252520%25252520%25252520%25252520return%25252520%28%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525253CStyledAnimatedFlatList%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520testID%2525253D%25252522animated-flatlist%25252522%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520style%2525253D%2525257B%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520transform%2525253A%25252520%2525255B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520translateY%2525253A%25252520scrollY.interpolate%28%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520inputRange%2525253A%25252520%2525255B0%2525252C%2525252050%2525252C%25252520100%2525255D%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520outputRange%2525253A%25252520%2525255B0%2525252C%2525252025%2525252C%252525200%2525255D%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%29%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525255D%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520contentContainerStyle%2525253D%2525257BgetContentContainerStyle%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520keyExtractor%2525253D%2525257B%28item%2525253A%25252520object%2525252C%25252520index%2525253A%25252520number%29%2525253A%25252520string%25252520%2525253D%2525253E%25252520index.toString%28%29%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520data%2525253D%2525257Busers%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520renderItem%2525253D%2525257BrenderItem%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520ListEmptyComponent%2525253D%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253CEmptyListItem%2525253E%2525257BgetString%28%27NO_CONTENT%27%29%2525257D%2525253C%2525252FEmptyListItem%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520onEndReachedThreshold%2525253D%2525257B0.1%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520onEndReached%2525253D%2525257BonEndReached%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520scrollEventThrottle%2525253D%2525257B500%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%29%2525253B%2525250A%25252520%25252520%2525257D%2525250A%25252520%25252520%2525250A%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf9f307ff4965a467315258230627c04/href">https://medium.com/media/cf9f307ff4965a467315258230627c04/href</a></iframe><p>Pagination을 위하여 FlatList의 아래 prop들을 활용하였습니다.</p><ul><li>onEndReached</li><li>onEndReachedThreshold</li><li>scrollEventThrottle</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJc2MX0Ew3PE%3Fstart%3D384%26feature%3Doembed%26start%3D384&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJc2MX0Ew3PE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJc2MX0Ew3PE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/77d1ebd056c599b2766400bbd9d02622/href">https://medium.com/media/77d1ebd056c599b2766400bbd9d02622/href</a></iframe><p><strong>onEndReached</strong></p><p>FlatList 속성 중에 <strong>renderItem</strong> 이라는 속성을 이용하여 리스트들을 컴포넌트로 렌더링을 하게 되는데,</p><p>이 리스트가 스크롤되면서 특정 offset에 도달 되었을 때 실행 되게 할 수 있는 로직입니다.</p><p>여기에서 Apollo client의 fetchMore를 활용한 pagination 로직이 들어 가게 됩니다.</p><p>해당 로직을 실행 시키게 하는 속성값은 바로 아래 서술 하게 될 onEndReachedThreshold에서 조절 할 수 있습니다.</p><p><strong>onEndReachedThreshold</strong></p><p>onEndReachedThreshold를 간단히 설명하자면, 스마트폰 화면의 맨 끝 부분과 실제 화면에 보이지 않고 있는 리스트 컨텐츠의 끝 부분 사이가 얼마나 떨어져 있는 지 측정하여 내가 넣은 값을 만족 시키면 onEndReached를 실행시켜 주는 속성입니다.</p><p>onEndReachedThreshold 라는 것은 정확히 어떤 조건에서 onEndReached 를 실행 시키는 지 확실하게 알고 싶어서 이 기회에 한번 실습을 통하여 알아 보았습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*IW31vU7gkbBNQ6UsnvZ8hw.png" /><figcaption>onEndReachedThreshold를 파헤쳐 보았다</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsnack.expo.io%2Fembedded%2F%40geoseong%2Fflatlist-infinite-scroll-onendreached-testing&amp;display_name=Expo+Snack&amp;url=https%3A%2F%2Fsnack.expo.io%2F%40geoseong%2Fflatlist-infinite-scroll-onendreached-testing%3Fsession_id%3Dsnack-session-Rv5kfvLW5%26preview%3Dtrue%26platform%3Dweb%26iframeId%3D8v7tv3x9b1%26theme%3Ddark&amp;image=https%3A%2F%2Fs3.amazonaws.com%2Fexp-brand-assets%2FSnackIcon_200.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=expo" width="700" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4aeabbc3571fa4990bf7572732674fa/href">https://medium.com/media/f4aeabbc3571fa4990bf7572732674fa/href</a></iframe><p>expo의 snack으로 직접 코딩하며 실습 해 본 것인데, <strong>threshold</strong> 변수의 값을 조절 해 보시면서 어느 시점에 아이템이 추가 로드 되는 지, offset과 height로그를 확인 하실 수 있습니다.</p><p>onEndReachedThreshold의 값을 1로 줘 봅니다.</p><p>이 1이라는 게 의미하는 것은 배수이며, 보통 0에서 1 사이의 값을 넣는 게 일반적인데, 어떤 것을 대상으로 이 배수를 곱할까요?</p><p>실습을 통하여 보면 FlatList의 height를 대상으로 하는 것 같습니다. 그 증거는 위에 첨부된 그림에서 보이시는 `<strong>window-(TopBar+statusBar)`. </strong>즉 FlatList의 height값이 `<strong>onEndReached`</strong>가 실행 되었을 당시에 뱉어내는 `<strong>distanceFromEnd`</strong>의 값과 같기 때문입니다. 수기로 스크롤을 내리다 보니까 빠른 속도로 스크롤을 내리면 값이 일치하지 않은 상태로 로그가 찍히기도 하네요; ㅎ</p><p>그래서 실제 리스트의 가장 마지막 밑에 부분과 스마트폰 기기의 밑 부분의 간격이<strong> (flatlist의 height) * (onEndReachedThreshold의 값)</strong>이 되는 순간 <strong>onEndReached</strong> 로직이 발동 되는 원리라는 것을 실습과 도식화를 통해서 새삼 다시 한 번 확인하게 되었습니다</p><p>만약 onEndReachedThreshold의 값을 아무것도 넣지 않으면 <strong>기본값으로 0.5</strong>가 들어가게 되니 참고하세요.</p><p><strong>scrollEventThrottle</strong></p><p>scrollEventThrottle prop은 제가 개발 중에 onEndReached로직이 2번 연속으로 실행이 되는 경우를 발견해서 구글링을 하다가 우연히 발견 한 속성입니다.</p><p>scrollEventThrottle은 문서에 따르면 ScrollView 컴포넌트에 내용이 존재하는데, FlatList의 prop들은 ScrollView의 prop을 상속 받았기 때문에 사용이 가능한 것입니다.</p><p>상속 받았다는 내용은 아래 React Native FlatList 페이지 링크를 걸어 두었습니다.</p><blockquote>Inherits <a href="https://reactnative.dev/docs/scrollview#props">ScrollView Props</a>, unless it is nested in another FlatList of same orientation.</blockquote><ul><li><a href="https://reactnative.dev/docs/scrollview#scrolleventthrottle">ScrollView · React Native</a></li><li><a href="https://reactnative.dev/docs/flatlist#props">FlatList · React Native</a></li></ul><p>scrollEventThrottle 기본값은 ‘0’ms이며, 보기가 스크롤 될 때마다 한 번만 스크롤 이벤트가 전송됩니다. 숫자가 높을수록 성능은 향상되지만 정밀도는 떨어진다고 합니다.</p><p>보통 16ms 으로 값을 넣는 예제들을 심심찮게 찾아 볼 수 있었는데, 이유는 bridge를 통해 전송되는 정보의 양으로 인해 스크롤 성능 문제가 발생할 수 있기 때문에 최소한의 ms단위인 16ms를 사용하는 것이라고 합니다.</p><p>저희 프로젝트에서는 굳이 빠르게 쿼리 할 필요가 없다고 느껴서 넉넉하게 500ms로 넣었습니다 ㅎ</p><p>참고로 이 속성은 iOS에서만 작동됩니다.</p><h3>마무리</h3><p>Infinite Scroll Pagination 구현을 위하여 Graphql의 relay-style cursor pagination에 대해 알아 보았고,</p><p>React-Native 프로젝트에서 GraphQL을 사용하게 해 주는 Relay와 Apollo에 대해 간단히 알아 보았으며,</p><p>Apollo Client를 통하여 실제 GraphQL 쿼리 사용과 Pagination방법,</p><p>FlatList의 onEndReached, onEndReachedThreshold, scrollEventThrottle prop에 대해 알아보았습니다.</p><p>이렇게 문서로 정리를 하다 보니까 내가 머릿속으로 어설프게 알고 있던 부분에 대한 궁금증이 많이 생기고, 파헤쳐 가며 알아내다 보니 가려운 부분을 긁는 느낌이 들어서 복잡했던 머릿속이 시원해 지는 느낌도 듭니다. 제 개인적으로는요..ㅎㅎ</p><p>이렇듯 저희가 커뮤니티에서 진행 중인 프로젝트 관련, 아니면 React-Native와 관련 된 공유하고자 하는 내용이 있으시다면 누구든 얼마든지 저희 react-native-seoul 미디움 채널에 포스팅을 남겨주시고, 같이 지식 공유하는 소통의 장이 되었음 좋겠습니다.</p><p>아.. 저희 리액트네이티브서울 커뮤니티 페이지에 올라왔던 질문 중에 이 주제에 관련 된 질문은 잘 해결 되었는지 궁금하네요.. ㅎ</p><p><a href="https://reactnativeseoul.org/t/flatlist-onendreached-prop/538">FlatList의 onEndReached prop에 대해 질문드리려고 합니다!</a></p><p>추가할 사항 있다면 내용 업데이트 하겠습니다</p><p>감사합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72c62e011c5e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/crossplatformkorea/hackatalk-mobile-react-native-%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8%EC%97%90-graphql-relay-style-cursor-pagination-%EC%A0%81%EC%9A%A9%ED%95%98%EA%B8%B0-72c62e011c5e">hackatalk-mobile React-Native 프로젝트에 graphql relay-style cursor pagination 적용하기</a> was originally published in <a href="https://medium.com/crossplatformkorea">Cross-Platform Korea</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraphQL Pagination 구현하기: Relay’s Cursor Based Connection Pattern]]></title>
            <link>https://medium.com/prisma-korea/graphql-pagination-%EA%B5%AC%ED%98%84%ED%95%98%EA%B8%B0-relays-cursor-based-connection-pattern-72ab0daceed4?source=rss-4ffa7246a983------2</link>
            <guid isPermaLink="false">https://medium.com/p/72ab0daceed4</guid>
            <category><![CDATA[hacktalk]]></category>
            <category><![CDATA[relay]]></category>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[cursor-connection]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[taeseong park]]></dc:creator>
            <pubDate>Sat, 14 Mar 2020 09:35:57 GMT</pubDate>
            <atom:updated>2020-04-14T13:04:58.233Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introducing</h3><p>GraphQL의 공식페이지인 <a href="https://graphql.org/learn/pagination/"><strong>graphql.org</strong></a> 에서 설명하고 있는 Pagination은 Relay project가 갖고 있는 공식 스펙인 <a href="https://facebook.github.io/relay/graphql/connections.htm"><strong>GraphQL Cursor Connections Specification</strong></a>과 일치하며(2020년 3월 14일 현재), <strong>Connection Specification</strong> 영역에 Relay 문서 링크를 걸어놓고 있다.</p><p>그리고 <a href="https://developer.github.com/v4/explorer/"><strong>GitHub Developer API Explorer</strong></a>에서도 데이터 제공방식을 GraphQL API로써 제공하는데, Pagination을 <strong>Relay의 cursor connections specification</strong>을 사용하고 있다.</p><h3>GraphQL Cursor Connections Specification</h3><pre>{<br>  user {<br>    id<br>    name<br>    friends(first: 10, after: &quot;opaqueCursor&quot;) {<br>      edges {<br>        cursor<br>        node {<br>          id<br>          name<br>        }<br>      }<br>      pageInfo {<br>        hasNextPage<br>      }<br>    }<br>  }<br>}</pre><p>위의 코드가 Relay문서에서 보여주고 있는 쿼리 예제이다.</p><p>여기서 주목해야 할 것은 <strong>friends</strong> 구문이고, 이 friends 구문을 Relay connection pattern에서는 <strong>Connection Model</strong>이라고 칭한다.</p><p>Pagination정보를 얻고자 할 때 이 Connection Model을 활용해야 한다.</p><h4>Overview</h4><p>Relay에서는 Connection Model에 대한 각 스펙에 네이밍 규칙을 정의 해 놓고 있다.</p><blockquote>Connection객체의 이름은 항상 끝에 “Connection” 으로 끝내야 한다</blockquote><blockquote>Pagination에 대한 정보를 담은 객체명은 “<strong>PageInfo</strong>”로 지어야 한다</blockquote><p>Connection Model에 대한 대략적인 Overview는 아래 그림과 같다</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*eQdIGtpd3ne_kJ9NWZAOKA.jpeg" /><figcaption>GraphQL Cursor Connections Specification Connection Flow overview</figcaption></figure><p>우선, 위의 쿼리 예제 옆에다가 Connection Model에 대한 설명을 주석으로 달아보았다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/75af68b80630e26dfeff6d4297f3f6ca/href">https://medium.com/media/75af68b80630e26dfeff6d4297f3f6ca/href</a></iframe><p>이제 각 Connection Model의 상세 스펙들에 대해서 알아보자.</p><h4>Edges</h4><p><strong>Node</strong></p><p>실질적으로 원하는 데이터가 들어 있는 <strong>Object 타입</strong>이라고 보면 된다.</p><p>예를 들어 Friends 테이블의 데이터를 얻어오고 싶을 때 Friends 테이블의 데이터는 return되는 Connection 필드 중에 edges -&gt; node에 들어 있다고 보면 된다.</p><p>아무런 결과가 없다면 <strong>Empty Array</strong>로 리턴을 시킨다.</p><p><strong>Cursor</strong></p><p>이 Cursor가 Pagination의 가장 핵심적인 부분이라고 볼 수 있는데, Cursor를 기준으로 이전 데이터와 이후 데이터를 받아올 수가 있다고 이해하면 된다.</p><p>내가 과거에 서술했던 부족한 코멘트는 무시하라..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*CEydgPrWhfDdZN-f133QKg.png" /><figcaption>내가 첫 포스팅 당시에 썼던 내용.. 이 내용을 쓰면서도 꺼림직했는데 이 설명은 틀린 것 같다</figcaption></figure><p><a href="https://graphql-kr.github.io/learn/pagination/">https://graphql-kr.github.io/learn/pagination/</a> 페이지에서는 Cursor에 대해 아래와 같이 서술하고 있다.</p><blockquote>커서를 offset 또는 ID로 지정한 커서 기반의 페이지네이션을 구현할 수 있으며,</blockquote><blockquote>커서를 사용하면 향후 페이지네이션 모델이 변경될 경우에 추가적인 유연성이 제공됩니다.</blockquote><blockquote>커서가 확실하고 형태를 신뢰할 수 없다는 것을 상기시켜주기 위해, <strong>base64 인코딩하는 것</strong>이 좋습니다.</blockquote><p>base64로 인코딩한다라…</p><p>그런데 다른 예시들을 살펴 보았을 때 RDB 기준으로 <strong>createdAt</strong> 같은 정렬하기에 무난한 컬럼을 하나 잡아 String형태로 그대로 리턴하는 케이스도 있었고, 짧은 UUID같은 값(이게 base64인가..)로 쓰이는 케이스도 보았다. 흠..</p><p>이렇듯 Cursor는 Edge 안의 객체 타입으로 사용하는 것이 아니라, Connection을 위한 속성으로 쓰이며, 나름의 로직을 통해 구현해 내는 것이라고 생각한다.</p><p>사실 조금 더 스터디해서 base64로 인코딩된 Cursor 를 구현해 봐야 할 것 같다.</p><h4>Arguments</h4><p>쿼리 시 조건문이라고 생각하면 쉽게 이해될 것 같다.</p><p>일반적으로 검색되는 정방향으로 검색하고 싶으면 <strong>forward</strong> argument를 넣으면 되고,</p><p>역방향으로 검색하고 싶으면 <strong>backward</strong> argument를 넣으면 되겠다.</p><p>각 타입은 아래와 같다.</p><p><a href="https://facebook.github.io/relay/graphql/connections.htm#sec-Forward-pagination-arguments"><strong>forward pagination arguments</strong></a></p><ul><li>first: non-negative integer</li><li>after: cursor type</li></ul><p><a href="https://facebook.github.io/relay/graphql/connections.htm#sec-Backward-pagination-arguments"><strong>backward pagination arguments</strong></a></p><ul><li>last: non-negative integer</li><li>before: cursor type</li></ul><p><strong>주의사항1. Edge Order</strong></p><ul><li><strong><em>before</em></strong> argument가 들어갔을 경우: <strong>before</strong> 커서에서 가장 가까운 edge가 결과 edge 중 <strong>가장 마지막에</strong> 와야 한다.</li><li><strong><em>after</em></strong> argument가 들어갔을 경우: <strong>after</strong> 커서에서 가장 가까운 edge가 결과 edge 중에 <strong>가장 먼저 </strong>나와야 한다.</li></ul><p>실제 데이터를 넣어서 예를 들자면 이렇게 나와야 한다</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*ztOHFRR6DZcWJT71n4S51Q.png" /><figcaption>before, after cursor를 입력하게 되면 리턴시켜야 할 데이터를 표시</figcaption></figure><p><strong>주의사항2. first와 last를 동시에 쿼리시키게 하지 마라</strong></p><p>Relay에서 이야기하기를 웬만해서는 first와 last argument를 동시에 받지 말라고 하고 있는데, 이는 혼란스러운 결과를 초래할 수 있다고 서술하고 있다.</p><p>실제로 GitHub Developer’s API Explorer에서는 first와 last argument를 동시에 쿼리시켰을 경우 아얘 에러를 뱉는다.</p><blockquote>“message”: “Passing both `first` and `last` to paginate the `search` connection is not supported.”</blockquote><h4>예제 데이터를 MySQL 쿼리와 함께 Pagination Connection 구축해 보기</h4><p>여태 살펴보았던 개념을 참고하여 구현 해 본 사항에 대해 서술을 해보려고 한다.</p><p><a href="https://github.com/dooboolab/hackatalk-server"><strong>hackatalk-server</strong></a>의 Pull Request에서 Full code를 볼 수 있다.</p><p><a href="https://github.com/dooboolab/hackatalk-server/pull/62">Implement Pagination: User by geoseong · Pull Request #62 · dooboolab/hackatalk-server</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*tajEEFpuOlFa2wPAzljUtg.png" /><figcaption>예제 데이터</figcaption></figure><p>예제 데이터(회원 테이블: users)를 5 row 만들었다.</p><p>createdAt을 <strong>Cursor</strong>로 활용할 것이다.</p><p>argument에 따른 <strong>Edge</strong> 제어는 아래와 같이 진행한다.</p><p><strong>Edge: Forward argument (first, after)</strong></p><ol><li><strong>after</strong> argument: 내림차순을 통해서 최신 가입 사용자가 가장 앞에 오도록 하고, after argument가 createdAt보다 작아야 after 이후에 가입한 사람들 리스트가 나올 것이다.</li><li><strong>first</strong> argument: 최신 가입 사용자를 내림차순으로 정렬 시킨 후 그 중에 first만큼의 row를 LIMIT 구문을 통해서 받아온다.</li></ol><p>아래 SQL문으로 1, 2번을 표현을 할 수가 있겠다.</p><pre>SELECT email, name, createdAt<br>FROM users<br>WHERE createdAt &lt; {after}<br>ORDER BY createdAt DESC<br>LIMIT {first}</pre><p><strong>Edge: Backward argument (last, before)</strong></p><ol><li><strong>before</strong> argument: Forward argument에서 사용하는 SQL문과 비슷하게 before 이전에 가입된 사용자를 받도록 한다.</li><li><strong>last</strong> argument: limit을 이용해서 last의 숫자대로 받아와야 하는데 복잡한 쿼리를 쓰지 않기 위해선 createdAt의 정렬을 오름차순으로 받아온다. 그래야 limit을 이용해서 last만큼의 데이터를 받아올 수 있기 때문이다.</li></ol><p>1, 2번에 대한 SQL문을 표현하자면 아래와 같다.</p><pre>SELECT email, name, createdAt<br>FROM users<br>WHERE createdAt &gt; {before}<br>ORDER BY createdAt ASC<br>LIMIT {last}</pre><p>그리고 이 결과 데이터를 다시 내림차순 시켜서 <strong>PageInfo</strong> 객체 생성에 쓰일 수 있도록 해야 한다. 헌데 이 부분을 SQL로 하자면 서브쿼리를 써야 하는데, 한번 쿼리를 더 감싸는 것이 O(n)에서 O(n²)가 되는 느낌이라 맘에 들지 않았다 (만약 제 생각이 틀렸다면 의견 부탁드려요 ㅠㅎ)</p><pre>SELECT T.email, T.name, T.createdAt<br>FROM <br>  (<br>    SELECT email, name, createdAt<br>    FROM users<br>    WHERE createdAt &gt; {before}<br>    ORDER BY createdAt ASC<br>    LIMIT {last}<br>  ) T<br>ORDER BY T.createdAt DESC;</pre><p>그래서 1,2번까지만 SQL을 활용하여 데이터를 받아 온 후, JS에서 createdAt을 기준으로 sort()를 하여 내림차순 정렬을 시켰다.</p><p><strong>PageInfo</strong> 구현은 forward든 backward든 argument가 무엇이 오든 간에 리턴하는 edge데이터를 기준으로 아래 사항들을 고려하여 로직을 짠다.</p><ul><li>현재 리턴시킬 데이터 이후의 데이터가 존재하는 지(<strong>hasNextPage</strong>)</li><li>현재 리턴시킬 데이터 이전의 데이터가 존재하는 지(<strong>hasPreviousPage</strong>)</li><li>현재 리턴시킬 데이터의 가장 첫번째 edge의 createdAt을 구한다(<strong>startCursor</strong>)</li><li>현재 리턴시킬 데이터의 가장 마지막 edge의 createdAt을 구한다(<strong>endCursor</strong>)</li></ul><p><strong>hasNextPage</strong>와 <strong>hasPreviousPage</strong>의 값을 얻어내기 위해 해당 users테이블의 가장 첫번째 데이터와 가장 마지막 데이터를 구해야 했다. 그래서 아래 SQL문을 이용하였다.</p><p><strong>가장 첫번째 데이터: SQL</strong></p><pre>SELECT createdAt<br>FROM users<br>WHERE<br>  users.createdAt &gt; {before} -- or users.createdAt &lt; {after}<br>  AND user.verified = true<br>ORDER BY createdAt <strong>ASC</strong> LIMIT 1;</pre><p><strong>가장 마지막 데이터: SQL</strong></p><pre>SELECT createdAt<br>FROM users<br>WHERE<br>  users.createdAt &gt; {before} -- or users.createdAt &lt; {after}<br>  AND user.verified = true<br>ORDER BY createdAt <strong>DESC</strong> LIMIT 1;</pre><p><strong>PageInfo 객체 생성 util 코드</strong></p><p><a href="https://github.com/geoseong/hackatalk-server/blob/30aa8cb80d6c81a6e648fe575bb30100d570a041/src/utils/pagination.ts">geoseong/hackatalk-server</a></p><h3>Extra: Inline Fragments에 대해서</h3><p>GitHub Developers API Explorer에서 pagination 쿼리를 실습 해 보기 위해 <strong>search() </strong>query 를 입력 했었다.</p><p>그런데 edges.node를 입력하는 과정에서 id를 쳐도, 어떤 것을 쳐도 자동완성의 결과는 항상 __typename 이었다.</p><p>graphql 초보인 나는 이게 대체 무슨 상황이지? 하면서 구글링을 한 결과 <strong>… on {TYPE}</strong> 을 이용해야 원하는 데이터를 얻을 수 있다는 것을 찾았다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*uqb7PwBBHUdOPxuoJc1pPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*D4SJwWRgCKpq8PMWjxaFGA.png" /><figcaption>Inline Fragments 구문</figcaption></figure><p>이 구문은 Inline Fragments라고 하며, interface나 union type을 쿼리할 때 쓰인다고 한다.</p><p><a href="https://graphql.org/learn/queries/#inline-fragments">GraphQL: A query language for APIs.</a></p><p>그리고 이것과 더불어서 내가 Inline Fragments를 사용하여 데이터를 리턴 받을 때, 여러 타입들이 합쳐진 데이터다 보니 이 데이터가 어떠한 스키마로부터 리턴되었는 지 모를 경우가 발생될 것이다.</p><p>이럴 때 <strong>__typename</strong>이라는 메타 필드를 이용하면 된다고 한다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*ABlg1MHl6PG4hwl8GK_2uw.png" /><figcaption>meta field: __typename</figcaption></figure><p><a href="https://graphql.org/learn/queries/#meta-fields">GraphQL: A query language for APIs.</a></p><h3>THE END</h3><p>이 글에 제안이나 잘못 된 점이 있다면 언제든지 의견 남겨주세요~!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72ab0daceed4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/prisma-korea/graphql-pagination-%EA%B5%AC%ED%98%84%ED%95%98%EA%B8%B0-relays-cursor-based-connection-pattern-72ab0daceed4">GraphQL Pagination 구현하기: Relay’s Cursor Based Connection Pattern</a> was originally published in <a href="https://medium.com/prisma-korea">Prisma Korea</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon Cognito로 시도 해 보는 다양한 방법의 소셜 로그인(Facebook, 카카오톡)]]></title>
            <link>https://medium.com/@parkopp/amazon-cognito%EB%A1%9C-%EC%8B%9C%EB%8F%84-%ED%95%B4-%EB%B3%B4%EB%8A%94-%EB%8B%A4%EC%96%91%ED%95%9C-%EB%B0%A9%EB%B2%95%EC%9D%98-%EC%86%8C%EC%85%9C-%EB%A1%9C%EA%B7%B8%EC%9D%B8-f81fa00b8c2e?source=rss-4ffa7246a983------2</link>
            <guid isPermaLink="false">https://medium.com/p/f81fa00b8c2e</guid>
            <category><![CDATA[awskrug]]></category>
            <category><![CDATA[amplify]]></category>
            <category><![CDATA[cognito]]></category>
            <category><![CDATA[kakao]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[taeseong park]]></dc:creator>
            <pubDate>Wed, 19 Feb 2020 18:02:59 GMT</pubDate>
            <atom:updated>2020-02-20T13:59:18.043Z</atom:updated>
            <content:encoded><![CDATA[<p>2020년 2월에 열린 <strong>AWSKRUG의 구로디지털 소모임</strong>에서 제가 발표한 내용에 대해서 내용을 좀 더 보강하여 정리 한 것을 이렇게 블로그로 공유해 보려고 합니다.</p><h3>AWSKRUG gudi 모임 소개</h3><p><a href="https://github.com/awskrug/gudi-group">awskrug/gudi-group</a></p><p>AWSKRUG의 지역 소모임 중에 하나인 구로디지털 소모임은 구로디지털단지 내의 모임공간에서 매달 셋째주 화요일마다 열리고 있습니다.</p><p>지역 소모임인 만큼 다른 AWSKRUG의 테마별 소모임(serverless, container, architecture, frontend 등..)과는 다르게 정해진 주제는 없습니다.</p><p>모임에 참가하시는 분들의 관심사에 따라 주제를 정해서 진행하고 있으며, 발표자 중심이 아닌 토론과 집단지성이 메인이 되는 분위기를 만들기 위하여 부단히 노력 중입니다 ㅎ</p><p>그만큼 편한 분위기를 조성하기 위해 노력중이며, 초심자나 처음 참가하시는 분들도 어색함을 느끼지 않도록 하게 하려는 것이 저희 모임의 목표입니다.</p><h4>AWSKRUG 에 참가하는 방법</h4><p>온라인으로는 Slack이 있고, 오프라인 모임은 meetup 플랫폼을 통해 이벤트를 주최 중입니다.</p><p><a href="http://slack.awskr.org/">AWSKRUG Slack 초대 링크</a></p><ul><li><strong>gudi</strong> 채널이 저희 구로디지털 소모임의 채널입니다.</li></ul><p><a href="https://www.meetup.com/ko-KR/awskrug/">AWSKRUG meetup 그룹</a></p><h3>Amazon Cognito?</h3><p>참고문서: <a href="https://docs.aws.amazon.com/ko_kr/cognito/latest/developerguide/what-is-amazon-cognito.html">Amazon Cognito란 무엇입니까?</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FOAR4ZHP8DEg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DOAR4ZHP8DEg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FOAR4ZHP8DEg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e1d5b3e8cdf242dc0745dbe142d39cf/href">https://medium.com/media/4e1d5b3e8cdf242dc0745dbe142d39cf/href</a></iframe><h4>첨부 영상에 대한 북마크</h4><p><a href="https://youtu.be/OAR4ZHP8DEg?t=249">OAuth 2.0 정의 설명(4:08)</a></p><p><a href="https://youtu.be/OAR4ZHP8DEg?t=300">OAuth, OIDC 설명(5:00)</a></p><p><a href="https://youtu.be/OAR4ZHP8DEg?t=388">OIDC 플로우(6:28)</a></p><p><a href="https://youtu.be/OAR4ZHP8DEg?t=475">JWT 개념 설명(7:55)</a></p><p><a href="https://youtu.be/OAR4ZHP8DEg?t=605">Cognito Overview(10:05)</a></p><ul><li><a href="https://youtu.be/OAR4ZHP8DEg?t=2100">Amazon Cognito 시나리오 흐름 설명 (35:00)</a><br>- IdP로 부터 redirect url, postback을 관리해줌</li><li>스크린샷으로 쓸만한 상세한 <a href="https://youtu.be/OAR4ZHP8DEg?t=2293">Cognito Overview (38:13)</a></li></ul><p><a href="https://youtu.be/OAR4ZHP8DEg?t=995">Hosted User Interface(16:35)</a></p><ul><li><a href="https://youtu.be/OAR4ZHP8DEg?t=1711">Hosted UI using OAuth flows(28:31)</a></li></ul><p><a href="https://youtu.be/OAR4ZHP8DEg?t=1003">Support for OAuth 2.0 in Cognito User Pools(16:43)</a></p><p><a href="https://youtu.be/OAR4ZHP8DEg?t=1126">Identity Federarion with user pools(18:46)</a></p><ul><li>스크린샷으로 쓸만한.. <a href="https://youtu.be/OAR4ZHP8DEg?t=1227">20:20</a></li></ul><p><a href="https://youtu.be/OAR4ZHP8DEg?t=1249">Cognito with SAML flow (20:49)</a></p><ul><li><a href="https://youtu.be/OAR4ZHP8DEg?t=1341">screenshot (22:21)</a></li></ul><p><a href="https://youtu.be/OAR4ZHP8DEg?t=1351">Comprehensive user flows(22:31)</a></p><p><a href="https://youtu.be/OAR4ZHP8DEg?t=1429">Lambda Trigger overview(23:49)</a></p><p><a href="https://youtu.be/OAR4ZHP8DEg?t=1543">Extensive admin capabilities(25:43)</a></p><p><a href="https://youtu.be/OAR4ZHP8DEg?t=2416">Demonstration (40:16)</a></p><p>Amazon Cognito는 쉽게 말해서 사용자 관리를 위한 서비스입니다.</p><p>두 가지 주요 구성 요소가 있는데 <strong>User Pool</strong>과 <strong>Identity Pool</strong>(예전에는 Federated Identity 라고 불렸었죠)이 있습니다.</p><h4>User Pool</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*GSUj2dZGw8OWsPRvwJH12g.png" /></figure><ul><li>사용자 디렉토리 용도로 사용<br>- 회원가입 된 사용자 정보는 Cognito 내의 데이터로 쌓이게 됩니다<br>- <strong>Group</strong>이란 단위로 사용 용도별로 묶어서 사용자 관리가 가능합니다.</li><li>소셜 로그인과 연계하여 회원 관리<br>- Amazon Cognito에서 내부적으로 간편하게 쓸 수 있도록 지원하는 Provider로는 Facebook, Google, Amazon, Apple등이 있고, 그 외에는 OpenID Connect와 SAML을 지원하고 있습니다.</li><li>사용자 로그인 웹 UI 지원</li><li>Multi Factor Authorization, SMS와 이메일로 인증번호 보내기 등의 보안기능</li><li>AWS Lambda Trigger<br>- Lambda Trigger 사용 예를 들자면, <strong>로그인 직전(Pre Authentication)에</strong> 자체 비즈니스 로직을 수행시킨다던 지, Cognito는 회원가입 요청 SignUp 이후 CONFIRMED 상태로 전환시키기 위한 이메일 혹은 SMS인증 과정이 필요한데, <strong>회원가입 요청 시(Pre sign-up)</strong>이러한 인증과정을 거치지 않고 바로 회원을CONFIRMED상태로 전환시키는 로직을 수행하는 등의 10가지의 시나리오 별로 Lambda 함수를 연결하여 구현 낼 수가 있습니다.</li></ul><p>이렇게 인증 과정을 거쳐서 회원 로그인을 하게 되면, <strong>JWT(JSON Web Token)</strong>을 발행하여 리턴을 시켜주며, 이 JWT를 이용하여 API Gateway 호출 시 Authorizer에 활용되거나 Amazon Cognito Identity Pool에 전달하여 AWS 리소스를 사용할 수 있는 권한으로 교환할 수도 있습니다.</p><h4>Identity Pool</h4><p>AWS 서비스 액세스 권한을 가지는 회원를 관리 해 줄 수 있습니다.</p><p>Identity Pool전용 회원관리도 가능하고, User Pool에 있는 회원과 연동해서 사용도 가능합니다.</p><p>이러한 Identity Pool에 회원이 로그인 되면, 그 회원의 액세스 레벨 안에서 AWS리소스에 접근 할 수가 있게 됩니다.</p><p>그리고 제가 발표하면서 한 참가자 분께서 Cognito뿐만 아니라, 회원 인증에 대하여 널리 쓰이고 있는 표준인 OAuth에 대한 개념에 대해서 먼저 짚었으면 좋았을 것 같다고 하셔서 OAuth에 대한 부연 설명 부분을 정리해 보았습니다.</p><h3>OAuth?</h3><p>OAuth 2.0은 일반적으로 인터넷 사용자가 웹 사이트나 응용 프로그램이 다른 웹 사이트의 정보에 액세스 할 수 있도록 암호를 제공하지 않고 액세스 할 수있는 권한으로 사용 되는 공개 표준입니다.</p><h4>OAuth는 API 또는 서비스가 아닙니다</h4><ul><li>2012 년 10 월에 승인을 위해 승인 된 공개 표준이며 모든 개발자가 이를 구현할 수 있습니다.</li></ul><h4>OAuth 흐름은 클라이언트 응용 프로그램에 “보안 위임 액세스”를 제공합니다.</h4><h4>액세스 토큰으로 인증</h4><ul><li>OAuth는 자격 증명이 아닌 액세스 토큰으로 장치, API, 서버 및 응용 프로그램을 인증합니다.</li></ul><p>제가 위의 Amazon Cognito를 소개했던 섹션에서 첨부한 영상에는 OAuth 뿐만 아니라 OIDC와 JWT에 대한 개념 설명도 하고 있습니다. 해당 설명으로 바로 갈 수 있는 좌표를 밑에 드리겠습니다</p><ul><li><a href="https://youtu.be/OAR4ZHP8DEg?t=249">OAuth 2.0 정의 설명(4:08)</a></li><li><a href="https://youtu.be/OAR4ZHP8DEg?t=300">OAuth, OIDC 설명(5:00)</a></li><li><a href="https://youtu.be/OAR4ZHP8DEg?t=388">OIDC 플로우(6:28)</a></li><li><a href="https://youtu.be/OAR4ZHP8DEg?t=475">JWT 개념 설명(7:55)</a></li></ul><h3>이번 시간에 다루게 될 것</h3><p>Amazon Cogito User Pool에 대해서만 다룰 것이고,</p><p>React 웹에서 Facebook 소셜 로그인을 통한 회원가입, 로그인 기능을 구현하며,</p><p>제가 한번 건드렸다가 쉽지 않은 여정이었던 카카오 소셜 로그인 구현을 해 보려고 합니다.</p><h3>프로젝트 만들기</h3><p>제가 React 웹을 사용하는 개발자인지라 간단한 웹 프로젝트를 만들기 위하여 create-react-app을 사용하여 프로젝트를 만들고,</p><p>웹 프로젝트 안에서 amplify 프로젝트를 만들어서 소셜 로그인 개발을 해 보려 합니다.</p><h3>AWS Amplify?</h3><p>AWS Amplify는 API(API Gateway&amp;Lambda, AppSync), Auth(Cognito), Storage(S3) 등의 서비스를 CloudFormation 기반으로 만들 수 있는 개발 플랫폼입니다.</p><p>Amplify는 CLI와 Framework으로 나뉘는데요,</p><p>Amplify CLI를 통해서 프로젝트를 Initialize하고 백엔드 리소스들을 구축 및 배포를 하며, Framework을 통해서 프론트엔드 로직에 Amplify 패키지를 설치하여 Amplify로 배포된 리소스를 코드로써 어렵지 않게 접근하여 사용할 수가 있습니다.</p><p>Amplify에 대해서는 제가 2020 AWS Community Day에서 발표한 자료가 있으니 관심 있으신 분들은 참고하시기 바랍니다.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2Fcyf4ogNCZpblEr&amp;display_name=SlideShare&amp;url=https%3A%2F%2Fwww.slideshare.net%2Fawskr%2Faws-community-day-2020-amplify&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2Ftrack-d-taeseongpark-amplifywithreactnative-200122053146-thumbnail-4.jpg%3Fcb%3D1579742373&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfec4391c04a891b8bffa2535b22636b/href">https://medium.com/media/dfec4391c04a891b8bffa2535b22636b/href</a></iframe><h3>Amplify로 Cognito 리소스 추가하기 &amp; Facebook 소셜 로그인 시도</h3><p>AWS Mobile 팀에 있는 <a href="https://github.com/dabit3"><strong>Nader Dabit</strong></a>이라는 분이 Amplify의 영상 튜토리얼 및 예제 코드들을 아주 활발히 올려주고 계신데, Facebook과 Google 소셜 로그인을 create-react-app React웹 프로젝트 생성과 Amplify 설치과정까지 담긴 튜토리얼 영상 또한 제공을 해 주셨습니다. 그래서 아래 영상으로 부가 설명을 대체합니다.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FF6ZPTKiEJx4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DF6ZPTKiEJx4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FF6ZPTKiEJx4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/016ab837feb62a52d45fa6e389ed04bb/href">https://medium.com/media/016ab837feb62a52d45fa6e389ed04bb/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FeqDUSY9KHYE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DeqDUSY9KHYE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FeqDUSY9KHYE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/46dc4c960a352d001d30587041dda6b8/href">https://medium.com/media/46dc4c960a352d001d30587041dda6b8/href</a></iframe><p>영상에서 실습을 다 마치고, Facebook으로 부터 날라오는 정보가 단순히 이메일만은 아닐 것인데.. 라고 생각이 들 건데, 이런 추가 유저 정보를 매핑 해 주는 설정을 추가로 해 주어야 합니다.</p><h4>Attribute mapping</h4><p>Amazon Cognito 웹 콘솔에 보시면 좌측의 Federation -&gt; Attribute mapping이 있는데요, 여기에서 Facebook에서 리턴하는 회원 정보들을 Cognito user pool의 attribute와 매핑을 시켜서 저장을 시키게끔 설정 할 수가 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LJYWtmXhSr2IzP4rT_YHOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*1Je3OBZaZ9UbkEEwQphKmg.png" /><figcaption>(좌) Attribute mapping / (우) General settings -&gt; Users and groups에서 추가된 사용자의 상태</figcaption></figure><p>이러한 과정이 Amplify CLI에서 제공이 되는 지 알아보았는데, 저는 찾지 못하였습니다.. 만약에 아시는 분이 있으시다면 슬랙에 남겨주시거나 여기에 댓글을 남겨주시는 등의 피드백 부탁드리겠습니다 🙇🏻‍♂️</p><h3>카카오톡 로그인 시도</h3><p>이 발표를 준비하면서 가장 공을 들였던 부분이 바로 카카오톡과 Cognito와의 연결입니다.</p><p>Amazon Cognito에서 제공하는 Provider 종류 중 OpenID와 SAML이 있으니 웬만한 소셜 로그인은 다 되겠지 라고 생각을 했지만, 카카오톡은 OpenID와 SAML을 지원하지 않았습니다..</p><p>사실 2017년 AWS Gaming On AWS행사에서 카카오톡 세팅에 대한 세션 및 자료가 있으나, 웹 콘솔에서 한땀한땀 리소스를 만드는 과정이 필요했기에 만약에 관련 리소스를 깨끗이 지우고 싶다면 내가 만들었던 리소스들을 역추적해 가며 지워야 하는 불편함이 있는 것이 사실입니다.</p><p><a href="https://github.com/bskim/gamingonaws2017_serverless#lab1-cognito%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%98%EC%97%AC-%EC%9D%B8%EC%A6%9D-%EC%97%B0%EB%8F%99%ED%95%98%EA%B8%B0">bskim/gamingonaws2017_serverless</a></p><p>그리하여 리소스 관리가 가능한 Amplify를 이용해서 REST API를 만들어서 그 안에서 카카오 소셜 프로바이더를 관리하는 코드를 만들도록 하겠습니다.</p><p>그래서 저는 카카오 소셜로그인을 프론트에서 해서 리턴받은 토큰 정보를 REST API로 보내서, API 내에서는 프론트에서 전달받은 토큰을 이용하여 카카오 REST API에 요청해서 받은 사용자 프로필 정보를 이용하여 AWS Cognito SDK을 활용한 회원가입을 이메일 인증 없이 시켜보는 작업을 해 보려고 합니다.</p><h4>카카오톡 소셜 회원가입 흐름</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*jKp7FLQeAHUjiKrzY8_Sqg.jpeg" /><figcaption>Amplify CLI로 리소스를 만들고, Amplify Framework으로 리소스 호출하고, Cognito Lambda Trigger에서 AWS-SDK CognitoUserPool을 이용하여 회원가입 시키기</figcaption></figure><h4>KAKAO 앱 만들기</h4><p>앱 등록은 아래 Kakao Developers 공식 문서를 보고 따라합니다.</p><p>여기서 한 가지 주의 하셔야 할 점은,</p><blockquote><strong>웹</strong> 플랫폼을 선택하고, <strong>사이트 도메인</strong> 을 등록합니다.</blockquote><p>부분에 <a href="http://localhost:3000/">http://localhost:3000</a> 을 추가합니다.</p><p>왜냐면 create-react-app에서 npm start를 하면 실행되는 서버의 url이 <a href="http://localhost:3000/">http://localhost:3000</a>이기 때문입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*Udcmic4ARDoY6LVhazNk4g.png" /><figcaption>카카오 앱에서 웹 플랫폼 추가</figcaption></figure><h4>React 프로젝트에서 Kakao API 추가하기</h4><p>KAKAO javascript SDK를 추가하는 작업은</p><p>public/index.html에서 kakao sdk를 import하는 &lt;script&gt; 태그를 넣어 주시고,</p><p>React js코드에서 componentDidMount나 useEffect부분에 sdk를 initialize를 해 주도록 합니다.</p><p>카카오 앱 키는 설정 -&gt; 일반에 들어가서 기본 정보 섹션에 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*XW-CvTHcTK9TObwzdxHtdQ.png" /><figcaption>카카오 앱 키 정보</figcaption></figure><h4>Amplify로 REST API 추가하기: 커맨드 입력</h4><p>이제 Amplify CLI를 이용해서 REST API를 만들어서 Lambda function을 구현 해 보겠습니다</p><p><strong>amplify add api</strong> 커맨드를 입력하면 여러 가지를 물어보는데, REST API중에서 express 템플릿을 선택하면 express 템플릿 코드가 자동완성 되어 있는 것을 확인할 수 있습니다. 참 편리해요..ㅎ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBHvDdS7UvjPVuqhqXlxKA.png" /></figure><h4>Amplify로 REST API 추가하기: axios로 KAKAO REST API 호출 후 AWS-SDK Cognito User Pool로 SignUp 시키기</h4><p>리액트 프로젝트에서 Kakao SDK로 login을 해서 받은 token들을 방금 저희가 Amplify로 만든 REST API에 전달하게 될 것이며, 그 token들을 받아서 처리하는 로직을 구현 해 보겠습니다.</p><ul><li>axios package 설치</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*VtjAyBFiV9WDniQWiUND0Q.png" /></figure><ul><li>1. axios로 KAKAO REST API 호출</li><li>2. AWS-SDK Cognito User Pool로 SignUp</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20156a8d9cb191c3363d38778b76bd69/href">https://medium.com/media/20156a8d9cb191c3363d38778b76bd69/href</a></iframe><p><strong>aws-exports.js?</strong></p><p>사실 Amplify 프로젝트를 React프로젝트 내에서 init할 때 설명했어야 하는 건데 Nader Dabit님이 영상으로 설명을 대체하다 보니 여기까지 와서 설명을 하게 되었네요 ㅎㅎ</p><p>Amplify CLI를 이용해서 추가되는 모든 리소스들의 credential한 정보들을 모아 놓은 집합소라고 보시면 됩니다.</p><p>또한 Amplify CLI에서 .gitignore 대상에 aws-exports.js 및 amplify민감 정보들을 알아서 추가해 주니 보안 상으로 방어를 잘 하고 있는 모습을 보여주고 있습니다.</p><p>그래서 이 안에 Cognito user pool정보, app client 정보, REST API endpoint 정보 들이 다 들어 있고, Amplify에서는 여기에 있는 정보를 이용해서 모든 작업이 이루어 지게 됩니다.</p><p>그래서 REST API코드를 보시면 UserPool과 ClientId를 그냥 하드코딩으로 넣었는데, 사실 프론트엔드에서 저 aws-exports.js파일을 import해 와서 전달하는 방법도 있습니다.</p><h4>Amplify로 REST API 추가하기: Cognito AWS-SDK 사용 권한 부여하기</h4><p>Amplify에서 REST API를 추가할 때 기본적으로 부여되는 IAM Role은 CloudWatch에 로그를 넣는 것 밖에 없어서 Cognito SDK에서 사용하는 signUp 사용권한 Role을 추가해 주어야 합니다.</p><p>그러기 위해서는 부득이하게 <strong>amplify/backend/function/kakaologin/kakaologin-cloudformation-template.json</strong>을 들어가서 CloudFormation문법을 조금 건드려야 합니다 😅</p><p>코드가 삽입된 위치는 <strong>Resources → lambdaexecutionpolicy → Properties → PolicyDocument → Statement</strong> 입니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbed0281958270084a18a6014d965162/href">https://medium.com/media/fbed0281958270084a18a6014d965162/href</a></iframe><h4>Lambda Trigger</h4><p>이제 Cognito에 SignUp메소드가 실행되는 순간 실행되는 <strong>Pre sign-up</strong> <strong>Lambda Trigger</strong>를 추가하고, Pre sign-up에서 이뤄지는 auto confirmation으로 인하여 실행되는 <strong>Post Confirmation</strong> <strong>Lambda Trigger </strong>리소스를 추가하고 코딩을 해 보겠습니다.</p><h4><strong>Amplify CLI로 Cognito Lambda Trigger 리소스 추가하기</strong></h4><p>Lambda Trigger 리소스를 추가하면서 “kakao”란 이름을 가진 Cognito User Group도 하나 만들어 봅시다. 회원 가입 시 Post Confirmation에서 “kakao” UserGroup에 자동으로 들어가게 하는 플로우를 상상하면서요.</p><p>이 작업은 <strong>amplify update auth</strong>를 통해서 실행 해 주어야 합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNVbbyFvcEaPjQg4lI6p3Q.png" /></figure><h4><strong>Lambda Trigger: Pre Sign-up</strong></h4><p>사용자가 회원가입을 하면 인증코드를 전송시키는 이메일이나 SMS가 원래 무조건 날아오는데요, 이것을 skip하기 위한 방법을 구글링을 통해서 먼저 접하게 되었는데요,</p><p><a href="https://stackoverflow.com/questions/47361948/how-to-confirm-user-in-cognito-user-pools-without-verifying-email-or-phone">How to confirm user in Cognito User Pools without verifying email or phone?</a></p><p>AWS Cognito 공식문서에도 나와 있으니 참고하세요.</p><p><a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-sign-up.html#aws-lambda-triggers-pre-registration-example">사전 가입 예제: 등록된 도메인의 사용자 자동 컨펌</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a7b6a2eaf97f026f69802f806ad7801/href">https://medium.com/media/6a7b6a2eaf97f026f69802f806ad7801/href</a></iframe><h4><strong>Lambda Trigger: Post Confirmation</strong></h4><p>방금 Ampilfy CLI로 Post Confirmation Lambda Trigger를 추가할 때 “Add to User Group”이라는 functionality를 선택했는데, Cognito AWS-SDK를 이용한 user group에 추가하는 메소드를 쓰는 코드 템플릿이 자동 완성됩니다. 따로 제가 신경써서 코딩할 것이 별로 없습니다..ㅎ</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42af675a779d2920d32e99695c749a94/href">https://medium.com/media/42af675a779d2920d32e99695c749a94/href</a></iframe><h4>AWS Cloud에 Auth, API 배포하기</h4><p>이제 Auth, API 리소스를 실제 AWS Cloud에 배포합니다.</p><p>Amplify CLI인 amplify push 를 통해서 Auth(Cognito)와 API(API Gateway &amp; Lambda)를 배포하게 됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*hng3AJf_-xdFJnwv7t0WcA.png" /></figure><h4>React 프로젝트에서 카카오 로그인 및 Cognito 회원가입 API 호출하기</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/beee790070d23b4f6e70c8a30eadb2a6/href">https://medium.com/media/beee790070d23b4f6e70c8a30eadb2a6/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d51d649dfaf8db267601dc8bef1ff34/href">https://medium.com/media/8d51d649dfaf8db267601dc8bef1ff34/href</a></iframe><p>이후에 터미널에서 <strong>npm start</strong>를 해서 페이지를 띄워 버튼을 눌러 잘 되나 시도 해 봅시다.</p><p>API호출이 끝나면 Cognito 웹 콘솔에서 이렇게 자동으로 회원이 추가되어 있고, amplify cli 를 통해 추가했던 “kakao” Group에 회원이 들어가 있으며, 별도 이메일 인증절차 없이 바로 CONFIRMED 상태인 걸 확인할 수가 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*0sVRVj0oZ6w8C4-lwrPT9A.png" /></figure><p>그리고 Amplify로 추가했던 REST API나 Cognito Lambda Trigger는 CloudWatch를 통해서 로그를 확인 하실 수 있습니다. console.log로 찍은 로그 말하는 겁니다 ㅎ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*BfzUErVcGb5mifiA6GEXYQ.png" /></figure><h3>카카오톡 소셜 로그인 &amp; 세션 관리 흐름</h3><p>아직 제가 구현 하진 않았지만, 이런 흐름으로 하면 되지 않을까 싶습니다.</p><p>Amplify Framework의 <strong>Auth.signIn()</strong> 메소드를 호출했을 때,</p><p>Cognito Lambda Trigger 중에 <strong>Pre Authentication</strong>을 이용하면, 로그인이 완료 되기 전에</p><ol><li>카카오의 REST API를 호출하여 access_token이나 refresh_token을 갱신</li><li>수정된 카카오의 token을 이용해서 회원 프로필을 받아오는 카카오 REST API를 호출하여 수정된 회원 정보를 받아옴</li><li>AWS-SDK의 Cognito를 이용하여 카카오 API로 부터 수정된 회원정보를 Cognito에 저장하는 로직을 구현</li></ol><h3>Coming Soon</h3><p>제가 Amplify &amp; Cognito &amp; 카카오 로그인 방법을 구현해 보면서 삽질을 여러번 해봤는데, 그 와중에 스터디했던 Lambda Trigger 중에 Custom Authentication Challenge Lambda Trigger라고 있습니다.</p><p>주로 사용되는 시나리오는 CAPTCHA 관련 동적인 질문을 구현하려 할 때 사용된다고 하는데요,</p><p>이 부분은 제가 사용하게 될 시나리오가 확보되면, 그리고 여러분들이 요청하신다면 한번 정리해 보도록 하겠습니다 ㅎ</p><p><a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-challenge.html">https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-challenge.html</a></p><p>그리고 추가로 제가 발표준비를 하면서 끄적였던 notion 페이지도 공유 드려보겠습니다 ㅎ</p><p><a href="https://www.notion.so/geoseong/Social-Login-in-various-ways-Using-Amazon-Cognito-6c27f0ef63ba4c9f8399d686f6cc6207">Social Login in various ways Using Amazon Cognito</a></p><h3>마치며.. 소감</h3><p>저는 실무에서 Cognito를 사용은 하고 있지만 Cognito에서 지원하는 다양한 기능을 적극적으로 활용하지 못하고 있었던 것이 사실인데, 발표 준비를 하면서 직접 여러 기능들을 경험 해 보고 나니까 시야가 넓어진 느낌이 들었고, 적어도 제가 다뤘던 User Pool에 있어서는 이제 어떻게 돌아가는 지 알겠다 라는 생각이 들면서 자신감이 조금 붙었다고 생각합니다.</p><p>또한 참가자 분들의 적극적인 참여 덕분에 제가 미스하고 있었던 Cognito의 세션 관리 구조, 개념 적인 부분들을 메꿔서 이런 내용을 공유하게 된 것에 대해 뿌듯합니다. ㅎㅎ</p><p>다른 참가자 분들도 이런 기회를 활용해서 저희 구디모임에서 발표하는 시간을 가지시어 자신의 경험 공유 및 집단지성의 힘을 빌어서 모르는 것에 대해 알아가시면 좋을 것 같습니다.</p><p>슬랙채널이나 저에게 간단한 주제라도 좋으니 발표신청 하시면 언제든 환영합니다.</p><p>그리고 발표자에게는 AWS 크레딧을 제공하고 있습니다 🎉</p><p>많은 참여 부탁드립니다~</p><p>감사합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f81fa00b8c2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[hackatalk-server 로컬 실행 환경 구축하기]]></title>
            <link>https://medium.com/prisma-korea/hackatalk-server-%EB%A1%9C%EC%BB%AC-%EC%8B%A4%ED%96%89-%ED%99%98%EA%B2%BD-%EA%B5%AC%EC%B6%95%ED%95%98%EA%B8%B0-84fa7768bfb8?source=rss-4ffa7246a983------2</link>
            <guid isPermaLink="false">https://medium.com/p/84fa7768bfb8</guid>
            <category><![CDATA[hackatalk-server]]></category>
            <category><![CDATA[hacktalk]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[taeseong park]]></dc:creator>
            <pubDate>Fri, 14 Feb 2020 08:07:50 GMT</pubDate>
            <atom:updated>2020-02-16T07:20:10.696Z</atom:updated>
            <content:encoded><![CDATA[<h3>Welcome to hackatalk-server !!</h3><p><a href="https://github.com/dooboolab"><strong>dooboolab</strong></a>에서 오프소스 프로젝트를 한창 진행 중인 모바일 앱 <strong>hackatalk</strong>의 <a href="https://github.com/dooboolab/hackatalk-mobile">hackatalk-mobile</a> 프로젝트에 이어 백엔드서버 또한 오픈소스 프로젝트로 진행하게 되었습니다. 🎉</p><p>이 포스팅에서는 <a href="https://github.com/dooboolab/hackatalk-server">hackatalk-server</a> 개발에 참여하고 싶으신 분들을 위하여 서버 배포 전 로컬에서 실행 환경을 구축하는 방법에 대해 공유드리고자 합니다.</p><blockquote>본론에 들어가기 앞서, 이전에 포스팅 된 <a href="https://medium.com/graphql-seoul/%EB%B2%88%EC%97%AD-%EC%95%84%ED%8F%B4%EB%A1%9C%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EA%B7%B8%EB%9E%98%ED%94%84-%ED%81%90%EC%97%98-%EC%84%9C%EB%B2%84-%EA%B5%AC%ED%98%84-70f5ae6d1ee6"><strong>[번역] 아폴로를 이용한 그래프 큐엘 서버 구현</strong></a><strong> </strong>을 읽어 보시고 오시면 hackatalk-server 프로젝트에 대한 이해도가 올라가실 거라고 생각합니다 👍</blockquote><h3>사전 준비 사항</h3><p>이미 준비가 되어 있으신 분들은 건너 뛰시면 됩니다.</p><h4>MySQL 설치</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*QG-oXCs2OlTsSTG_HzXCNg.png" /><figcaption>MySQL</figcaption></figure><p><a href="https://dev.mysql.com/downloads/mysql/">MySQL Community Downloads</a> 사이트에 들어가서 자신의 운영체제에 맞는 MySQL Community Server를 다운로드 받으세요.</p><p>설치 및 실행에 대한 자세한 방법은 아래 문서를 참고해 주시면 됩니다.</p><p><strong>mac OS X</strong></p><p>Installer로 설치 후 Control Panel에서 MySQL 서버를 켜는 법까지 가이드가 되어 있습니다.</p><ul><li><a href="https://dev.mysql.com/doc/refman/8.0/en/osx-installation-launchd.html">MySQL Documentation: Installing and Using the MySQL Launch Daemon</a></li></ul><p><strong>Windows</strong></p><p>MySQL 공식문서에는 Windows용 설치 스크린샷이 없고 각 옵션들에 대한 텍스트들만 있어서 읽기 불편할 것으로 생각합니다 ㅎ</p><p>그래서 아래의 공식 문서는 사실 보시는 게 제일 좋지만, MySQL을 사용 하시면서 읽어 보셔도 좋을 것 같습니다.</p><p>하여 한글로 된 포스팅을 링크 드리니, 참고 하시기 바랍니다.</p><ul><li><a href="https://dzzienki.tistory.com/10"><strong>윈도우 10에 MYSQL 설치 방법 Window 10 (2019. 01.24 최신)</strong></a></li></ul><p>Installer type으로 설치했다고 하면, 아래 문서를 참고하세요.</p><ul><li><a href="https://dev.mysql.com/doc/refman/8.0/en/mysql-installer-setup.html">MySQL Documentation: MySQL Installer Initial Setup</a></li></ul><p>ZIP으로 설치했다고 하면, 아래 문서를 참고하세요. 이 과정은 매뉴얼로 설정해야 하는 작업이 많아서 MySQL사이트에서도 추천하지는 않는 방법 같습니다 ㅎ</p><ul><li><a href="https://dev.mysql.com/doc/refman/8.0/en/windows-install-archive.html">MySQL Documentation: Installing MySQL on Microsoft Windows Using a </a><a href="https://dev.mysql.com/doc/refman/8.0/en/windows-install-archive.html">noinstall ZIP Archive</a></li></ul><p><strong>Other OS</strong></p><p>다른 운영체제에 대한 MySQL 설치방법은 <a href="https://dev.mysql.com/doc/refman/5.7/en/installing.html"><strong>MySQL Documentation: Installing and Upgrading MySQL</strong></a> 문서를 참고하세요.</p><h4><strong>DBeaver 설치</strong></h4><figure><a href="https://dbeaver.io/"><img alt="" src="https://cdn-images-1.medium.com/max/128/1*tGyJjP0MEj5Ck4Dq3uJJXw.png" /></a><figcaption>DBeaver</figcaption></figure><p><a href="https://dbeaver.io/"><strong>DBeaver</strong></a>는 오픈소스 데이터베이스 툴로써, 현재 MySQL, PostgreSQL, SQLite, Oracle, DB2 등 아주 다양한 종류의 데이터베이스를 지원하고 있습니다.</p><p>지금 포스팅에서는 DBeaver 사용을 안내 하고 있지만 필수적으로 사용해야 하는 것은 아닙니다. 사실 <a href="https://dev.mysql.com/doc/workbench/en/"><strong>MySQL Workbench</strong></a>가 MySQL에서 만든 데이터베이스 툴로써 가장 많이 알려져 있긴 하지만, mac OS에서는 매끄럽게 동작이 되지 않는 부분이 많아서 불편함을 느끼는 사용자가 많습니다. (저 포함해서요.. 복붙 키와 한/영 전환이 가끔 먹지 않는다던지, GUI가 좋지 않다던지…)</p><p><a href="https://dbeaver.io/download/">DBeaver Download</a> 페이지에 들어가서 Community Edition 섹션에 자신의 운영체제에 맞는 것으로 다운로드 받아서 설치 해 주세요.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hKFWIA2yhoiPRVoXeD73lQ.png" /><figcaption>DBeaver Download Page</figcaption></figure><h4>npm 설치</h4><p><a href="https://www.npmjs.com/get-npm">Introducing: get npm</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y5YLuOKO5XM7MOzve6XsDQ.png" /><figcaption>node.js with npm</figcaption></figure><p>node.js를 설치하면 npm도 함께 설치됩니다.</p><ul><li><a href="https://nodejs.org/en/">nodejs Download</a></li></ul><h4>yarn 설치</h4><p><a href="https://classic.yarnpkg.com/en/docs/getting-started">Introducing: yarn getting started</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*xEbvXkliodcMH9RyYdvCxQ.jpeg" /><figcaption>yarn</figcaption></figure><p>npm을 먼저 설치했다면, 터미널에서 아래 커맨드로 간단히 설치 가능합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*XOi1Kdcyh-TtonqZ2aUeNw.png" /><figcaption>yarn installation via npm</figcaption></figure><p><strong>yarn</strong>을 독립적으로 설치하시려면 아래 문서를 참고하시어 운영체제 별로 따라 하시면 되겠습니다.</p><ul><li><a href="https://classic.yarnpkg.com/en/docs/install">yarn installation</a></li></ul><h4>git 설치</h4><p>아래 문서 참고하시어 운영체제별로 설치하시기 바랍니다.</p><p><a href="https://git-scm.com/book/ko/v2/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-Git-%EC%84%A4%EC%B9%98">Git Documentation: 1.5 시작하기 — Git 설치</a></p><h3>hackatalk-server 프로젝트 세팅</h3><h4>코드 복사 및 패키지 설치</h4><ul><li>git 명령어를 이용하여 <a href="https://github.com/dooboolab/hackatalk-server"><strong>hackatalk-server</strong> github repository</a>로부터 로컬에 clone을 해 온 뒤,</li><li><strong>hackatalk-server</strong> 폴더로 들어가서,</li><li><strong>yarn</strong>명령어로 package.json에 명시된 dependencies, devdependencies들을 모두 설치 해 줍니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2SYV-SynWXxl7l5oXbCUuQ.png" /></figure><h4>환경변수(.env) 설정하기</h4><p>dotenv폴더 안에다가 .env 파일을 만들어 놓아야 하는데,</p><p>dotenv 폴더 안에 env 템플릿이 준비되어 있습니다.</p><p><strong>`test.env`</strong>가 저희가 사용할 대상입니다.</p><ol><li>새로 .env파일을 dotenv폴더 안에 만듭니다.</li><li>test.env 내용을 복사하여 <strong>.env</strong> 파일에 붙여넣습니다.</li><li><strong>.env</strong>파일 내용 중에 <strong>DB_USER</strong>, <strong>DB_PASSWORD</strong>, <strong>DB_DATABASE</strong> 부분을 자신의 기호대로 설정 해 줍니다.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*D-T34jWMQy-LmK8PQtVUFA.png" /><figcaption>.env</figcaption></figure><h3>MySQL 유저 추가하기</h3><p>.env에 정의한 <strong>DB_USER</strong>, <strong>DB_PASSWORD </strong>의 내용대로 사용자를 추가하는 작업을 진행 해 봅니다.</p><p>물론 MySQL 설치 시에 자동으로 만들어진 root계정으로 사용하고자 하신다면 이 단계는 건너뛰어도 됩니다.</p><h4>참고</h4><ul><li><a href="https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql">How To Create a New User and Grant Permissions in MySQL</a></li></ul><h4>mysql 접속하기</h4><ul><li>root 권한으로 접속하여 root 비밀번호를 입력해서 들어간다.</li></ul><pre>mysql -p</pre><h4>사용자 생성</h4><pre>CREATE USER &#39;<strong>hackatalk</strong>&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;{password}&#39;;</pre><h4>사용자에 사용권한 부여</h4><pre>GRANT {TYPE_OF_PERMISSION} ON <strong>hackatalk.*</strong> TO <strong>hackatalk</strong>@&#39;localhost&#39;;</pre><p><strong>참고: TYPE_OF_PERMISSION</strong></p><ul><li>ALL PRIVILEGES- as we saw previously, this would allow a MySQL user full access to a designated database (or if no database is selected, global access across the system)</li><li>CREATE: allows them to create new tables or databases</li><li>DROP: allows them to them to delete tables or databases</li><li>DELETE: allows them to delete rows from tables</li><li>INSERT: allows them to insert rows into tables</li><li>SELECT: allows them to use the SELECT command to read through databases</li><li>UPDATE: allow them to update table rows</li><li>GRANT OPTION: allows them to grant or remove other users’ privileges</li></ul><h4>사용자에 권한 부여 후 적용하기</h4><pre>GRANT ALL PRIVILEGES ON <strong>hackatalk.*</strong> TO <strong>hackatalk</strong>@&#39;localhost&#39;;<br>FLUSH PRIVILEGES;</pre><h4>생성한 유저의 권한 확인하기</h4><pre>SHOW GRANTS FOR hackatalk@localhost;</pre><h4>(삭제하고 싶다면,) 유저 삭제하기</h4><pre>DROP USER &#39;hackatalk&#39;@&#39;localhost&#39;;</pre><h4>나가기</h4><pre>quit</pre><h4>(테스트) 새로 생성한 사용자로 mysql 접속하기</h4><pre>mysql -u [username] -p</pre><h3>DBeaver에서 MySQL Connection 세팅하기</h3><p>이제 DBeaver를 실행해서 hackatalk-server를 위한 MySQL Connection을 생성 해 봅시다.</p><p><strong>Steps</strong></p><ol><li>Connection을 생성한다</li><li><strong>.env</strong>에서 정의했던 <strong>DB_DATABASE</strong> (e.g., hackatalk)에 있는 값으로 database를 만든다.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*G2JWNYSmeh6NtZ9uDISoDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*NsgjwYTFg4_oQ7JY6YVcaA.png" /><figcaption>step 1.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OE-Qkfr59CYoU4XfR1YKhQ.png" /><figcaption>step 1.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*RFCGq4DAJak_dd2P9Kjt6g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*123DZfERFlf7o7HVZul9LA.png" /><figcaption>step 2.</figcaption></figure><h3>hackatalk-server 프로젝트 실행하기</h3><p>프로젝트로 돌아와서 <strong>$ yarn local</strong> 스크립트를 입력하면 MySQL 스키마가 로컬에 자동으로 생성되면서 서버가 실행됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZG9WIDIJK9rOb0S8fA-JQ.png" /><figcaption>yarn local</figcaption></figure><p>서버가 정상적으로 켜졌다면, <strong>DBeaver</strong>에 가서 테이블들이 잘 생성되었는 지 확인 해 봅니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*NRHu49omBAZtO9TQd5gVlw.png" /><figcaption>after hackatalk-server local server running</figcaption></figure><p>또한 graphql 서버가 잘 켜졌는 지 <strong>http://localhost:4000/graphql</strong>에 들어가서 확인 해 봅니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-wmnRCb2LGhIbl3VEtpkQ.png" /><figcaption>localhost graphql server</figcaption></figure><h3>This is just beginning 🏃🏻‍♀️</h3><p>이로써 로컬에서 hackatalk-server 프로젝트를 실행하는 방법에 대해 알아봤습니다.</p><p>아직 프로젝트가 시작 단계이기 때문에 추후 데이터베이스 구조 변경 사항에 대한 migration 방법, graphql resolver 등에 대한 완전한 기획이 나온 사항이 아니기 때문에 관심 있으신 분이라면 아래 슬랙 채널에서 같이 의논 해 보면서 만들어 나갔으면 합니다.</p><ul><li><a href="https://dooboolab.com/joinGraphQLSeoul">Graphql-Seoul Slack Invitation link</a></li></ul><p>Github issue, PR 모두 환영합니다. 새로운 기술 도입도 언제든 환영합니다.</p><p>관심 있으신 분들의 많은 참여 바랍니다.</p><p>감사합니다 🙇🏻‍♂️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84fa7768bfb8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/prisma-korea/hackatalk-server-%EB%A1%9C%EC%BB%AC-%EC%8B%A4%ED%96%89-%ED%99%98%EA%B2%BD-%EA%B5%AC%EC%B6%95%ED%95%98%EA%B8%B0-84fa7768bfb8">hackatalk-server 로컬 실행 환경 구축하기</a> was originally published in <a href="https://medium.com/prisma-korea">Prisma Korea</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hackatalk-mobile 살펴보기 — Configuration]]></title>
            <link>https://medium.com/crossplatformkorea/hackatalk-mobile-%EC%82%B4%ED%8E%B4%EB%B3%B4%EA%B8%B0-configuration-d96288dff48d?source=rss-4ffa7246a983------2</link>
            <guid isPermaLink="false">https://medium.com/p/d96288dff48d</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[dooboolab]]></category>
            <dc:creator><![CDATA[taeseong park]]></dc:creator>
            <pubDate>Sun, 24 Nov 2019 13:59:21 GMT</pubDate>
            <atom:updated>2020-03-22T15:56:25.217Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hackatalk-mobile 살펴보기 — Configuration</h3><h3>안내사항</h3><blockquote>2020년 3월 현재 hackatalk-mobile 가 expo 프로젝트에서 eject되어 react-native 프로젝트로 변경되어 아래 내용과 설정이 많이 상이한 상태이니 혼돈이 없으시길 바라며, 아래 포스팅 내용은 2019년 11월 기준 <a href="https://github.com/dooboolab/hackatalk-mobile/tree/design-1"><strong>hackatalk-mobile design-1</strong></a>버전으로 작성 되었습니다.</blockquote><p>현재 <a href="https://www.meetup.com/ko-KR/react-native-seoul"><strong>react-native-seoul meetup</strong></a>에서 오픈소스 프로젝트가 한창 진행중에 있습니다.</p><p>제가 현재 참여하고 있는 오픈소스 프로젝트이기도 하지만, 머릿속 정리도 할 겸 이 글을 작성하게 되었고, 이 글을 통하여 <a href="https://github.com/dooboolab/hackatalk-mobile"><strong>hackatalk-mobile</strong></a> 프로젝트를 하고 계신분, 그리고 참여해 보려고 하시는 분들 또한 도움이 되었으면 하는 바램입니다.</p><p>이번 포스팅에서는 <strong>hackatalk-mobile</strong> 구조 이해에 도움이 되는 설정파일들을 한번 쭉 훑어보려고 합니다.</p><h3>Configuration 관련 파일</h3><p>우선 첫번째 시간으로 configuration 파일들을 한번 훑어보려고 합니다.</p><h4>app.json</h4><p><a href="https://docs.expo.io/versions/v35.0.0/workflow/configuration/">Configuration with app.json</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db030df3a2a85902fb6b87dd1b256e92/href">https://medium.com/media/db030df3a2a85902fb6b87dd1b256e92/href</a></iframe><p>앱 이름, sdk버전, 플랫폼(ios/android/web), orientation(가로/세로), 스플레쉬 스크린 설정 등의 <strong>Expo Manifest</strong>에 대한 정보들을 넣어놓는 곳입니다.</p><p><strong>app.json</strong>에 입력된 대부분의 정보는 소스코드에서 <a href="https://docs.expo.io/versions/v35.0.0/sdk/constants/#expoconstantsmanifest"><strong>Constants.manifest</strong></a>를 통하여 접근이 가능합니다.</p><p>Expo Manifest 외의 자신만의 커스텀한 변수를 넣고 싶다면, <strong>extra</strong>키 안에 값들을 넣어 놓고, 소스코드에서 <strong>Constants.manifest.extra</strong>로 접근하면 됩니다.</p><p><em>hackatalk-mobile에서의 쓰임</em>은, <strong>README.md</strong> 의 <a href="https://github.com/dooboolab/hackatalk-mobile/tree/design-1#appjson"><strong>app.json 섹션</strong></a>에 세팅법이 나와 있으니 참고하시기 바랍니다.</p><blockquote>프로젝트를 처음 세팅하시는 분이라면 <strong>app.sample.json</strong>파일을 복제하여 <strong>app.json</strong>로 이름을 변경하여 사용하세요.</blockquote><p><a href="https://github.com/dooboolab/hackatalk-mobile#appjson">dooboolab/hackatalk-mobile</a></p><h4>rn-cli.config.js</h4><p>expo 디버깅을 위한 프로젝트를 시작하게 되면 웹브라우저에 새로 뜨는 페이지가 바로 <a href="https://facebook.github.io/metro/"><strong>Metro Bundler</strong></a>인데, facebook에서 개발한 React-Native용 Javascript Bundler라고 합니다.</p><p><a href="https://facebook.github.io/metro/docs/en/configuration">Configuring Metro · Metro</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kuQ6CW8lwrbBD_ZGON8shA.png" /><figcaption>Metro Bundler</figcaption></figure><p>현재 <strong>hackatalk-mobile</strong>에서 이러한 Metro Bundler 설정을 <strong>rn-cli.config.js</strong>에서 하게 되는데,</p><p><strong>metro config</strong>를 건드리는 목적은, <strong>svg</strong>확장자를 가진 이미지파일을 expo에서 사용하기 위함입니다.</p><p><a href="https://github.com/facebook/metro/blob/master/packages/metro-config/src/defaults/defaults.js#L14-L44"><strong>기본 metro-config에서 지원되는 assetExts 확장자 목록</strong></a>에서 보면 svg가 포함 되어 있지만, <strong>svg</strong>를 사용하기 위해서는 <strong>assetExts</strong>에 있는 <strong>svg</strong>를 없애고, <strong>sourceExts</strong>에 <strong>svg</strong>를 추가하는 설정을 하게 됩니다.</p><p>그리고 추가로 svg를 사용하려고 하면 한 가지 더 마무리 되어야 할 설정이 있는데, <strong>app.json</strong>에 아래처럼 코드를 넣는 것입니다.</p><pre>{<br>  “expo”: {<br>    “config”: “./rn-cli.config.js”,<br>    “packagerOpts”: {<br>      &quot;sourceExts&quot;: [&quot;js&quot;, &quot;jsx&quot;, &quot;ts&quot;, &quot;tsx&quot;, &quot;svg&quot;]<br>    }<br>  }<br>}</pre><p>이렇게 하면 svg파일을 소스코드파일 import하듯이 사용할 수 있습니다.</p><p>이러한 과정은 <strong>react-native-svg-transformer</strong>의 Documentation에 나와 있습니다.</p><p><a href="https://github.com/kristerkari/react-native-svg-transformer#installation-and-configuration">kristerkari/react-native-svg-transformer</a></p><h4>environment.d.ts</h4><p>이 설정 파일은 typescript 설정파일인 <a href="https://github.com/dooboolab/hackatalk-mobile/blob/design-1/tsconfig.json"><strong>tsconfig.json</strong></a>에서 참고하는 파일입니다.</p><p>hackatalk-mobile에서 주로 사용하는 목적은 png파일과 svg파일을 가진 확장자 등을 typescript안에서 import구문으로 가져다 쓰기 위함입니다.</p><p>typescript의 declare module에 대한 설명은 아래 Typescript Document를 참고하시기 바랍니다.</p><p><a href="https://www.typescriptlang.org/docs/handbook/modules.html#working-with-other-javascript-libraries">Guidance for structuring modules #</a></p><p>특히 svg에 대한 설정은 아까 metro config에서 보았던 <strong>react-native-svg-transformer</strong>의 영향을 받았습니다.</p><p><a href="https://github.com/kristerkari/react-native-svg-transformer#using-typescript">kristerkari/react-native-svg-transformer</a></p><h4>__mocks__/</h4><p>이 폴더 및 파일의 설정 또한 <strong>react-native-svg-transformer</strong>의 영향을 받았습니다.</p><p>jest 테스트 코드를 짤 때 mocking을 하기 위한 설정입니다.</p><p>아래 링크된 문서의 내용을 더 내려보시다보면 <strong>jest.config.js</strong> 파일의 옵션도 건드리고 있으니 참고 하시기 바랍니다.</p><p><a href="https://github.com/kristerkari/react-native-svg-transformer#usage-with-jest">kristerkari/react-native-svg-transformer</a></p><h4>babel.config.js</h4><pre>module.exports = {<br>  presets: [‘babel-preset-expo’, ‘@babel/preset-typescript’],<br>  sourceMaps: ‘inline’,<br>  plugins: [<br>    [<br>      ‘@babel/plugin-transform-runtime’,<br>      {<br>        helpers: true,<br>        regenerator: false,<br>      },<br>    ],<br>    ‘@babel/proposal-object-rest-spread’,<br>    [‘babel-plugin-styled-components’],<br>  ],<br>};</pre><p><a href="https://github.com/expo/expo/blob/master/packages/babel-preset-expo/README.md"><em>babel-preset-expo</em></a>는 지금 아래 나열할 기능들을 사용하기 위해 쓰입니다.</p><ul><li><strong>Tree-Shaking</strong>(<em>사용하지 않는 코드를 제거함으로써 번들 용량을 줄이는 방식)</em></li><li><strong>expo 웹 프로젝트</strong>에 필요한 설정</li><li><strong>decorator</strong>지원</li><li>네이티브 dependency가 필요할 수 있는 <strong>font icon</strong></li></ul><p><a href="https://babeljs.io/docs/en/babel-preset-typescript"><em>@babel/preset-typescript</em></a>는 <strong>@babel/plugin-transform-typescript</strong> 플러그인을 포함하고 있으며, <strong>typescript</strong>코드를 빌드 시 js 코드로 번들링 가능하도록 하기 위해 쓰입니다.</p><p><strong>플러그인</strong>은 프로젝트를 하면서 개발과 테스트코딩의 편의를 위한 플러그인들을 유동적으로 추가하고 없애고 있습니다.</p><ul><li><a href="https://babeljs.io/docs/en/babel-plugin-transform-runtime">@babel/plugin-transform-runtime</a> : 바벨에 의해 주입된 헬퍼 코드들이 재사용되게 해줌으로써 코드사이즈를 줄여주기 위한 다양한 옵션을 제공해 줍니다.</li><li><a href="https://babeljs.io/docs/en/babel-plugin-proposal-object-rest-spread">@babel/proposal-object-rest-spread</a> : ES문법 중 Spread연산자를 사용할 수 있게 해줍니다.</li><li><a href="https://github.com/styled-components/babel-plugin-styled-components">babel-plugin-styled-components</a> : 알아볼 수 있는 클래스명 제공, 서버사이드 렌더링 호환성, 조그만 번들러 용량 등의 기능을 제공하는데, styled-components 에서 사용하라고 추천하는 플러그인입니다.</li></ul><h4>config.ts</h4><p>현재는 Google 소셜 로그인을 위한 설정파일로 쓰이고 있습니다.</p><p><em>hackatalk-mobile에서의 쓰임</em>은, <strong>README.md</strong> 의 <a href="https://github.com/dooboolab/hackatalk-mobile/tree/design-1#configts"><strong>config.ts 섹션</strong></a>에 세팅법이 나와 있으니 참고하시기 바랍니다.</p><blockquote>프로젝트를 처음 세팅하시는 분이라면 <strong>config.sample.ts</strong>파일을 복제하여 <strong>config.ts</strong>로 이름을 변경하여 사용하세요.</blockquote><p><a href="https://github.com/dooboolab/hackatalk-mobile#configts">dooboolab/hackatalk-mobile</a></p><h4>.eslintrc.js &amp; .prettierrc.js</h4><p>eslint와 prettier등을 vscode와 함께 활용하면 개발할 때 쉽게 발견하기 힘든 오타/구문에러, 코드 포멧팅 등을 편하게 함으로써 개발 생산성을 향상시킬 수가 있는데요, eslint, prettier &amp; sort-imports 익스텐션에 대한 설정법은 <a href="https://medium.com/u/c82b036b5e6f">DongKyun Ko</a>님이 dooboolab medium에 올린 <a href="https://medium.com/dooboolab/using-eslint-prettier-and-sort-imports-vscode-extensions-for-formatting-open-source-project-16edf317129d"><strong>Using eslint, prettier and sort-imports vscode extensions for formatting Open Source Project ‘HackaTalk’</strong></a><strong> </strong>포스팅을 참고 바랍니다.</p><p>이렇게 <strong>hackatalk-mobile</strong>프로젝트의 <strong>Configuration</strong>들을 한번 훑어 보았습니다. react-native부터 typescript, babel, expo 에 이르기까지 수많은 세팅들이 복잡하게 얽혀있는 것은 사실이나, 이것들이 시너지 효과를 내어 최상의 퍼포먼스와 최소한의 앱 용량을 낼 수 있도록 도와주는 것들이니 익히는 수 밖에 없을 것 같습니다 😭</p><p>잘못된 점이나 수정이 필요한 부분이 있다면 언제든지 코멘트 남겨주시기 바랍니다.</p><p>감사합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d96288dff48d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/crossplatformkorea/hackatalk-mobile-%EC%82%B4%ED%8E%B4%EB%B3%B4%EA%B8%B0-configuration-d96288dff48d">Hackatalk-mobile 살펴보기 — Configuration</a> was originally published in <a href="https://medium.com/crossplatformkorea">Cross-Platform Korea</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[hackatalk-mobile 오픈소스 프로젝트에 참여하세요!: React-Native-Seoul 커뮤니티]]></title>
            <link>https://medium.com/crossplatformkorea/talktalk-%EC%98%A4%ED%94%88%EC%86%8C%EC%8A%A4-%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8%EC%97%90-%EC%B0%B8%EC%97%AC%ED%95%98%EC%84%B8%EC%9A%94-react-native-seoul-%EC%BB%A4%EB%AE%A4%EB%8B%88%ED%8B%B0-3bac10321991?source=rss-4ffa7246a983------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bac10321991</guid>
            <category><![CDATA[dooboolab]]></category>
            <category><![CDATA[react-native-seoul]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[taeseong park]]></dc:creator>
            <pubDate>Wed, 24 Apr 2019 13:59:07 GMT</pubDate>
            <atom:updated>2020-02-23T16:37:19.667Z</atom:updated>
            <content:encoded><![CDATA[<h3>hackatalk-mobile 오픈소스 프로젝트에 참여하세요!: React-Native-Seoul meetup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*278MeRxJEt_a-d_djWD-9w.gif" /><figcaption><strong>hackatalk-mobile</strong></figcaption></figure><p><a href="https://www.meetup.com/ko-KR/react-native-seoul/"><strong>React-Native-Seoul Meetup</strong></a> 에서 진행 중인 오픈소스 프로젝트 <a href="https://github.com/dooboolab/hackatalk-mobile"><strong>hackatalk</strong></a>을 소개합니다.</p><p>저희 커뮤니티의 목적은, React-Native에 관심 있는 사람, Skill-Up을 하고 싶은 사람들에게 지식을 공유하고, 어느정도 실력이 쌓이면, 입문자에게 자신의 지식을 공유하는 자율참여 선순환의 기능을 가지려는 것이 저희 커뮤니티의 궁극적인 목표입니다.</p><p>현재 모바일 앱은 <a href="https://github.com/dooboolab/hackatalk-mobile"><strong>hackatalk-mobile</strong></a> Github Repository를 통하여 구현을 하고 있으며, 아래의 스펙을 가져가려 하고 있습니다.</p><blockquote><a href="https://reactjs.org/docs/hooks-intro.html">react hooks</a></blockquote><blockquote><a href="https://reactnavigation.org/">react-navigation</a></blockquote><blockquote><a href="https://github.com/Microsoft/TypeScript">typescript</a></blockquote><blockquote><a href="https://www.styled-components.com/">styeld-components</a></blockquote><blockquote><a href="https://github.com/stefalda/ReactNativeLocalization">localization</a></blockquote><blockquote><a href="https://github.com/kulshekhar/ts-jest">ts-jest</a></blockquote><blockquote><a href="https://www.apollographql.com/docs/react">apollo-client</a></blockquote><blockquote><a href="https://github.com/oblador/react-native-animatable">react-native-animatable</a></blockquote><blockquote><a href="https://testing-library.com/docs/native-testing-library/intro">@testing-library/react-native</a></blockquote><blockquote><a href="https://react-hooks-testing-library.com/">@testing-library/react-hooks</a></blockquote><p>오픈소스 참가대상은 <strong>React-Native를 배우고자</strong>, <strong>Git으로 협업하는 연습을 하고자</strong> 하시는 의지가 있으신 여러분 누구나 환영합니다.</p><p>저희 React-Native-Seoul Meetup은 2017년 9월부터 시작하여 서울에서 현재 1달에 1~2회씩 정기적으로 오프라인 모임을 가지고 있습니다.</p><p>세미나 방식으로도 진행 해보고, 핵 나이트<em>(자신의 프로젝트에 대해 공유하고 자유롭게 코딩하는 시간)</em> 등 여러가지 시도들을 하면서 지금까지 활성화 상태를 유지하고 있습니다.</p><p>저는 2018년 5월 즈음부터 여러번 밋업을 참가하면서 느낀 점은, 아직까지 우리나라에서 React-Native 오프라인 밋업이 그렇게 활성화가 되고 있지는 않은 것 같습니다. 😅</p><p>아마도 참가하기에는 야근이 있으시거나, 자신에게 주어진 일들 때문에 심적 여유가 없으셔서, 그리고 혹여나 나에게 발표를 시키지는 않을까? 등의 이유가 클 것이라 생각합니다. 🤪</p><p>특히 조금만 기술적인 난이도가 있는 주제로 밋업을 주최하면, 참가하시는 분들이 눈에 띄게 감소하는 것을 확인 할 수 있었습니다 😂</p><p>그래서 참가하는 멤버들이 모두 같이 Skill-Up을 같이 해 나가자 라는 의미에서 오픈소스 활동을 시작하게 되었습니다.</p><p>가벼운 마음으로 참가하셔서 같이 오픈소스 활동에 대해서 배우고, 같이 활동하면서 네트워킹과 실력을 같이 쌓아가고, 영어가 되신다면 해외취업의 기회의 발판도 삼으실 수 있는 기회의 장을 함께 만들어갔으면 합니다 🎉</p><p>소통채널은 아래와 같이 열려 있으니 자유롭게 참여해 보아요~</p><blockquote><a href="https://www.meetup.com/ko-KR/react-native-seoul/"><strong>Meetup - 리액트 네이티브 서울</strong></a></blockquote><blockquote><a href="https://www.youtube.com/channel/UCy0YwPrjRbcmb4A110xx4zg/featured"><strong>YouTube Channel - 두부랩</strong></a></blockquote><blockquote><a href="https://reactnativeseoul.org/"><strong>Forum - react-native-seoul</strong></a></blockquote><blockquote><a href="https://join.slack.com/t/reactnativeseoul/shared_invite/enQtMjY4ODI2OTgzNzE0LWQ1ZDA4Mjk3ZjNmNjZjNjYyMzEwMDVhNGJjNDJlMGVhYmI1Y2M5Y2JmMDQ5MTMwMTFiNTUyOTcxZmQwNGRjMmE"><strong>Slack - React-Native-Seoul 채널 초대링크</strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bac10321991" width="1" height="1" alt=""><hr><p><a href="https://medium.com/crossplatformkorea/talktalk-%EC%98%A4%ED%94%88%EC%86%8C%EC%8A%A4-%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8%EC%97%90-%EC%B0%B8%EC%97%AC%ED%95%98%EC%84%B8%EC%9A%94-react-native-seoul-%EC%BB%A4%EB%AE%A4%EB%8B%88%ED%8B%B0-3bac10321991">hackatalk-mobile 오픈소스 프로젝트에 참여하세요!: React-Native-Seoul 커뮤니티</a> was originally published in <a href="https://medium.com/crossplatformkorea">Cross-Platform Korea</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>