1 minute read

오늘 배운 것


1. 원격 graphql endpoint로부터 graphql schema 가져오기

상당히 애먹었다. prisma를 쓰는 것이 아니라, graphql-cli를 설치하여 graphql get-schema명령을 사용해야 한다. 이걸 하고 나서도 직접 endpoint등 설정 파일을 작성하여 실행하려 해봤지만 계속 Implication failed오류 또는 token is invalid오류가 나며 실패했다. 결국 예전의 react-apollo 튜토리얼의 코드 구조를 복사해다가 몇 번 시도한 끝에 성공했다. graphql get-schema --all을 사용하여 .graphqlconfig.yml에 설정된 모든 endpoint들의 schema를 가져올 수 있다. 다만 prisma의 endpoint로부터 가져올 때 prisma.yml이 자동으로 변형되는데, 이 변형된 파일로는 yarn dev 명령어가 실패한다. 그래서 graphql get-schema명령을 수행한 후 다시 ctrl-z를 눌러 복구시켜야 한다. 뭐 이모양이냐..

수행 절차 :

  1. yarn global add graphql-cli로 graphql-cli 설치.
  2. .graphqlconfig.yml 파일 작성. endpoint 등 설정한다.
  3. graphql get-schema --all로 모든 endpoint에 대한 스키마 읽어오기.
  4. 변경된 prisma.yml 파일 되돌리기

2. graphql server 포트 지정하기

이상하게 아무리 포트를 설정하고 바꿔도 endpoint 포트가 4000일 때 빼고는 playground에서 network fetch도 안되고, 에러가 뜬다.

3. codeforces 485

C번 문제를 하다 잠듬..

#include <bits/stdc++.h>
#include<iostream>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi acos(-1)
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll i,j,k;
    ll ara[n],ara1[n];
    for(i=0;i<n;i++) cin>>ara[i];
    for(i=0;i<n;i++) cin>>ara1[i];
    ll ans=LLONG_MAX;
    for(i=0;i<n;i++)
    {
        ll min1=LLONG_MAX;
        ll min2=LLONG_MAX;
        int cnt=0,cnt1=0;
        for(j=0;j<i;j++)
        {
            if(ara[j]<ara[i]){
                min1=min(min1,ara1[j]);
                cnt=1;
            }
        }
        for(j=i+1;j<n;j++)
        {
            if(ara[j]>ara[i]){
                min2=min(min2,ara1[j]);
                cnt1=1;
            }
        }
        if(cnt && cnt1){
                ans=min(ans, min1+min2+ara1[i]);
        }
    }
    if(ans>300000000 || ans<=0) cout<<-1<<endl;
    else
    cout<<ans<<endl;
}

dep

ref


Comments