-
-
Notifications
You must be signed in to change notification settings - Fork 575
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
Extending the Root Query Type #1656
Comments
Directives that the client can apply (those valid against operations, fields, fragments, selection sets, etc) become part of the schema. The other directive locations (field definition, object, etc) only become part of the schema if they are in the GraphQL spec, such as Adding a server-side directive to PostGraphile is currently meaningless. If you're doing this so that people may use the directive in
Graphile Build doesn't currently have a hook system around directives; you can only hook certain GraphQL types: https://github.com/graphile/graphile-engine/blob/1bc8cfefdab7a61fd7ad287bcdff66298352e308/packages/graphile-build/src/makeNewBuild.js#L336 so your |
I hadn't noticed that the code block had a scrollbar 🤦♂️
|
Understood. What's the method to get that serverside directive added to |
|
OK thanks, that gives me an idea about how to accomplish the goal. I can see what you mean about plugin ordering, that will be tricky. You're welcome to close this, I'll update this issue if/as I make progress. |
Merging typeDefs seems like a possibility: import { inspect } from 'util';
import { mergeTypeDefs } from '@graphql-tools/merge';
const result = mergeTypeDefs([`type Query`, `type Query @deprecated`]);
console.log(inspect(result, { depth: 10, colors: true })); results in: {
kind: 'Document',
definitions: [
{
name: { kind: 'Name', value: 'Query', loc: { start: 5, end: 10 } },
description: undefined,
kind: 'ObjectTypeDefinition',
loc: { start: 0, end: 22 },
fields: [],
directives: [
{
kind: 'Directive',
name: {
kind: 'Name',
value: 'deprecated',
loc: { start: 12, end: 22 }
},
arguments: [],
loc: { start: 11, end: 22 }
}
],
interfaces: []
},
{
kind: 'SchemaDefinition',
operationTypes: [
{
kind: 'OperationTypeDefinition',
type: {
kind: 'NamedType',
name: {
kind: 'Name',
value: 'Query',
loc: { start: 5, end: 10 }
}
},
operation: 'query'
}
]
}
]
} The directive is there, and that's clutch. The idea being a dev could perhaps specify a simplified schema annotated with directives (I'm sure that's turning up a nose but this is all an exercise) |
I'm going to close this because it doesn't seem actionable. We'd need to come up with a plan for defining exactly what directives mean and how they're used in PostGraphile and then set about implementing that. Feel free to open a discussion about that, but it's a very low priority for me. |
Summary
I'm doing what is probably a silly thing. I've defined a directive and am attempting to extend
Query
with that directive. The probably silly thing is withinTagQueryPlugin
where I'm attempting to use that plugin to add the directive - reason being that I'm seeking a smooth way to enable other devs in my org to add that directive. Nothing is throwing an error, but I'm unable to see the Symbol I've created in scope for the context, within myLogScopePlugin
plugin.Any pointers on where I've gone off the rails?
Additional context
Here's the code I'm playing with at the moment:
The text was updated successfully, but these errors were encountered: