Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

err #1

Open
tmk3s opened this issue Nov 12, 2023 · 4 comments
Open

err #1

tmk3s opened this issue Nov 12, 2023 · 4 comments

Comments

@tmk3s
Copy link
Owner

tmk3s commented Nov 12, 2023

Failed to build a GraphQL list result for field Employee.gender at path employees.0.gender.\nExpected \"female\" (String) to implement .each to satisfy the GraphQL return type [Gender!].\n

field :gender, [Types::GenderType], null: true, description: '性別' => NG
field :gender, Types::GenderType, null: true, description: '性別' => OK

query
query{
  employees{
    id
    gender
    code
    last_name
  }
}


{
  "errors": [
    {
      "message": "Field 'last_name' doesn't exist on type 'Employee'",
      "locations": [
        {
          "line": 9,
          "column": 5
        }
      ],
      "path": [
        "query",
        "employees",
        "last_name"
      ],
      "extensions": {
        "code": "undefinedField",
        "typeName": "Employee",
        "fieldName": "last_name"
      }
    }
  ]
}

module Types
class EmployeeType < Types::BaseObject
description "従業員"
field :id, ID, null: false
field :company_id, ID, null: false, description: '会社ID'
field :code, String, null: false, description: '従業員番号'
field :last_name, String, null: false, description: '姓'

last_nameはあるが。。NG

query
query{
  employees{
    id
    gender
    code
    lastName =>キャメル式!!!にすればOK
  }
}

モジュール 'front/components/setting/Layout.tsx' またはそれに対応する型宣言が見つかりません。ts(2307)
=>
tsconfigは下記のように全部指定になっているので、

   "paths": {
      "@/*": ["./*"]
    }
  },

import Layout from '@/components/setting/Layout';
こんな感じでかけばOK

export default function Home() {
  const [edit, setEdit] = useState(false);
  const { loading, error, data } = useQuery(GET_COMPANY);

  console.log(data?.company)
  return (
    <main>
      <Layout children={
        <>
          <h1 className='text-3xl font-bold'>会社情報</h1>
          <p className='mt-5'>会社の基本情報の確認や編集ができます。</p>
          <h2 className='text-2xl mt-5'>基本情報</h2>
          <button className="favorite styled" type="button" onClick={() => setEdit(true)}>編集</button>
          <div className='mt-5 w-full outline rounded-md outline-1 outline-gray-300 bg-slate-50 shadow-md lg:grid lg:grid-cols-2 lg:gap-4'>
            { loading ? (
              <p>読み込み中です・・</p>
            ) : (
              <>
                { edit ? (
                  <Edit company={data?.comapny}/>
                ) : (
                  <Show company={data.comapny}/>
                )}
              </>
              
            )
          }
          </div>
        </>
      }/>
    </main>  
  )
}
  

この部分で指定しているがundifiendになる

comapny=>NG
正しくはcompanyなのでただのtypo!!

https://chusotsu-program.com/vercel-do-not-pass-children/ =>ずみ


npm install @graphidocs/docs --save-dev

 ./node_modules/.bin/graphidocs -h
node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module '/Users/XXXXX/workspace/d-eins-erp/.doc/node_modules/@graphidocs/docs/package.json'
Require stack:
- /Users/XXXXX/workspace/d-eins-erp/.doc/node_modules/@graphidocs/docs/src/lib/command.js
- /Users/XXXXX/workspace/d-eins-erp/.doc/node_modules/@graphidocs/docs/bin/graphidocs.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/Users/XXXXX/workspace/d-eins-erp/.doc/node_modules/@graphidocs/docs/src/lib/command.js:11:31)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/XXXXX/workspace/d-eins-erp/.doc/node_modules/@graphidocs/docs/src/lib/command.js',
    '/Users/XXXXX/workspace/d-eins-erp/.doc/node_modules/@graphidocs/docs/bin/graphidocs.js'
  ]
}

問題のところ
const graphidocsPackageJSON = require(path.resolve(__dirname, '../../package.json'));

これが存在しないがどうしようもないきが・・

代わりを考える
https://zenn.dev/codehex/articles/102b05544cce29#fnref-a763-1
https://zenn.dev/shuntaka/scraps/8175568eed2e31
https://github.com/wayfair/dociql

trend
https://npmtrends.com/dociql-vs-graphql-markdown-vs-graphqldoc

https://github.com/exogen/graphql-markdown

インストール成功

npm install graphql-markdown --save-dev
./node_modules/.bin/graphql-markdown --version
7.0.0
@tmk3s
Copy link
Owner Author

tmk3s commented Nov 23, 2023

devise_token_auth

install

gem 'devise_token_auth' # トークン認証

railsのversion => Rails 7.1.1

エラー

docker-compose exec app bundle install
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Could not find compatible versions

Because devise_token_auth >= 0.1.21.alpha2, < 0.1.23.alpha1 depends on rails ~> 4.1.4
  and devise_token_auth < 0.1.21.alpha2 depends on rails ~> 4.1,
  devise_token_auth < 0.1.23.alpha1 requires rails >= 4.1, < 5.A.
And because devise_token_auth >= 0.1.23.alpha1, < 0.1.31.beta3 depends on rails ~> 4.1
  and devise_token_auth >= 0.1.31.beta3, < 0.1.37 depends on rails ~> 4.2,
  devise_token_auth < 0.1.37 requires rails >= 4.1, < 5.A.
And because devise_token_auth >= 0.1.37, < 1.0.0.rc2 depends on rails < 6
  and devise_token_auth >= 1.0.0.rc2, < 1.1.1 depends on rails >= 4.2.0, < 6,
  devise_token_auth < 1.1.1 requires rails < 6.
And because devise_token_auth >= 1.1.1, < 1.1.5 depends on rails >= 4.2.0, < 6.1
  and devise_token_auth >= 1.1.5, < 1.2.1 depends on rails >= 4.2.0, < 6.2,
  devise_token_auth < 1.2.1 requires rails < 6.2.
So, because devise_token_auth >= 1.2.1 depends on rails >= 4.2.0, < 7.1
  and Gemfile depends on rails ~> 7.1.1,
  version solving has failed.

lynndylanhurley/devise_token_auth#1608 (comment)

まだ未対応みたい

lynndylanhurley/devise_token_auth#1608 (comment)

forkされたものを使ってみる
gem 'devise_token_auth', :git => 'https://github.com/single-stop-tony/devise_token_auth'

成功

手順通りにやる
https://devise-token-auth.gitbook.io/devise-token-auth/config

rails g devise_token_auth:install User auth

エラー

rails c

/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/dynamic_matchers.rb:22:in method_missing': undefined method devise' for User:Class (NoMethodError)

参考:lynndylanhurley/devise_token_auth#1579

rails generate devise:install

USER
コメントアウトして、

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  # devise :database_authenticatable, :registerable,
  #        :recoverable, :rememberable, :validatable
  # include DeviseTokenAuth::Concerns::User
end

/usr/local/bundle/gems/devise-4.9.3/lib/devise/rails/routes.rb:510:in `raise_no_devise_method_error!': User does not respond to 'devise' method. This usually means you haven't loaded your ORM file or it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb' or before your application definition in 'config/application.rb' (RuntimeError)

User model削除

mount_devise_token_auth_for 'User', at: 'auth'

上記をコメントアウト

その上でrails generate devise:install

で成功

データ作成

POST
http://localhost:8080/auth

{
  "email": "[email protected]",
  "password":"zaq12wsx"
}

@tmk3s
Copy link
Owner Author

tmk3s commented Nov 23, 2023

const token = {};
token['access-token'] = localStorage.getItem('accessToken');

型 '"access-token"' の式を使用して型 '{}' にインデックスを付けることはできないため、要素は暗黙的に 'any' 型になります。
  プロパティ 'access-token' は型 '{}' に存在しません。ts(7053)

const token:{[key: string]: string | null;} = {};
token['access-token'] = localStorage.getItem('accessToken');

@tmk3s
Copy link
Owner Author

tmk3s commented Nov 23, 2023

ActionDispatch::Request::Session::DisabledSessionError (Your application has sessions disabled. To write to the session you must first configure a session store):

https://qiita.com/KazuyaInoue/items/2d4065ddf2237c66dfd4
https://blog.dnpp.org/api_only_rails7_with_devise

@tmk3s
Copy link
Owner Author

tmk3s commented Dec 2, 2023

        <Text {...register("name")} name='社名' defaultValue={company?.name}/>

// export default function Text({name, defaultValue}: { name: string, defaultValue: string }) {
//   return (
//     <div className='p-5'>
//       <p className='text-gray-500 text-s'>{name}</p>
//       <input className='w-full h-10 outline outline-1 outline-gray-300' defaultValue={defaultValue}/>
//     </div>
//   )
// }


Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

https://qiita.com/s_taro/items/06ace4d323176a1f2fff
https://ja.react.dev/reference/react/forwardRef#usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant