Comments (2)
Switch to insomnia, and wait for it to do a schema request, you will see an error :
Names must only contain [_a-zA-Z0-9] but "agenda.schedules_exceptions_exception" does not
Never heard of insomnia, but I can reproduce the same error using GraphiQL, e.g. using https://github.com/mll-lab/laravel-graphiql
{
"errors": [
{
"message": "Names must only contain [_a-zA-Z0-9] but \"m.e\" does not.",
(is there a relation between the two, because the error is exactly the same?)
Anyway, I think the tooling to detect this is already possible: graphql-laravel is really just a (thin) layer on top of https://github.com/webonyx/graphql-php/ .
Your schema has a name, and in PHP code you can get the schema like this:
$schema = app('graphql')->schema('default');
This $schema
is of type \GraphQL\Type\Schema
and has a ->validate()
method you can call: $errors = $schema->validate();
, which returns an array of \GraphQL\Error\Error
, if any:
array:1 [
0 => GraphQL\Error\Error^ {#11569
#message: "Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "m.e" does not."
#code: 0
#file: "./vendor/webonyx/graphql-php/src/Utils/Utils.php"
In an project of mine I've written an artisan command, part of the CI pipeline, which basically does exactly what I laid out:
public function handle(): int
{
$schemaName = (string) $this->option('schema');
$schema = app('graphql')->schema($schemaName);
$result = $schema->validate();
if ($result) {
$this->error("Errors have been detected in the given GraphQL schema '$schemaName':");
dump($result);
return Kernel::RETURN_ERROR;
}
$this->info("No errors found in GraphQL schema '$schemaName");
return Kernel::RETURN_SUCCESS;
}
For performance reasons, such checks are not part of the runtime and have to be done out of band (the majority of schemas are "static", so one upfront validation run usually is enough).
from graphql-laravel.
Wow, thank you very much for your detailed answer, lots of useful insights on how to use the library differently.
I was actually looking how to "dynamically" load a schema based on export "channels" (i.e specific data endpoint for a specific frontend, like we have a "wordpress" channel in Laravel for our wordpress frontend), and also looking at multi-user access, which would load schemas and types from other definitions (maybe a Schema class).
I'll have some experiments and see how we can work with this information. Thanks again :)
For now I'll close the ticket but will update it if we have more info.
from graphql-laravel.
Related Issues (20)
- Tests are failing on CI HOT 3
- Cannot upgrade to laravel 10x because it cannot coexist with rebing dependency illuminate/contracts and illuminate/support
- Playground, are you thinking of implementing it?
- Unable to enable apq caching
- Is there documentation on returning objects with relation objects as a part of the type? HOT 4
- Pagination on Relation HOT 1
- Unexpected end of JSON input HOT 3
- queryContext in GraphQLController doesn't exist HOT 2
- L11: Unresolvable dependency resolving [Parameter #4 [ <required>; string $basePath ]] in class Illuminate\Foundation\Exceptions\Renderer\Renderer (500 Internal Server Error) HOT 1
- GraphQL Request must include at least one of those two parameters: \"query\" or \"queryId\" HOT 3
- Add support for thecodingmachine/safe 2.0 HOT 2
- Nullable and Filled
- Resolver context is not updated once a user is logged in HOT 2
- repo description nit
- Pagination error HOT 2
- Integration tests for L9 are not working anymore
- useing $args in the resolve cloture of a type item
- Missing parent table in SelectFields for UnionType and InterfaceType HOT 3
- Using getRelations of SelectFields involves only selecting the requested fields for relationships HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-laravel.