Skip to content

@field namespace requirement is inconsistent #2350

@Yannick-Bruening

Description

@Yannick-Bruening

Hi,
we have an issue with our lighthouse powered GraphQL api.
Why do we need to specify the full namespace in an imported .graphql file but not in the schema.graphql.
It feels weird to define the full path with namespace in one .graphql file but not in the other.
Is this a bug or is this intended behaviour?

Versions in use

nuwave/lighthouse         5.71.0
nwidart/laravel-modules.  9.0.6

This is our file structure.
image

Contents of namespaces of lighthouse.php

<?php

...

/* resolve module paths is to get all Entities/Eloquent Models which are defined within the different modules */
'namespaces' => [
    'models' => ['App', 'App\\Models', ...resolveModulePaths('Entities')],
    'queries' => ['App\\GraphQL\\Queries', 'Modules\\GraphQL\\Queries'],
    'mutations' => ['App\\GraphQL\\Scalars', 'Modules\\GraphQL\\Mutations'],
    'subscriptions' => ['App\\GraphQL\\Subscriptions', 'Modules\\GraphQL\\Subscriptions'],
    'interfaces' => ['App\\GraphQL\\Interfaces', 'Modules\\GraphQL\\Interfaces'],
    'unions' => ['App\\GraphQL\\Unions', 'Modules\\GraphQL\\Unions'],
    'scalars' => ['App\\GraphQL\\Scalars', 'Modules\\GraphQL\\Scalars'],
    'directives' => ['App\\GraphQL\\Directives', 'Modules\\GraphQL\\Directives'],
    'validators' => ['App\\GraphQL\\Validators', 'Modules\\GraphQL\\Validators'],
],

...

Example field ZipCode

"""
validates a zipcode and returns all matching geopoints
"""
zipCode(zipcode: String!, countryIsoCode: String): ZipCode
@field(resolver: "Zip\\ZipcodeResolver")

Definition of ZipCode in graphql/types/zipcode/ZipCode.graphql

type ZipCode {
  zipCode: String
  
  isValid: Boolean
  
  geoPoints: [GeoPoint] 
  @field(resolver: "Modules\\GraphQL\\Queries\\Zip\\GeoPointsResolver")
}

Why doesn't Zip\\GeoPointsResolver work here. But Zip\\ZipcodeResolver works in the default schema file.

All of the types are imported through the graphql/types.graphql file

...

#import Zipcode/*.graphql

...

And this types.graphql itself is imported within the schema.graphql file.

If you have any questions regarding our structure etc. feel free to ask.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionRequest for support or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions