laravelgraphqllaravel-lighthouse

Why command make:graphql:type UserType was not found in laravel/graphql/lighthouse app?


Starting with graphql on laravel site on some tutorials

    php artisan make:graphql:type UserType

   ERROR  There are no commands defined in the "make:graphql" namespace. Did you mean one of these?  

  ⇂ make  
...

In output of

php artisan  

I have :

graphql-playground
  graphql-playground:download-assets         Download the newest version of the GraphQLPlayground assets to serve them locally.


  ...


 lighthouse
  lighthouse:cache                           Compile the GraphQL schema and cache it.
  lighthouse:clear-cache                     Clear the GraphQL schema cache.
  lighthouse:directive                       Create a class for a custom schema directive.
  lighthouse:field                           Create a resolver class for a field on a non-root type.
  lighthouse:ide-helper                      Create IDE helper files to improve type checking and autocompletion.
  lighthouse:interface                       Create a type resolver class for a GraphQL interface type.
  lighthouse:mutation                        Create a resolver class for a single field on the root Mutation type.
  lighthouse:print-schema                    Compile the GraphQL schema and print the result.
  lighthouse:query                           Create a resolver class for a single field on the root Query type.
  lighthouse:scalar                          Create a class for a GraphQL scalar type.
  lighthouse:subscription                    Create a resolver class for a single field on the root Subscription type.
  lighthouse:union                           Create a type resolver class for a GraphQL union type.
  lighthouse:validate-schema                 Validate the GraphQL schema definition.
  lighthouse:validator                       Create a validator class

and no any more GraphQL items...

Did I miss some packages in installation ?

And do I need to add some custom graphql types into my project ? lessongs/docs I found are contradicting. Typing “graphql:type” in https://lighthouse-php.com/6/getting-started/installation.html I did not find anything. Is “graphql:type” some obsolete option ?

    "laravel/framework": "^9.48.0",
    "mll-lab/laravel-graphql-playground": "^2.6",
    "nuwave/lighthouse": "^6.6",

Solution

  • There is no command to create graphql schema types with the laravel lighthouse. In order to create a type, on the forder /graphql create a schemaTypes.graphql then write in it the types you want like:

    type User {
      id: ID!
      name: String!
      email: String!
      created_at: String!
      updated_at: String
    }
    

    Later, under you can use the type for mutations or querys like:

    type Query {
      users: [User!]!
      user(id: ID!): User
    }
    

    Check docs about the basic types of laravel Lighthouse. ps: don't forget to #import all schemas to the main schema.graphql.