Comments (4)
hey @EdmundsEcho can you try to execute:
lookupType yourSchema "RequestInput"
And see what it returns ?
from graphql-api.
Great question. It returns Nothing
...
compileQuery
uses lookupType
to validate the 'TypeCondition'.
-- | Validate a type condition that appears in a query.
validateTypeCondition :: Schema -> AST.TypeCondition -> Validation TypeDefinition
validateTypeCondition schema (NamedType typeCond) =
case lookupType schema typeCond of <<< here
Nothing -> throwE (TypeConditionNotFound typeCond)
Just typeDefn -> pure typeDefn
My schema describes the DefinedInputType
among other Input
related objects. However, the schema does not record a inferred TypeDefinitionObject
that lookupType
might find.
makeSchema
calls the type class DefinesTypes
function getDefinedTypes :: t -> Map Name TypeDefinition
.
The InputType
instance of DefinesTypes
points to
DefinedInputType typeDefinition -> getDefinedTypes typeDefinition
In my case the DefinedInputType typeDefinition
pattern matches to:
(DefinedInputType
(InputTypeDefinitionObject
(InputObjectTypeDefinition (Name {unName = "RequestInput"})
(InputObjectFieldDefinition (Name {unName = etc... :| [])..
The getDefinedTypes
function cascade points to the following
Value type constructor :: Type
-----------------------------------------------
DefinedInputType InputTypeDefinition :: InputType ->
InputTypeDefinitionObject InputObjectTypeDefinition :: InputTypeDefinition ->
InputObjectTypeDefinition Name (NonEmpty InputObjectFieldDefinition) :: InputObjectTypeDefinition -> <<< here
InputObjectFieldDefinition Name (AnnotatedType InputType) (Maybe DefaultValue) :: InputObjectFieldDefinition ->
TypeNonNull :: AnnotatedType etc...
If the InputObjectTypeDefinition
is used to instantiate a TypeDefinition
during the compileQuery
operation, the getDefinedTypes
instance evaluates to mempty
TypeDefinitionInputObject InputObjectTypeDefinition ->
TypeDefinitionInputObject _ -> mempty
If only to promote some ideas, if this is what is going on, then perhaps there are two things to consider:
- Should the library ever combine type definitions for
InputObjectTypes
with the regularObjectTypes
(e.g., combined in the sameMap
collection)? - Should the
compileQuery
look for valid types in two separate collections of types, one forInputObjectTypes
and the other for the regularObjectTypes
? - Other explanation and thus consideration?
- E
from graphql-api.
One last observation for this evening. In the GraphQL.Internal.Validation
module the getInputTypeDefinition
relies on lookupType
.
-- | Ensure that a variable has a correct type declaration given a schema.
validateTypeAssertion :: Schema -> Variable -> AST.GType -> Validation (AnnotatedType InputType)
validateTypeAssertion schema var varTypeAST =
astAnnotationToSchemaAnnotation varTypeAST <$>
case lookupType schema varTypeNameAST of
Nothing -> validateVariableTypeBuiltin var varTypeNameAST
Just cleanTypeDef -> validateVariableTypeDefinition var cleanTypeDef
where
varTypeNameAST = getName varTypeAST
-- | Validate a variable type which has a type definition in the schema.
validateVariableTypeDefinition :: Variable -> TypeDefinition -> Validation InputType
validateVariableTypeDefinition var typeDef =
case getInputTypeDefinition typeDef of
Nothing -> throwE (VariableTypeIsNotInputType var $ getName typeDef)
Just value -> pure (DefinedInputType value)
Conclusion: lookupType
is being relied on to retrieve both ObjectTypes
and ObjectInputTypes
. Based on what I outlined in the previous post, the getDefinedTypes
used to populate the collection searched by lookupType
does not seem to record ObjectInputTypes
defined in the Schema
.
from graphql-api.
Does the library support using variables :: InputObject, instances of hasAnnotatedInputType
, in a query that gets compiled at runtime? Has anyone had success doing so? Thank you in advance. - E
from graphql-api.
Related Issues (20)
- Domain errors on Mutations HOT 1
- Deriving instance FromValue - guideline for using underscore in Record field names HOT 2
- Do the warnings 'No explicit implementation for ToValue' cause errors elsewhere
- Thinking about Subscriptions HOT 1
- Simplify code by using DuplicateRecordFields and NamedFieldPuns HOT 3
- Refactor Value kind definition
- Simplify Value related function
- Provide a way to pass initialValue between resolver calls HOT 1
- Should graphql's selection sets be subtypes or records in haskell (as opposed to JSON-like AST) ?
- Latest release points to 0.1.1 (not 0.3.0) HOT 1
- How to construct a complex Object from Record? HOT 6
- Intergrating GraphQL and Servent Generically HOT 1
- List of Object makes an error (Tried to treat object as if it were leaf field)
- Is this project still under development ? HOT 1
- Issue with parsing non-nullable types
- Parsing documents with comments HOT 1
- How Integrate with DB provider?
- Question regarding updated features HOT 2
- Build error in `src/GraphQL/Internal/Syntax/Parser.hs`: No instance for (ConvertText Text ByteString)
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-api.