Schema.graphql issue

Hi everybody,

I was wondering if anyone knew how to fix a schema.graphql upload issue I’m facing?

I’m trying to update my schema using this file:

But I get a number of errors – The first few are:

Schema does not pass validation. Violations:

Object 'Complaint' does not have a field named 'where'. (line 153, column 13):
  complaint(where: ComplaintWhereUniqueInput!): Complaint
            ^

Object 'Complaint' does not have a field named 'after'. (line 154, column 14):
  complaints(after: ComplaintWhereUniqueInput, before: ComplaintWhereUniqueInput, first: Int, last: Int, orderBy: ComplaintOrderByInput, where: ComplaintWhereInput): [Complaint!]
             ^

Object 'Complaint' does not have a field named 'before'. (line 154, column 48):
  complaints(after: ComplaintWhereUniqueInput, before: ComplaintWhereUniqueInput, first: Int, last: Int, orderBy: ComplaintOrderByInput, where: ComplaintWhereInput): [Complaint!]
                                               ^

Object 'Complaint' does not have a field named 'first'. (line 154, column 83):
  complaints(after: ComplaintWhereUniqueInput, before: ComplaintWhereUniqueInput, first: Int, last: Int, orderBy: ComplaintOrderByInput, where: ComplaintWhereInput): [Complaint!]
                                                                                  ^

Object 'Complaint' does not have a field named 'last'. (line 154, column 95):
  complaints(after: ComplaintWhereUniqueInput, before: ComplaintWhereUniqueInput, first: Int, last: Int, orderBy: ComplaintOrderByInput, where: ComplaintWhereInput): [Complaint!]
                                                                                              ^

Object 'Complaint' does not have a field named 'orderBy'. (line 154, column 106):

Does anybody know the correct way to add the ability to filter types/objects?

I’d like to be able to run a query like:

query Complaints {
    complaints( first: 1, where: {
      site: {
        equals: "pcc"
      }
    } ){
      link
    }

Thanks in advance!

UPDATE:

I think I have to implement this myself, based on this post? If that’s the case, it’s not obvious to me where I would add the “where”, “first” (etc) stuff – Does anybody have any pointers on that?

Fauna is trying to generate new indexes that filter on the field with names provided as args, given no further instruction using directives.

Yep you have to create indexes (several based on there several filters you want to use) yourself and call a UDF that Unions them all with @resolver

Got it, thanks for this info!

I think I may have picked an extremely tricky example to get started with…!

I’ll take a look through UDFs, but I think I may have to leave Fauna for the time being (given the time this might take to implement).

Is there an easy way to make a generic “where” search, for any field and any number of clauses?

ie, The UDF + FQL equivalent of WHERE col = X AND col2 LIKE '%Y%'; ?

(But generic, so the parameters and conditions can be specified dynamically upon invocation).

I’ve read the documentation and have searched the forums for examples, but I can’t quite figure out how to link it all together.

For example, the first, last, before, after and orderBy params would have to come before the where in the UDF (or is that not the case) ? I’m also not clear on how to ‘chain’ these so that if a query like this is passed, only the first one is returned:

query Complaints {
    complaints( first: 1, where: {
      site: {
        equals: "pcc"
      }
    } ){
      link
    }

@ptpaterson Sorry, one other thing:

I’m looking at the pagination page, and wondering: Is it possible to implement before and after at all?

Yep! Well I guess GraphQL restricts you to just _cursor as input. You can specify _cursor in any of the generated queries. Or you can use pagination in your own resolver UDFs.

Set pagination: true, i.e `@resolver(name: “udf_name”, pagination: true).

I also just made some notes for using pagination in UDFs.

This is all incredibly useful, thank you!

I assume I must be doing something wrong, because when I try to alter the first example function you gave, and add it via the dashboard, I see this:

My function is:

Query(
    Lambda(
        ["set", "size", "after", "before"],
        If(
            And(Not(Equals(Var("before"), null)), Not(Equals(Var("after"), null))),
            Paginate(Var("set"), { size: Var("size"), before: Var("before"), after: Var("after") }),
            If(
                Not(Equals(Var("before"), null)),
                Paginate(Var("set"), { size: Var("size"), before: Var("before") }),
                If(
                    Not(Equals(Var("after"),null)),
                    Paginate(Var("set"), { size: Var("size"), after: Var("after") }),
                    Paginate(Var("set"), { size: Var("size") }),
                )
            )
        )
    )
)

It is invalid to specify both after and before. Choose one to specify the page you want to “traverse” (my word) to.

So do not alter the example :stuck_out_tongue:

Are you trying to specify a range of elements to retrieve? You can do that, but that is separate from pagination. Pagination let’s you get pages of results from a Set by specifying a single cursor. Separately, you can modify a Set by specifying a Range. Does that make sense?

Ah-ha! Yes, it does make sense! Thank you!